unity中ngui用table怎么实现折叠功能

unity中ngui用table怎么实现折叠功能,第1张

项目中UI经常要用到动态加载,比较简单的方法是使用UITexture控件,这样只用3W类下载好后直接给UITexture控件赋值就好了,缺点是DrawCall太高了,一个UITexture一个DrawCall,通常只有是背景这种才会使用UITexture控件,如果是下拉列表项,我们通常都是使用的UISprite控件,这时就需要我们在程序运行时,由程序创建图集,给UISprite控件使用。

NGUI实现的ScrollView中的控件中可以拖动里面的子物体!但是这些子物体是不带吸附作用的!比如说:现在有3张放在scrollView下,我拖动一下可能停在两张半的地方!我想要停在1张,2张 ,或者第3张的位置

;XXXspriteName = GetComponent(); sprite同一个atlas里通过spriteName设置UISprite sprite = gameObject; ;

我看了下NGUI关于 NGUIToolsSetActive(gameobject,state)这个方法的定义,是这样定义的
static public void SetActive (GameObject go, bool state)
{
if (state)
{
Activate(gotransform);
}
else
{
Deactivate(gotransform);
}
}
然后Activae(Transform t)是这样定义的:
static void Activate (Transform t)
{
SetActiveSelf(tgameObject, true);
// Prior to Unity 4, active state was not nested It was possible to have an enabled child of a disabled object
// Unity 4 onwards made it so that the state is nested, and a disabled parent results in a disabled child
#if UNITY_3_5
for (int i = 0, imax = tGetChildCount(); i < imax; ++i)
{
Transform child = tGetChild(i);
Activate(child);
}
#else
// If there is even a single enabled child, then we're using a Unity 40-based nested active state scheme
for (int i = 0, imax = tchildCount; i < imax; ++i)
{
Transform child = tGetChild(i);
if (childgameObjectactiveSelf) return;
}
// If this point is reached, then all the children are disabled, so we must be using a Unity 35-based active state scheme
for (int i = 0, imax = tchildCount; i < imax; ++i)
{
Transform child = tGetChild(i);
Activate(child);
}
#endif
}
SetActiveSelf(tgameObject, true);方法是这样定义的:
static public void SetActiveSelf(GameObject go, bool state)
{
#if UNITY_3_5
goactive = state;
#else
goSetActive(state);
#endif
}
结论就是他的这个NGUIToolsSetActive(gameObject, false);方法归根结底还是用的gameObjectsetActivate(bool state)方法,所以你还是直接用gameObjectsetActivate(bool state)方法就可以了

首先,将下载好的NGUI插件导入的相应的项目中。
打开NGUI菜单,Open->Atlas Maker。这个菜单可以让我们快速的创建一个游戏中的图集。
在该菜单打开后,只需要在文件下选择需要添加的入图集的便可自动加入到图集项目中,多张可以使用Ctrl或shift来选择。
4
点击create或add来创建或添加图集。下面便是我们的创建的图集文件。

NGUI实现的ScrollView中的控件中可以拖动里面的子物体!但是这些子物体是不带吸附作用的!比如说:现在有3张放在scrollView下,我拖动一下可能停在两张半的地方!我想要停在1张,2张 ,或者第3张的位置


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13347016.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-19
下一篇 2023-07-19

发表评论

登录后才能评论

评论列表(0条)

保存