예제 #1
0
        public override void OnGUI(MazeCreationWorkflowBackEnd backend)
        {
            unitPrefab = EditorGUILayout.ObjectField("Unit Prefab:", unitPrefab, typeof(GameObject), false) as GameObject;

            if (unitPrefab != null)
            {
                var unit = unitPrefab.GetComponent <MazeUnit>();

                if (unit != null)
                {
                    if (unit.Dimension != backend.selectedMaze.RoomDimension)
                    {
                        EditorUtility.DisplayDialog("Wrong Size!", "The selected Prefab has not the correct dimensions!", "Ok");
                        unitPrefab = null;
                    }
                    else
                    {
                        unitDimensions = unit.Dimension;
                    }
                }
                else
                {
                    EditorUtility.DisplayDialog("Wrong Selection!", "The Selected Prefab is not a MazeUnit!", "Reset");
                    unitPrefab = null;
                }
            }

            unitDimensions = EditorGUILayout.Vector3Field("Cell Size: ", unitDimensions);

            if (unitPrefab == null && GUILayout.Button("Create new Unit"))
            {
                UnitCreator.OpenUnitCreator(backend.selectedMaze.RoomDimension, c => {
                    // get the created Unit prefab automaticaly back to the Editor Window
                    c.onUnitPrefabCreated += prefab =>
                    {
                        var mazeUnit = prefab.GetComponent <MazeUnit>();

                        if (mazeUnit != null)
                        {
                            unitPrefab = prefab;
                        }
                    };
                });
            }

            EditorGUILayout.Space();

            if (unitPrefab == null)
            {
                removeMode = GUILayout.Toggle(removeMode || Event.current.shift, "Remove", "Button");
                return;
            }

            EditorGUILayout.BeginHorizontal();

            addMode    = GUILayout.Toggle(!removeMode, "Add", "Button");
            removeMode = GUILayout.Toggle(!addMode || Event.current.shift, "Remove", "Button");

            EditorGUILayout.EndHorizontal();
        }