/// <summary> /// Draws the GUI /// </summary> /// <param name="materialEditor">Material editor provided by the custom inspector</param> /// <param name="properties">Array of materialProperties provided by the custom inspector</param> public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { //if is the first cycle it runs, do the initializzations needed on the start function if (isFirstCycle) { Start(materialEditor, properties); isFirstCycle = false; } TSFunctions.DrawHeader(EditorGUIUtility.currentViewWidth, 10); //Temporary code for converting back HDR colors #if UNITY_2018_1_OR_NEWER if (FindProperty("_NeedsFix", properties).floatValue == 1) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Convert HDR colors back to 2017 look")) { foreach (MaterialProperty m in properties) { if (m.flags == MaterialProperty.PropFlags.HDR) { m.colorValue = m.colorValue.linear; } } FindProperty("_NeedsFix", properties).floatValue = 0; } if (GUILayout.Button("Keep current colors")) { FindProperty("_NeedsFix", properties).floatValue = 0; } EditorGUILayout.EndHorizontal(); } #endif //if a keyword is used to apply the effects on the shader caused by enabling/disabling a section, it needs to be set every update foreach (Material mat in _SpecularOn.targets) { TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0)); TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0); } //draw main section if (inspectorLevel == InspectorLevel.Basic) { basicMain.DrawSection(materialEditor); } else { main.DrawSection(materialEditor); } group.DrawSectionsList(materialEditor, properties); group.DrawAddButton(properties); TSFunctions.DrawFooter(); }
/// <summary> /// Main GUI update /// </summary> void OnGUI() { // If this is the first iteration since the window is opened, do the needed initializzations if (firstCycle) { Start(); } // Check if for some reason the updater is not initialized, this eventuality tends to happen if some code gets recompiled while the window is open if (updater == null) { updater = new TSUpdater(); } TSFunctions.DrawHeader(position.width, 10); section = (MultiWindowSection)GUILayout.Toolbar((int)section, Enum.GetNames(typeof(MultiWindowSection)), EditorStyles.toolbarButton, GUI.ToolbarButtonSize.Fixed); MainAreaScrollPos = EditorGUILayout.BeginScrollView(MainAreaScrollPos); GUILayout.Space(10); // Based on the section selected draw only the gui of said section switch (section) { case MultiWindowSection.Settings: DrawSettings(); break; case MultiWindowSection.Updater: DrawUpdater(); break; case MultiWindowSection.Credits: DrawCredits(); break; default: EditorGUILayout.LabelField("Something went wrong, maybe you should contact the creator and report this"); break; } EditorGUILayout.EndScrollView(); TSFunctions.DrawFooter(); }
/// <summary> /// Draws the GUI /// </summary> /// <param name="materialEditor">Material editor provided by the custom inspector</param> /// <param name="properties">Array of materialProperties provided by the custom inspector</param> public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { //if is the first cycle it runs, do the initializzations needed on the start function if (isFirstCycle) { Start(materialEditor, properties); isFirstCycle = false; } //Fetching properties is needed only if the start function has not run since the start function already fetches them once else { FindProperties(properties); } TSFunctions.DrawHeader(EditorGUIUtility.currentViewWidth, 10); //Temporary code for converting back HDR colors #if UNITY_2018_1_OR_NEWER if (FindProperty("_NeedsFix", properties).floatValue == 1) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Convert HDR colors back to 2017 look")) { foreach (MaterialProperty m in properties) { if (m.flags == MaterialProperty.PropFlags.HDR) { m.colorValue = m.colorValue.linear; } } FindProperty("_NeedsFix", properties).floatValue = 0; } if (GUILayout.Button("Keep current colors")) { FindProperty("_NeedsFix", properties).floatValue = 0; } EditorGUILayout.EndHorizontal(); } #endif //if a keyword is used to apply the effects on the shader caused by enabling/disabling a section, it needs to be set every update foreach (Material mat in _SpecularOn.targets) { TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", mat.GetFloat(_SpecularOn.name) != 0); TSFunctions.SetKeyword(mat, "_DETAIL_MAP", mat.GetFloat(_DetailMapOn.name) != 0); } //draw main section if (inspectorLevel == InspectorLevel.Basic) { DrawBasicMainSection(materialEditor); } else { if (!_RampOn.hasMixedValue && _RampOn.floatValue == 0f) { _Ramp.textureValue = TSConstants.DefaultRamp; _RampOffset.floatValue = 0f; _ShadowIntensity.floatValue = 0.4f; } DrawMainSection(materialEditor); } group.DrawSectionsList(materialEditor); group.DrawAddButton(); TSFunctions.DrawFooter(); }