public void onTopBar() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); string[] enumNames = Enum.GetNames(typeof(ImportPreferences.EPanel)); ImportPreferences.EPanel[] enumValues = (ImportPreferences.EPanel[])Enum.GetValues(typeof(ImportPreferences.EPanel)); for (int i = 0; i < enumNames.Length - 1; i++) { if (GUILayout.Toggle(panelState == enumValues[i], enumNames[i], EditorStyles.toolbarButton, GUILayout.Width(100))) { panelState = enumValues[i]; curPanel = GetCurrentPanel(); } } GUILayout.Toolbar(0, new[] { "" }, EditorStyles.toolbar, GUILayout.ExpandWidth(true)); if (GUILayout.Toggle(panelState == ImportPreferences.EPanel.Setting, enumNames[enumNames.Length - 1], EditorStyles.toolbarButton, GUILayout.Width(100))) { panelState = enumValues[enumNames.Length - 1]; curPanel = GetCurrentPanel(); } if (lastPanelState != panelState) { lastPanelState = panelState; curPanel.OnInit(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }
void OnGUI() { int newTab = mTab; GUILayout.BeginHorizontal(); if (GUILayout.Toggle(newTab == 0, "模型", "ButtonLeft")) { newTab = 0; } if (GUILayout.Toggle(newTab == 1, "特效", "ButtonMid")) { newTab = 1; } // if (GUILayout.Toggle(newTab == 2, "贴图", "ButtonMid")) newTab = 2; // if (GUILayout.Toggle(newTab == 3, "4", "ButtonMid")) newTab = 3; if (GUILayout.Toggle(newTab == 2, "贴图", "ButtonRight")) { newTab = 2; } GUILayout.EndHorizontal(); //tab切换时初始化相应的分页 if (mTab != newTab) { mTab = newTab; searchFilter = ""; currentPanel = initSubPanel(newTab); } //搜索 GUILayout.BeginHorizontal(); string after = EditorGUILayout.TextField("", searchFilter, "SearchTextField", GUILayout.Width(Screen.width - 20f)); if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f))) { after = ""; GUIUtility.keyboardControl = 0; } if (searchFilter != after) { NGUISettings.searchField = after; searchFilter = after; } GUILayout.EndHorizontal(); if (currentPanel != null) { currentPanel.OnGUI(); } GUILayout.Space(10); }
private void initzalize() { currentPanel = initSubPanel(0); }