Exemplo n.º 1
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            List <Perk> perkList = EditorDBManager.GetPerkList();

            if (GUI.Button(new Rect(window.position.width - 120, 5, 100, 25), "Save"))
            {
                EditorDBManager.SetDirtyPerk();
            }


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                int newSelectID = EditorDBManager.AddNewPerk();
                if (newSelectID != -1)
                {
                    SelectPerk(newSelectID);
                }
            }
            if (perkList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                int newSelectID = EditorDBManager.ClonePerk(selectID);
                if (newSelectID != -1)
                {
                    SelectPerk(newSelectID);
                }
            }


            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 = DrawPerkList(startX, startY, perkList);

            startX = v2.x + 25;

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


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

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

            //float cachedX=startX;
            v2            = DrawPerkConfigurator(startX, startY, perkList[selectID]);
            contentWidth  = v2.x + 50;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyPerk();
            }
        }