Example #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);
        }
Example #2
0
 protected void RecycleItem(ScrollItem it)
 {
     it.target.SetActive(false);
     Recycler.Add(it);
     if (ItemRecycle != null)
     {
         ItemRecycle(it);
     }
 }
 protected void RecycleItem(ScrollItem it)
 {
     it.target.activeSelf = false;
     Recycler.Add(it);
     if (ItemRecycle != null)
     {
         ItemRecycle(it);
     }
 }
Example #4
0
        void SetItemPostion(ScrollItem item)
        {
            int   r = item.index / Column;
            int   c = item.index % Column;
            float x = (c + 0.5f) * ItemSize.x;
            float y = (r + 0.5f) * ItemSize.y;

            x -= Position.x;
            x -= Size.x * 0.5f;
            y  = Position.y - y;
            y += Size.y * 0.5f;
            item.target.transform.localPosition = new Vector3(x, y, 0);
        }
Example #5
0
        void SetItemPostion(ScrollItem item, float ox, float oy)
        {
            int   r  = item.index / Column;
            int   c  = item.index % Column;
            float sx = c * ItemActualSize.x;
            float sy = r * ItemActualSize.y;

            sx -= _pos.x - ox;
            sy -= _pos.y - oy;
            var p = ItemOffset;

            p.x += sx;
            p.y -= sy;
            item.target.localPosition = p;
        }
        protected ScrollItem CreateItem()
        {
            if (Recycler.Count > 0)
            {
                var it = Recycler[0];
                it.target.activeSelf = true;
                it.index             = -1;
                Recycler.RemoveAt(0);
                return(it);
            }
            ModelElement me = new ModelElement();

            me.Load(modData);
            me.data.sizeDelta = ItemSize;
            me.SetParent(Model);
            ScrollItem a = new ScrollItem();

            a.target = me;
            if (creator != null)
            {
                if (creator.hotfix)
                {
                    if (creator.reflect != null)
                    {
                        a.obj = creator.reflect(me);
                    }
                    else
                    {
                        a.obj = me;
                    }
                }
                else if (creator.create)
                {
                    a.obj = creator.Create();
                    ModelManagerUI.ComponentReflection(me, a.obj);
                }
                else
                {
                    a.obj = me;
                }
            }
            else
            {
                a.obj = me;
            }
            me.IsChanged = true;
            return(a);
        }
Example #7
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);
        }
Example #8
0
        /// <summary>
        /// 创建项目实例
        /// </summary>
        /// <returns></returns>
        protected ScrollItem CreateItem()
        {
            if (Recycler.Count > 0)
            {
                var it = Recycler[0];
                it.target.gameObject.SetActive(true);
                it.index = -1;
                Recycler.RemoveAt(0);
                return(it);
            }
            ScrollItem a = new ScrollItem();

            if (creator != null)
            {
                if (creator.create)
                {
                    a.obj    = creator.Create();
                    a.target = HGUIManager.GameBuffer.Clone(ItemMod, creator.initializer).transform;
                }
                else
                {
                    var go = HGUIManager.GameBuffer.Clone(ItemMod);
                    a.obj    = go;
                    a.target = go.transform;
                }
            }
            else
            {
                var go = HGUIManager.GameBuffer.Clone(ItemMod);
                a.obj    = go;
                a.target = go.transform;
            }
            a.target.SetParent(Main);
            a.target.SetAsFirstSibling();
            a.target.localRotation = Quaternion.identity;
            a.target.localScale    = Vector3.one;
            var ui = a.target.GetComponent <UIElement>();

            if (ui != null)
            {
                UIElement.Resize(ui);
                ItemSize = ui.m_sizeDelta;
            }
            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);
        }
Example #10
0
        protected ScrollItem CreateItem()
        {
            if (Recycler.Count > 0)
            {
                var it = Recycler[0];
                it.target.gameObject.SetActive(true);
                it.index = -1;
                Recycler.RemoveAt(0);
                return(it);
            }
            ScrollItem a = new ScrollItem();

            if (creator != null)
            {
                if (creator.create)
                {
                    a.obj    = creator.Create();
                    a.target = HGUIManager.GameBuffer.Clone(ItemMod, creator.initializer).transform;
                }
                else
                {
                    var go = HGUIManager.GameBuffer.Clone(ItemMod);
                    a.obj    = go;
                    a.target = go.transform;
                }
            }
            else
            {
                var go = HGUIManager.GameBuffer.Clone(ItemMod);
                a.obj    = go;
                a.target = go.transform;
            }
            a.target.SetParent(Main);
            a.target.SetAsFirstSibling();
            a.target.localRotation = Quaternion.identity;
            return(a);
        }
Example #11
0
        public static ScrollItem GetCenterItem(List <ScrollItem> items)
        {
            if (items.Count < 1)
            {
                return(null);
            }
            float      min  = 100;
            ScrollItem item = items[0];

            for (int i = 1; i < items.Count; i++)
            {
                float x = items[i].target.data.localPosition.x;
                if (x < 0)
                {
                    x = -x;
                }
                if (x < min)
                {
                    min  = x;
                    item = items[i];
                }
            }
            return(item);
        }
Example #12
0
        public static ScrollItem GetCenterItem(List <ScrollItem> items)
        {
            if (items.Count < 1)
            {
                return(null);
            }
            float      min  = 100;
            ScrollItem item = items[0];

            for (int i = 1; i < items.Count; i++)
            {
                float y = items[i].target.transform.localPosition.y;
                if (y < 0)
                {
                    y = -y;
                }
                if (y < min)
                {
                    min  = y;
                    item = items[i];
                }
            }
            return(item);
        }