Example #1
0
    void DrawBlueprintsList()
    {
        Blueprint tempBP;

        GUILayout.BeginVertical("Blueprints", boxStyle);

        GUILayout.Space(15);

        blueprintListScrollPos = GUILayout.BeginScrollView(blueprintListScrollPos);

        for (int i = 0; i < loadedBlueprints.Count; i++)
        {
            tempBP = loadedBlueprints[i];

            if (tempBP == currentBlueprint)
            {
                GUI.backgroundColor = Color.cyan;
            }

            GUILayout.BeginHorizontal(boxStyle);
            if (GUILayout.Button("Blueprint : " + tempBP.blueprintName, invisibleButtonStyle))
            {
                if (tempBP != currentBlueprint)
                {
                    currentBlueprint = tempBP;
                }
                else
                {
                    currentBlueprint = null;
                }
            }
            GUILayout.EndHorizontal();

            GUI.backgroundColor = Color.white;
        }

        EditorGUILayout.EndScrollView();


        GUILayout.BeginHorizontal();
        if (GUILayout.Button("+", invisibleButtonStyle, GUILayout.Height(20), GUILayout.Width(20)))
        {
            var bp = Blueprint.CreateBlueprint();

            if (bp != null)
            {
                LoadBlueprints(); // reset blueprints
            }
        }
        if (GUILayout.Button("-", invisibleButtonStyle, GUILayout.Height(20), GUILayout.Width(20)))
        {
            if (currentBlueprint != null)
            {
                currentBlueprint.Delete();
                LoadBlueprints();
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
    }