示例#1
0
 void setupPanels()
 {
     GUILayoutOption[] layoutParams = { GUILayout.Width(40), GUILayout.Height(40) };
     EditorGUILayout.BeginHorizontal();
     for (int x = 0; x < bl.panelScripts.Length; x++)
     {
         if (x % 5 == 0)
         {
             EditorGUILayout.EndHorizontal();
             EditorGUILayout.BeginHorizontal();
         }
         // panels selection
         if (bl.panelEditVisuals[x] != null && bl.panelEditVisuals[x].texture != null)             // assigned texture version
         {
             if (GUILayout.Button(bl.panelEditVisuals[x].texture, GUI.skin.box, layoutParams))
             {
                 bl.setPanel(pos, x);
                 EditorWindow.GetWindow(typeof(BoardLayoutWindow), false, "Board Setup");
                 this.Close();
             }
         }
         else                 // script name version
         {
             if (GUILayout.Button(bl.panelScripts[x].GetType().Name.Substring(0,
                                                                              Mathf.Min(5, bl.panelScripts[x].name.Length)).ToString().Replace("Panel", ""),
                                  new GUILayoutOption[] { GUILayout.ExpandWidth(false) }))
             {
                 bl.setPanel(pos, x);
                 EditorWindow.GetWindow(typeof(BoardLayoutWindow), false, "Board Setup");
                 this.Close();
             }
         }
     }
     EditorGUILayout.EndHorizontal();
 }