Exemple #1
0
        void OnGUI()
        {
            this.scrollSystem = EditorGUILayout.ObjectField("当前ScrollSystem:", this.scrollSystem, typeof(ScrollSystem), true) as ScrollSystem;
            //GUILayout.Label("当前ScrollSystem:" + (scrollSystem != null ? scrollSystem.name : "null"));
            if (scrollSystem == null)
            {
                return;
            }
            tileHeight = EditorGUILayout.FloatField("元素高度", tileHeight);
            tileWidth  = EditorGUILayout.FloatField("元素宽度", tileWidth);
            GUILayout.BeginHorizontal();
            rowCount = EditorGUILayout.IntField("行数", rowCount);
            if (GUILayout.Button("设置高度"))
            {
                Undo.RecordObject(scrollSystem.transform as RectTransform, "设置高度");
                SetHeight();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            colCount = EditorGUILayout.IntField("列数", colCount);
            if (GUILayout.Button("设置宽度"))
            {
                Undo.RecordObject(scrollSystem.transform as RectTransform, "设置宽度");
                SetWidth();
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("设置高度和宽度"))
            {
                Undo.RecordObject(scrollSystem.transform as RectTransform, "设置高度和宽度");
                SetWidth();
                SetHeight();
            }
        }
Exemple #2
0
 protected void Init(ScrollSystem scrollSystem, string prefabName, object dataSource, Func <object, Vector2> onResize)
 {
     this.scrollSystem     = scrollSystem;
     this.objectPool       = scrollSystem.ObjectPoolDic[prefabName];
     this.dataSource       = dataSource;
     this.newLine          = objectPool.newLine;
     this.onResize         = onResize;
     this.isPositionInited = false;
 }
            public static SearchGroup Get(int left, int right, ScrollSystem scrollSystem)
            {
                var result = ObjectPool <SearchGroup> .Get();

                result.left   = left;
                result.right  = right;
                result.middle = (left + right) / 2;
                var curData = scrollSystem.listData[result.middle];

                result.distance = scrollSystem.onGetDistanceToCenter(curData.anchoredPosition);
                result.found    = curData.IsVisible();
                return(result);
            }
            public void Expand(List <SearchGroup> list, ScrollSystem scrollSystem)
            {
                int minus = right - left;

                if (minus > 1)
                {
                    list.Add(Get(left, middle - 1, scrollSystem));
                    list.Add(Get(middle + 1, right, scrollSystem));
                }
                else if (minus > 0)
                {
                    list.Add(Get(right, right, scrollSystem));
                }
            }
            public PrefabGroup(GameObject origin, ScrollSystem scrollSystem, int registPoolCount)
            {
                this.prefabName   = origin.name;
                this.origin       = origin;
                this.scrollSystem = scrollSystem;
                var prefabRectTransform = origin.transform as RectTransform;

                this.prefabWidth  = prefabRectTransform.sizeDelta.x;
                this.prefabHeight = prefabRectTransform.sizeDelta.y;
                var layout = origin.GetComponent <ScrollLayout>();

                if (layout != null)
                {
                    this.newLine = layout.newLine;
                }
                else
                {
                    this.newLine = ScrollLayout.NewLine.None;
                }
                this.pool = new GameObjectPool(origin, scrollSystem.ContentTrans.Value, registPoolCount);
            }
Exemple #6
0
        public static void ShowWindow(ScrollSystem scrollSystem)
        {
            if (scrollSystem.ContentTrans.Value.childCount <= 0)
            {
                Debug.LogError("ScrollSystem至少需要放置一个模板预制体");
                return;
            }
            var window = GetWindow <ScrollSystemSetSizeWindow>("ScrollSystemSetSizeWindow");

            window.scrollSystem = scrollSystem;

            var r = window.position;

            r.x             = Screen.currentResolution.width / 2 - r.width / 2;
            r.y             = Screen.currentResolution.height / 2 - r.height / 2;
            window.position = r;

            var originTransform = scrollSystem.ContentTrans.Value.GetChild(0) as RectTransform;

            window.tileWidth  = originTransform.sizeDelta.x;
            window.tileHeight = originTransform.sizeDelta.y;
        }
Exemple #7
0
 void Awake()
 {
     mScrollSystem = GameObject.FindObjectOfType <BanSupport.ScrollSystem>();
     mScrollSystem.PreSetting(1, 0, false, new Vector2(1, 1), new Vector2(5, 5), -1, 0);
 }
Exemple #8
0
 public ScrollData(ScrollSystem scrollSystem, string prefabName, object dataSource, Func <object, Vector2> onResize)
 {
     Init(scrollSystem, prefabName, dataSource, onResize);
 }
 public JumpState(ScrollSystem scrollSystem, Action <float> setNormalizedPos, Func <float> getNormalizedPos)
 {
     this.scrollSystem     = scrollSystem;
     this.setNormalizedPos = setNormalizedPos;
     this.getNormalizedPos = getNormalizedPos;
 }