Exemplo n.º 1
0
        /// <summary>
        /// 创建项目
        /// </summary>
        /// <param name="buffer">项目缓存</param>
        /// <param name="con">构造器</param>
        /// <param name="mod">UI模型数据</param>
        /// <param name="parent">父坐标变换</param>
        /// <returns></returns>
        protected ScrollItem CreateItem(List <ScrollItem> buffer, Constructor con, FakeStruct mod, Transform parent)
        {
            if (buffer.Count > 0)
            {
                var it = buffer[0];
                it.target.gameObject.SetActive(true);
                it.index = -1;
                buffer.RemoveAt(0);
                return(it);
            }
            ScrollItem a = new ScrollItem();

            if (con == null)
            {
                a.obj = a.target = HGUIManager.GameBuffer.Clone(mod).transform;
            }
            else
            {
                a.obj    = con.Create();
                a.target = HGUIManager.GameBuffer.Clone(mod, con.initializer).transform;
            }
            a.target.SetParent(parent);
            a.target.localScale    = Vector3.one;
            a.target.localRotation = Quaternion.identity;
            return(a);
        }
Exemplo n.º 2
0
        protected ScrollItem CreateItem()
        {
            if (Recycler.Count > 0)
            {
                var it = Recycler[0];
                it.target.SetActive(true);
                it.index = -1;
                Recycler.RemoveAt(0);
                return(it);
            }
            GameObject   go    = null;
            ScrollItem   a     = new ScrollItem();
            ModelElement model = new ModelElement();

            model.Load(ItemMod.ModData);
            model.SetParent(Model);
            if (creator != null)
            {
                if (creator.hotfix)
                {
                    go = ModelManagerUI.LoadToGame(model, null);
                    if (creator.reflect != null)
                    {
                        a.obj = creator.reflect(go);
                    }
                    else
                    {
                        a.obj = go;
                    }
                    a.target = go;
                }
                else
                {
                    a.obj    = creator.Create();
                    go       = ModelManagerUI.LoadToGame(model, a.obj);
                    a.target = go;
                }
            }
            else
            {
                go       = ModelManagerUI.LoadToGame(model, null);
                a.target = go;
                a.obj    = go;
            }
            return(a);
        }
        protected ScrollItem CreateItem(List <ScrollItem> buffer, Constructor con, ModelElement mod, ModelElement parent)
        {
            if (buffer.Count > 0)
            {
                var it = buffer[0];
                it.target.activeSelf = true;
                it.index             = -1;
                buffer.RemoveAt(0);
                return(it);
            }
            ModelElement me = new ModelElement();

            me.Load(mod.ModData);
            me.SetParent(parent);
            ScrollItem a = new ScrollItem();

            a.target = me;
            if (con == null)
            {
                a.obj = me;
            }
            else
            {
                if (con.hotfix)
                {
                    if (con.reflect != null)
                    {
                        a.obj = con.reflect(me);
                    }
                    else
                    {
                        a.obj = me;
                    }
                }
                else
                {
                    a.obj = con.Create();
                    ModelManagerUI.ComponentReflection(me, a.obj);
                }
            }
            return(a);
        }