Exemplo n.º 1
0
        private Collectible selectedCollectible;                        //currently select collectible to be plop on the grid

        void DrawEditModeCollectibleUI()
        {
            GUILayout.Label("Collectible To Deploy:");

            if (collectibleDB.ClearEmptyElement())
            {
                UpdateLabel_Collectible();
            }
            List <Collectible> collectibleList = collectibleDB.collectibleList;

            unitNumInRow = (int)Mathf.Max(1, Mathf.Floor((editorWidth) / 50));
            Rect rect = new Rect(0, 0, 0, 0);

            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < collectibleList.Count; i++)
            {
                if (i % unitNumInRow == 0)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }

                GUI.color = selectedCollectible == collectibleList[i] ? colorOn : Color.white;
                if (collectibleList[i].icon == null)
                {
                    cont = new GUIContent((Texture)null, collectibleList[i].itemName);
                }
                else
                {
                    cont = new GUIContent(collectibleList[i].icon.texture, collectibleList[i].itemName);
                }

                if (GUILayout.Button(cont, GUILayout.Width(45), GUILayout.Height(45)))
                {
                    selectedCollectible = collectibleList[i];
                }
                if (selectedCollectible == collectibleList[i])
                {
                    rect = GUILayoutUtility.GetLastRect();
                }
            }

            if (selectedCollectible != null)
            {
                rect.x += 3; rect.y += 3; rect.width -= 6; rect.height -= 6;
                TBEditorUtility.DrawSprite(rect, selectedCollectible.icon, selectedCollectible.itemName, false);
            }
            EditorGUILayout.EndHorizontal();

            GUI.color = Color.white;

            EditorGUILayout.Space();
        }
Exemplo n.º 2
0
        private Unit selectedUnit;              //currently select unit to be plop on the grid

        void DrawEditModeUnitUI()
        {
            GUILayout.Label("Unit's Faction:");

            for (int i = 0; i < factionManager.factionList.Count; i++)
            {
                GUI.color = unitFactionID == i ? colorOn : Color.white;
                if (GUILayout.Button(factionManager.factionList[i].name.ToString(), GUILayout.MaxWidth(editorWidth)))
                {
                    unitFactionID = i;
                }
            }

            GUILayout.Label("________________________________________________________________________________________________________", GUILayout.Width(editorWidth - 30));
            GUILayout.Label("Unit To Deploy:");

            unitDB.ClearEmptyElement();
            if (unitDB.ClearEmptyElement())
            {
                UpdateLabel_Unit();
            }
            List <Unit> unitList = unitDB.unitList;

            unitNumInRow = (int)Mathf.Max(1, Mathf.Floor((editorWidth) / 50));
            Rect rect = new Rect(0, 0, 0, 0);

            EditorGUILayout.BeginHorizontal();
            for (int i = 0; i < unitList.Count; i++)
            {
                if (i % unitNumInRow == 0)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }

                GUI.color = selectedUnit == unitList[i] ? colorOn : Color.white;
                if (unitList[i].iconSprite == null)
                {
                    cont = new GUIContent((Texture)null, unitList[i].unitName);
                }
                else
                {
                    cont = new GUIContent(unitList[i].iconSprite.texture, unitList[i].unitName);
                }

                if (GUILayout.Button(cont, GUILayout.Width(45), GUILayout.Height(45)))
                {
                    selectedUnit = unitList[i];
                }
                if (selectedUnit == unitList[i])
                {
                    rect = GUILayoutUtility.GetLastRect();
                }
            }

            if (selectedUnit != null)
            {
                rect.x += 3; rect.y += 3; rect.width -= 6; rect.height -= 6;
                TBEditorUtility.DrawSprite(rect, selectedUnit.iconSprite, selectedUnit.name, false);
            }
            EditorGUILayout.EndHorizontal();

            GUI.color = Color.white;

            EditorGUILayout.Space();
        }