public static void SubFoldout( string header, Dictionary <Material, Toggles> foldouts, Dictionary <Action, GUIContent> buttons, Material mat, MaterialEditor me, Action DisplayTabContent, bool error, MaterialProperty toggleProp ) { int buttonCount = buttons != null ? buttons.Count : 0; bool isToggled = DisplayErrorSubFoldoutElements(me, header, foldouts[mat].GetState(header), buttonCount, 0, error); foldouts[mat].SetState(header, isToggled); if (buttons != null) { DisplaySubFoldoutButtons(buttons); } else { MGUI.Space18(); } MGUI.SpaceN18(); SubFoldoutToggleProperty(me, toggleProp); MGUI.SpaceN4(); if (isToggled) { MGUI.Space10(); DisplayTabContent(); MGUI.Space4(); } else { MGUI.Space4(); } }
void OnGUI() { MGUI.Space10(); if (needsRefresh) { selection = 0; PopulateMaterialList(); needsRefresh = false; } MGUI.Space8(); GUILayout.Label(matCount + " material(s) with keywords found..."); MGUI.SpaceN4(); // Display list of materials // float boxSpacing = position.height-200 > 10 ? position.height-200 : 10; float spacing = (position.height / 2.0f); ContentBox(new Vector2(position.width, spacing)); scrollPos0 = EditorGUILayout.BeginScrollView(scrollPos0, GUILayout.Width(position.width + 1), GUILayout.Height(spacing)); if (materialNames != null) { selection = GUILayout.SelectionGrid(selection, materialNames, 1); } if (materials.Count > 0) { materials.TryGetValue(materialNames[selection], out selectedMat); } EditorGUILayout.EndScrollView(); // Display list of keywords ContentBox(new Vector2(position.width, spacing / 2)); scrollPos1 = EditorGUILayout.BeginScrollView(scrollPos1, GUILayout.Width(position.width + 1), GUILayout.Height(spacing / 2)); if (selectedMat != null) { keywords = selectedMat.shaderKeywords; if (excludeWhitelisted) { keywords = IsolateKeywords(selectedMat.shaderKeywords, whitelist); } GUILayout.SelectionGrid(0, keywords, 1, new GUIStyle("Label")); } EditorGUILayout.EndScrollView(); // Display info about selection if (selectedMat != null) { GUILayout.Label("Shader: "+ selectedMat.shader.name); GUILayout.Label("Total Keywords: "+ keywords.Length); } // Controls excludeWhitelisted = GUILayout.Toggle(excludeWhitelisted, " Exclude Whitelisted Keywords"); if (hasToggled != excludeWhitelisted) { needsRefresh = true; } hasToggled = excludeWhitelisted; if (GUILayout.Button("Refresh List")) { needsRefresh = true; } if (GUILayout.Button("Locate Selected")) { EditorUtility.FocusProjectWindow(); EditorGUIUtility.PingObject(selectedMat); } }