Esempio n. 1
0
    void setupPieces()
    {
        GUILayoutOption[] layoutParams = { GUILayout.Width(40), GUILayout.Height(40) };
        EditorGUILayout.BeginHorizontal();
        for (int x = 0; x < bl.pieceScripts.Length; x++)
        {
            if (x % 5 == 0)
            {
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
            }

            // pieces selection
            if (bl.pieceEditVisuals[x] != null && bl.pieceEditVisuals[x].texture != null)             // assigned texture version
            {
                if (GUILayout.Button(bl.pieceEditVisuals[x].texture, GUI.skin.label, layoutParams))
                {
                    bl.setPiece(pos, x);
                    EditorWindow.GetWindow(typeof(BoardLayoutWindow), false, "Board Setup");
                    this.Close();
                }
            }
            else if (bl.pieceScripts[x] != null)               // assigned texture version
            {
                if (GUILayout.Button(bl.pieceScripts[x].GetType().ToString().Replace("Piece", ""),
                                     new GUILayoutOption[] { GUILayout.ExpandWidth(false) }))
                {
                    bl.setPiece(pos, x);
                    EditorWindow.GetWindow(typeof(BoardLayoutWindow), false, "Board Setup");
                    this.Close();
                }
            }
        }
        EditorGUILayout.EndHorizontal();
    }