private void GUITopBar() { //if header is texture, draw it first so other ui elements can be positions below if (shaderHeader != null && shaderHeader.options.texture != null) { shaderHeader.Draw(); } Rect mainHeaderRect = EditorGUILayout.BeginHorizontal(); //draw editor settings button if (GUILayout.Button(new GUIContent("", Styles.settings_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { Thry.Settings window = Thry.Settings.getInstance(); window.Show(); window.Focus(); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); if (GUILayout.Button(Styles.search_icon, EditorStyles.largeLabel, GUILayout.MaxHeight(20))) { show_search_bar = !show_search_bar; } //draw master label text after ui elements, so it can be positioned between if (shaderHeader != null) { shaderHeader.Draw(new CRect(mainHeaderRect)); } //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true)); GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100)); EditorGUILayout.EndHorizontal(); }
private void GUITopBar() { //if header is texture, draw it first so other ui elements can be positions below if (shaderHeader != null && shaderHeader.options.texture != null) { shaderHeader.Draw(); } Rect mainHeaderRect = EditorGUILayout.BeginHorizontal(); //draw editor settings button if (GuiHelper.ButtonWithCursor(Styles.icon_style_settings, 25, 25)) { Thry.Settings window = Thry.Settings.getInstance(); window.Show(); window.Focus(); } if (GuiHelper.ButtonWithCursor(Styles.icon_style_search, 25, 25)) { show_search_bar = !show_search_bar; if (!show_search_bar) { ClearSearch(); } } Rect presetR = GUILayoutUtility.GetRect(25, 25); Presets.PresetGUI(presetR, this); //draw master label text after ui elements, so it can be positioned between if (shaderHeader != null) { shaderHeader.Draw(new CRect(mainHeaderRect)); } //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true)); GUILayout.FlexibleSpace(); GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100)); EditorGUILayout.EndHorizontal(); }
//-------------Main Function-------------- public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout)) { editorData = new EditorData(); editorData.editor = materialEditor; editorData.gui = this; editorData.textureArrayProperties = new List <ShaderProperty>(); editorData.firstCall = true; } editorData.properties = props; CheckInAnimationRecordMode(); m_RenderersForAnimationMode = MaterialEditor.PrepareMaterialPropertiesForAnimationMode(props, GUI.enabled); UpdateEvents(); //first time call inits if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout)) { OnOpen(); } editorData.shader = editorData.materials[0].shader; currentlyDrawing = editorData; active = this; //sync shader and get preset handler Config config = Config.Get(); if (editorData.materials != null) { Mediator.SetActiveShader(editorData.materials[0].shader); } //TOP Bar Rect mainHeaderRect = EditorGUILayout.BeginHorizontal(); //draw editor settings button if (GUILayout.Button(new GUIContent("", Styles.settings_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { Thry.Settings window = Thry.Settings.getInstance(); window.Show(); window.Focus(); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); if (GUILayout.Button(Styles.search_icon, EditorStyles.largeLabel, GUILayout.MaxHeight(20))) { show_search_bar = !show_search_bar; } //draw master label if exists if (masterLabelText != null) { GuiHelper.DrawMasterLabel(masterLabelText, mainHeaderRect); } //GUILayout.Label("Thryrallo",GUILayout.ExpandWidth(true)); GUILayout.Label("@UI by Thryrallo", Styles.made_by_style, GUILayout.Height(25), GUILayout.MaxWidth(100)); EditorGUILayout.EndHorizontal(); if (show_search_bar) { header_search_term = EditorGUILayout.TextField(header_search_term); } //Visibility menu if (editorData.show_HeaderHider) { HeaderHider.HeaderHiderGUI(editorData); } bool isMaterialLocked = editorData.use_ShaderOptimizer && editorData.propertyDictionary["_ShaderOptimizerEnabled"].materialProperty.floatValue == 1; if (editorData.use_ShaderOptimizer) { editorData.propertyDictionary["_ShaderOptimizerEnabled"].Draw(); } EditorGUI.BeginDisabledGroup(isMaterialLocked); //PROPERTIES if (header_search_term == "" || show_search_bar == false) { foreach (ShaderPart part in shaderparts.parts) { part.Draw(); } } else { foreach (ShaderPart part in editorData.propertyDictionary.Values) { if (IsSearchedFor(part, header_search_term)) { part.Draw(); } } } EditorGUI.EndDisabledGroup(); //Render Queue selection if (config.showRenderQueue) { materialEditor.RenderQueueField(); } //footer GuiHelper.drawFooters(footer); if (GUILayout.Button("@UI Made by Thryrallo", Styles.made_by_style)) { Application.OpenURL("https://www.twitter.com/thryrallo"); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); Event e = Event.current; bool isUndo = (e.type == EventType.ExecuteCommand || e.type == EventType.ValidateCommand) && e.commandName == "UndoRedoPerformed"; if (reloadNextDraw && Event.current.type == EventType.Layout) { reloadNextDraw = false; } if (isUndo) { reloadNextDraw = true; } //on swap if (on_swap_to_actions != null && swapped_to_shader) { foreach (DefineableAction a in on_swap_to_actions) { a.Perform(); } on_swap_to_actions = null; swapped_to_shader = false; } //test if material has been reset if (wasUsed && e.type == EventType.Repaint) { if (editorData.materials[0].HasProperty("shader_is_using_thry_editor") && editorData.materials[0].GetFloat("shader_is_using_thry_editor") != 69) { reloadNextDraw = true; HandleReset(); wasUsed = true; } } if (e.type == EventType.Used) { wasUsed = true; } if (input.HadMouseDownRepaint) { input.HadMouseDown = false; } input.HadMouseDownRepaint = false; editorData.firstCall = false; }
//-------------Main Function-------------- public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props) { if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout)) { current = new EditorData(); current.editor = materialEditor; current.gui = this; current.properties = props; current.textureArrayProperties = new List <ShaderProperty>(); current.firstCall = true; } //handle events UpdateEvents(); //first time call inits if (firstOnGUICall || (reloadNextDraw && Event.current.type == EventType.Layout)) { OnOpen(); } current.shader = current.materials[0].shader; currentlyDrawing = current; //sync shader and get preset handler Config config = Config.Get(); if (current.materials != null) { Mediator.SetActiveShader(current.materials[0].shader, presetHandler: presetHandler); } //TOP Bar Rect mainHeaderRect = EditorGUILayout.BeginHorizontal(); //draw editor settings button if (GUILayout.Button(new GUIContent("", Styles.settings_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20))) { Thry.Settings window = Thry.Settings.getInstance(); window.Show(); window.Focus(); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); if (GUILayout.Button(Styles.search_icon, EditorStyles.largeLabel, GUILayout.MaxHeight(20))) { show_search_bar = !show_search_bar; } //draw master label if exists if (masterLabelText != null) { GuiHelper.DrawMasterLabel(masterLabelText, mainHeaderRect); } Rect visibilityButtonPosition = GUILayoutUtility.GetRect(new GUIContent(Styles.visibility_icon), EditorStyles.largeLabel, GUILayout.MaxHeight(20), GUILayout.MaxWidth(20)); if (GUI.Button(visibilityButtonPosition, Styles.visibility_icon, EditorStyles.largeLabel)) { HeaderHider.DrawHeaderHiderMenu(visibilityButtonPosition, current.shaderParts); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); //draw presets if exists presetHandler.drawPresets(current.properties, current.materials); EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); EditorGUILayout.EndHorizontal(); if (show_search_bar) { header_search_term = EditorGUILayout.TextField(header_search_term); } //PROPERTIES if (header_search_term == "" || show_search_bar == false) { foreach (ShaderPart part in shaderparts.parts) { part.Draw(); } } else { foreach (ShaderPart part in current.propertyDictionary.Values) { if (IsSearchedFor(part, header_search_term)) { part.Draw(); } } } //Render Queue selection if (config.showRenderQueue) { if (config.renderQueueShaders) { customRenderQueueFieldInput = GuiHelper.drawRenderQueueSelector(current.defaultShader, customRenderQueueFieldInput); EditorGUILayout.LabelField("Default: " + current.defaultShader.name); EditorGUILayout.LabelField("Shader: " + current.shader.name); } else { materialEditor.RenderQueueField(); } } //footer GuiHelper.drawFooters(footer); EditorGUILayout.LabelField("@UI Powered by Thryrallo", Styles.made_by_style); Event e = Event.current; bool isUndo = (e.type == EventType.ExecuteCommand || e.type == EventType.ValidateCommand) && e.commandName == "UndoRedoPerformed"; if (reloadNextDraw && Event.current.type == EventType.Layout) { reloadNextDraw = false; } if (isUndo) { reloadNextDraw = true; } //on swap if (on_swap_to_actions != null && swapped_to_shader) { foreach (DefineableAction a in on_swap_to_actions) { a.Perform(); } on_swap_to_actions = null; swapped_to_shader = false; } //test if material has been reset if (wasUsed && e.type == EventType.Repaint) { if (current.materials[0].HasProperty("shader_is_using_thry_editor") && current.materials[0].GetFloat("shader_is_using_thry_editor") != 69) { reloadNextDraw = true; HandleReset(); wasUsed = true; } } if (e.type == EventType.Used) { wasUsed = true; } if (config.showRenderQueue && config.renderQueueShaders) { UpdateRenderQueueInstance(); } if (input.HadMouseDownRepaint) { input.HadMouseDown = false; } input.HadMouseDownRepaint = false; current.firstCall = false; }