/// <summary> /// Initializations needed when first opening the window /// </summary> public void Start() { firstCycle = false; // Gets the inspector level from editorPrefs, if for some reason is not present it just defaults to normal and writes it (should never happen if i remembered to do the first time window) if (EditorPrefs.HasKey(TSConstants.TSEPInspectorLevel)) { inspectorLevel = (InspectorLevel)EditorPrefs.GetInt(TSConstants.TSEPInspectorLevel); } else { inspectorLevel = InspectorLevel.Normal; EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)InspectorLevel.Normal); } // Loads the settings file if exists, creates a default one if not if (File.Exists(TSConstants.SettingsJSONPath)) { TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath)); sectionStyle = (SectionStyle)settings.sectionStyle; sectionColor = settings.sectionColor; isAutoUpdateDisabled = settings.disableUpdates; } else { TSSettings settings = new TSSettings(); settings.sectionStyle = (int)SectionStyle.Bubbles; settings.sectionColor = new Color(1, 1, 1, 1); settings.disableUpdates = false; File.WriteAllText(TSConstants.SettingsJSONPath, JsonUtility.ToJson(settings)); } }
public InspectAttribute(InspectorLevel level, Delegate method, bool condition, int priority) { this.level = level; this.condition = condition; this.priority = priority; this.delegates.Add(method); }
public InspectAttribute(InspectorLevel level, string methodName, bool condition, int priority) { this.level = level; this.condition = condition; this.methodName = methodName; this.priority = priority; }
public MainSection(MaterialProperty[] properties, InspectorLevel level, TexturePacker packer, ToonyStandardGUI gui) { FindProperties(properties); this.level = level; isTexturePackerOpen = false; Styles.ToggleTexturePackerContent(isTexturePackerOpen); this.packer = packer; this.gui = gui; }
public SpecularSection(MaterialProperty[] properties, InspectorLevel level, ToonyStandardGUI gui, bool open, bool enabled) : base(Styles.title, open, enabled) { FindProperties(properties); this.inspector = gui; this.level = level; foreach (Material mat in _SpecularOn.targets) { TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0)); SetupWorkflow(mat, (Workflow)_workflow.floatValue); SetupSpMode(mat, (SpMode)_SpMode.floatValue); } gradientEditor = new GradientEditor(); isGradientEditorOpen = false; needToStorePreviousRamp = true; Selection.selectionChanged += ResetRampTexture; }
void OnGUI() { TSFunctions.DrawHeader(position.width, 20); EditorGUILayout.LabelField("Seems like this is your first time installing Toony Standard, first of all, thanks for using it, it makes me happy.", TSConstants.Styles.multilineLabel); GUILayout.Space(10); EditorGUILayout.LabelField("Now, the only thing that you need to set immediately is the inspector level, this will tell the shader what features to expose based on your experience with making stuff in unity.", TSConstants.Styles.multilineLabel); GUILayout.Space(10); EditorGUILayout.LabelField("You can edit this choice later and modify other options by going on Window/Toony Standard/Settings ", TSConstants.Styles.multilineLabel); GUILayout.Space(10); EditorGUI.BeginChangeCheck(); inspectorLevel = (InspectorLevel)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.InspectorLevel, inspectorLevel); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)inspectorLevel); switch (inspectorLevel) { case InspectorLevel.Basic: boxMessage = "The basic level is suited for people who are relatively new to avatar creation giving them just the basic stuff they need to get started."; break; case InspectorLevel.Normal: boxMessage = "Normal level will give the vast majority of the features this shader has to offer, this is the default setting and probably will be the most used one."; break; case InspectorLevel.Expert: boxMessage = "Warning, i expect you to be experienced in what you're doing in order to select this.\nThis level grants access to all the features and little adjustments that you can do with this shader, even if you don't know what the hell they do."; break; } } EditorGUILayout.HelpBox(boxMessage, MessageType.Info); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Done!", GUILayout.MinWidth(100))) { this.Close(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); }
/// <summary> /// Draws the settings GUI /// </summary> private void DrawSettings() { EditorGUI.BeginChangeCheck(); inspectorLevel = (InspectorLevel)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.InspectorLevel, inspectorLevel); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(TSConstants.TSEPInspectorLevel, (int)inspectorLevel); } EditorGUI.BeginChangeCheck(); updater.updateStream = (UpdateStream)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.UpdateStream, updater.updateStream); if (EditorGUI.EndChangeCheck()) { LocalVersionJSON local = JsonUtility.FromJson <LocalVersionJSON>(File.ReadAllText(TSConstants.LocalJSONPath)); local.beta = updater.updateStream == UpdateStream.Beta; File.WriteAllText(TSConstants.LocalJSONPath, JsonUtility.ToJson(local)); updater.Reset(); } EditorGUI.BeginChangeCheck(); sectionStyle = (SectionStyle)EditorGUILayout.EnumPopup(TSConstants.TSWindowLabels.SectionStyle, sectionStyle); sectionColor = EditorGUILayout.ColorField(TSConstants.TSWindowLabels.Color, sectionColor); isAutoUpdateDisabled = EditorGUILayout.Toggle(TSConstants.TSWindowLabels.DisableAutoUpdates, isAutoUpdateDisabled); if (EditorGUI.EndChangeCheck()) { TSSettings settings = JsonUtility.FromJson <TSSettings>(File.ReadAllText(TSConstants.SettingsJSONPath)); settings.sectionStyle = (int)sectionStyle; settings.sectionColor = sectionColor; settings.disableUpdates = isAutoUpdateDisabled; File.WriteAllText(TSConstants.SettingsJSONPath, JsonUtility.ToJson(settings)); exampleSection = new Section(new GUIContent("Example Section"), true, delegate(MaterialEditor m){ EditorGUILayout.LabelField("Example content"); }, delegate(bool a, bool b){}); } GUILayout.Space(20); if (exampleSection == null) { exampleSection = new Section(new GUIContent("Example Section"), true, delegate(MaterialEditor m){ EditorGUILayout.LabelField("Example content"); }, delegate(bool a, bool b){}); } exampleSection.DrawSection(null); }
public InspectAttribute(InspectorLevel level, Delegate method) : this(level, method, true, 0) { }
public InspectAttribute(InspectorLevel level, string methodName, bool condition) : this(level, methodName, condition, 0) { }
public InspectAttribute(InspectorLevel level, string methodName) : this(level, methodName, true, 0) { }
public InspectAttribute(InspectorLevel level, string methodName, int priority) : this(level, methodName, true, priority) { }
public InspectAttribute(InspectorLevel level, int priority) : this(level, "", true, priority) { }
/// <summary> /// Initializzation that happens the first time the window is created /// </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 void Start(MaterialEditor materialEditor, MaterialProperty[] properties) { //Temporary code for transitioning between 2017 to 2018 if (FindProperty("_NeedsFix", properties).floatValue == 0.5) { #if UNITY_2018_1_OR_NEWER FindProperty("_NeedsFix", properties).floatValue = 0; #else FindProperty("_NeedsFix", properties).floatValue = 1; #endif } EditorGUIUtility.labelWidth = 0f; //material = materialEditor.target as Material; //Initialize properties FindProperties(properties); //Initializes the ramp section based on the inspector level inspectorLevel = (InspectorLevel)EditorPrefs.GetInt("TSInspectorLevel"); switch (inspectorLevel) { case InspectorLevel.Basic: basicMain = new BasicMainSection(properties); break; case InspectorLevel.Normal: packer = new TexturePacker(TexturePacker.Resolution.M_512x512, new string[] { "Metallic", "Smoothness", "Ambient occlusion", "Thickness map" }, GetTextureDestinationPath((Material)_RampOn.targets[0], "MSOT.png")); main = new MainSection(properties, inspectorLevel, packer, this); Selection.selectionChanged += SetMSOT; break; case InspectorLevel.Expert: packer = new TexturePacker(TexturePacker.Resolution.M_512x512, new string[] { "Metallic", "Smoothness", "Ambient occlusion", "Thickness map" }, GetTextureDestinationPath((Material)_RampOn.targets[0], "MSOT.png")); main = new MainSection(properties, inspectorLevel, packer, this); break; } foreach (Material mat in FindProperty("_Mode", properties).targets) { //remove keywords not used in Toony Standard RemoveUnwantedKeywords(mat); // Setup various keyword based settings SetupMaterialWithBlendMode(mat, (BlendMode)mat.GetFloat("_Mode"), mat.GetFloat("_OutlineOn") > 0); // Setup emission MaterialEditor.FixupEmissiveFlag(mat); bool shouldEmissionBeEnabled = (mat.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; TSFunctions.SetKeyword(mat, "_EMISSION", shouldEmissionBeEnabled); if (shouldEmissionBeEnabled) { mat.SetOverrideTag("IsEmissive", "true"); } else { mat.SetOverrideTag("IsEmissive", "false"); } } GenerateRampMinMax(properties); // Add sections based on the inspector level group = new OrderedSectionGroup(); if (inspectorLevel == InspectorLevel.Basic) { group.addSection(new BasicSpecularSection(properties, TSFunctions.BooleanFloat(_SpecularBox.floatValue), TSFunctions.BooleanFloat(_SpecularOn.floatValue))); group.addSection(new OutlineSection(properties, TSFunctions.BooleanFloat(_OutlineBox.floatValue), TSFunctions.BooleanFloat(_OutlineOn.floatValue))); } else { group.addSection(new RampSection(this, properties, TSFunctions.BooleanFloat(_ToonRampBox.floatValue), TSFunctions.BooleanFloat(_RampOn.floatValue))); group.addSection(new RimLightSection(properties, TSFunctions.BooleanFloat(_RimLightBox.floatValue), TSFunctions.BooleanFloat(_RimLightOn.floatValue))); group.addSection(new SpecularSection(properties, inspectorLevel, this, TSFunctions.BooleanFloat(_SpecularBox.floatValue), TSFunctions.BooleanFloat(_SpecularOn.floatValue))); group.addSection(new DetailSection(properties, TSFunctions.BooleanFloat(_DetailBox.floatValue), TSFunctions.BooleanFloat(_DetailMapOn.floatValue))); group.addSection(new SubsurfaceSection(properties, inspectorLevel, this, TSFunctions.BooleanFloat(_SSSBox.floatValue), TSFunctions.BooleanFloat(_SSSOn.floatValue))); group.addSection(new OutlineSection(properties, TSFunctions.BooleanFloat(_OutlineBox.floatValue), TSFunctions.BooleanFloat(_OutlineOn.floatValue))); } if (inspectorLevel == InspectorLevel.Expert) { group.addSection(new StencilSection(properties, TSFunctions.BooleanFloat(_StencilBox.floatValue), TSFunctions.BooleanFloat(_StencilOn.floatValue))); } else { FindProperty("_StencilID", properties).floatValue = 0; FindProperty("_StencilComp", properties).floatValue = 0; FindProperty("_StencilOp", properties).floatValue = 0; } }
public InspectAttribute(InspectorLevel level) : this(level, "", true, 0) { }
public InspectAttribute(InspectorLevel level, Delegate method, int priority) : this(level, method, true, priority) { }
/// <summary> /// Initializzation that happens the first time the window is created /// </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 void Start(MaterialEditor materialEditor, MaterialProperty[] properties) { //Temporary code for transitioning between 2017 to 2018 if (FindProperty("_NeedsFix", properties).floatValue == 0.5) { #if UNITY_2018_1_OR_NEWER FindProperty("_NeedsFix", properties).floatValue = 0; #else FindProperty("_NeedsFix", properties).floatValue = 1; #endif } EditorGUIUtility.labelWidth = 0f; material = materialEditor.target as Material; //Initialize properties FindProperties(properties); //Set some values based on the inspector level setting inspectorLevel = (InspectorLevel)EditorPrefs.GetInt("TSInspectorLevel"); switch (inspectorLevel) { case InspectorLevel.Basic: _Occlusion.floatValue = 0f; _FakeLight.floatValue = 0f; _RimLightOn.floatValue = 0; _workflow.floatValue = (float)Workflow.Metallic; _MetallicMap.textureValue = null; _GlossinessMap.textureValue = null; _SpMode.floatValue = (float)SpMode.Standard; _indirectSpecular.floatValue = (float)IndirectSpecular.Probe; _HighlightRamp.textureValue = TSConstants.DefaultRamp; _HighlightRampOffset.floatValue = 0f; _DetailMapOn.floatValue = 0f; break; case InspectorLevel.Normal: break; case InspectorLevel.Expert: break; } 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); } // Setup various keyword based settings SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode")); SetupIndirectSource(material, (IndirectSpecular)material.GetFloat("_IndirectSpecular")); SetupWorkflow(material, (Workflow)material.GetFloat("_Workflow")); SetupSpMode(material, (SpMode)_SpMode.floatValue); // Setup emission MaterialEditor.FixupEmissiveFlag(material); bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; TSFunctions.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); if (shouldEmissionBeEnabled) { material.SetOverrideTag("IsEmissive", "true"); } else { material.SetOverrideTag("IsEmissive", "false"); } // Add sections based on the inspector level group = new OrderedSectionGroup(); if (inspectorLevel == InspectorLevel.Basic) { group.addSection(new OrderedSection(Styles.specularOptions, DrawBasicSpecularOptionsSection, CheckBasicSpecularOptionsSection, SpecularOptionsIndex)); } else { group.addSection(new OrderedSection(Styles.rampOptions, DrawRampOptionsSection, CheckRampOptionsChanges, RampOptionsIndex)); group.addSection(new OrderedSection(Styles.rimOptions, DrawRimLightOptionsSection, CheckRimLightOptionsSection, RimLightOptionsIndex)); group.addSection(new OrderedSection(Styles.specularOptions, DrawSpecularOptionsSection, CheckSpecularOptionsSection, SpecularOptionsIndex)); group.addSection(new OrderedSection(Styles.detailOptions, DrawDetailOptionsSection, CheckDrawDetailOptionsSection, DetailOptionsIndex)); } }
public SubsurfaceSection(MaterialProperty[] properties, InspectorLevel level, ToonyStandardGUI gui, bool open, bool enabled) : base(Styles.title, open, enabled) { this.inspector = gui; this.level = level; FindProperties(properties); }