示例#1
0
    private void OnGUI()
    {
        EditorGUILayout.LabelField("BOARD CREATOR", EditorStyles.boldLabel);

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("This tool will create a new board prefab " +
                                   "according to the desired number of rows and columns. \n\n" +
                                   "Cells will be automatically arranged to fit the board.\n\n" +
                                   "Upon hitting create, the prefab will be created and loaded into the scene " +
                                   "and you will be editing the prefab itself with scene view open.\n\n" +
                                   "Here you can edit each cell individually.",
                                   EditorStyles.helpBox);

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        columns = EditorGUILayout.IntField("Columns: ", columns);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        rows = EditorGUILayout.IntField("Rows: ", rows);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        if (GUILayout.Button("CREATE"))
        {
            if (rows < 5 || columns < 5)
            {
                throw new Exception($"Board must have at least 5 rows & columns!");
            }

            EditorWindow sceneView = EditorWindow.GetWindow <SceneView>();
            sceneView.Focus();
            sceneView.Repaint();

            CreateBoardPrefab();

            BoardCreatorGUI boardCreationWindow = GetWindow <BoardCreatorGUI>("Board Creation");
            boardCreationWindow.Close();
        }
    }
示例#2
0
    public static void OpenBoardCreationWindow()
    {
        BoardCreatorGUI boardCreationWindow = GetWindow <BoardCreatorGUI>("Board Creator");

        boardCreationWindow.Show();
    }