Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #4
0
 public virtual void InitOnGroup(UIBindRoot root, BaseUIBindGroup group, int arrayIndex)
 {
 }
Beispiel #5
0
        public void AddRefOnGroup(string refName, object value, BaseUIBindGroup group)
        {
            var dataSet = group.DataSet;

            dataSet.Set(refName, value);
        }
Beispiel #6
0
        public int CreateCellOnGroup(GameObject gameObject, string bindFuncName, string bindDataName, BaseUIBindGroup group, object param)
        {
            var                dataSet  = group.DataSet;
            UIDataCell         cell     = new UIDataCell(bindDataName, dataSet, param, gameObject);
            UIDataCellCallback callback = new UIDataCellCallback(this, bindFuncName, cell);

            dataSet.AddListener(bindDataName, callback.Run);
            this.callbacks.Add(callback);
            return(this.callbacks.Count);
        }
Beispiel #7
0
 //初始化,事件注册在root下
 public override void InitOnGroup(UIBindRoot root, BaseUIBindGroup group, int arrayIndex)
 {
     this.root = root;
     cellIndex = root.CreateCellOnGroup(this.gameObject, this.GetBindFunctionName(), this.bindDataName, group, this.GetParam());
 }