示例#1
0
        private void InitBindDatas(GameObject gameObject)
        {
            //数组下的内容交给数组来注册了
            if (gameObject.GetComponent <UIBindArrayTemplate>() != null)
            {
                return;
            }

            //注册Group
            BaseUIBindGroup bindGroup = gameObject.GetComponent <BaseUIBindGroup>();

            if (bindGroup)
            {
                bindGroup.Init(this);
                return;
            }

            //注册数组
            BaseUIBindArray bindArray = gameObject.GetComponent <BaseUIBindArray>();

            if (bindArray)
            {
                bindArray.Init(this);
            }

            var sNodes = StaticObject <List <BaseUINode> > .Instance;

            //注册事件和绑定
            gameObject.GetComponents <BaseUINode>(sNodes);
            foreach (var component in sNodes)
            {
                component.InitOnRoot(this);
            }
            sNodes.Clear();

            for (int i = 0; i < gameObject.transform.childCount; i++)
            {
                InitBindDatas(gameObject.transform.GetChild(i).gameObject);
            }
        }
示例#2
0
        private void InitBindDatas(Transform transform, int index, Transform rootTrans)
        {
            if (transform != rootTrans && transform.GetComponent <UIBindArrayTemplate>() != null)
            {
                return;
            }

            var sNodes = StaticObject <List <BaseUINode> > .Instance;

            transform.GetComponents <BaseUINode>(sNodes);
            foreach (var component in sNodes)
            {
                component.InitOnArray(root, this, index);
            }
            sNodes.Clear();

            //注册数组
            BaseUIBindArray bindArray = transform.GetComponent <BaseUIBindArray>();

            if (bindArray)
            {
                bindArray.Init(this.root, this, index);
            }

            //注册Group
            BaseUIBindGroup bindGroup = transform.GetComponent <BaseUIBindGroup>();

            if (bindGroup)
            {
                bindGroup.Init(this.root, this, index);
                return;
            }

            //防止调不到OnDestroy
            for (int i = 0; i < transform.childCount; i++)
            {
                InitBindDatas(transform.GetChild(i), index, rootTrans);
            }
        }
示例#3
0
        private void InitBindDatas(Transform transform, BaseUIBindContainer parent = null, int arrayIndex = 0)
        {
            if (transform.GetComponent <UIBindArrayTemplate>() != null)
            {
                return;
            }

            var sNodes = StaticObject <List <BaseUINode> > .Instance;

            transform.GetComponents <BaseUINode>(sNodes);
            foreach (var component in sNodes)
            {
                component.InitOnGroup(root, this, arrayIndex);
            }
            sNodes.Clear();

            //注册数组
            BaseUIBindArray bindArray = transform.GetComponent <BaseUIBindArray>();

            if (bindArray)
            {
                bindArray.Init(this.root, this, arrayIndex);
            }

            //注册Group
            BaseUIBindGroup bindGroup = transform.GetComponent <BaseUIBindGroup>();

            if (bindGroup && bindGroup != this)
            {
                bindGroup.Init(this.root, this, arrayIndex);
                return;
            }

            for (int i = 0; i < transform.childCount; i++)
            {
                InitBindDatas(transform.GetChild(i), parent, arrayIndex);
            }
        }