예제 #1
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            if (!CheckIsPlaying())
            {
                return;
            }
            if (window == null)
            {
                Init();
            }


            List <UnitCreep> creepList = CreepDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(CreepDB.GetDB(), "creepDB");
            if (creepList.Count > 0)
            {
                Undo.RecordObject(creepList[selectID], "creep");
            }


            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                TDE.SetDirty();
            }

            UnitCreep newCreep = null;

            TDE.Label(5, 7, 150, 17, "Add New Creep:", "Drag creep prefab to this slot to add it to the list");
            newCreep = (UnitCreep)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newCreep, typeof(UnitCreep), false);
            if (newCreep != null)
            {
                Select(NewItem(newCreep));
            }


            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawCreepList(startX, startY, creepList);

            startX = v2.x + 25;

            if (creepList.Count == 0)
            {
                return;
            }


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY);
            Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight);

            scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect);

            v2            = DrawUnitConfigurator(startX, startY, creepList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }