public override void EndBoxCheck(bool isOpen, bool isEnabled)
        {
            _SpecularBox.floatValue = TSFunctions.floatBoolean(isOpen);

            if (!isEnabled)
            {
                if (!_SpecularOn.hasMixedValue)
                {
                    foreach (Material mat in _SpecularOn.targets)
                    {
                        TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !isEnabled);
                        _SpecularOn.floatValue = TSFunctions.floatBoolean(!mat.IsKeywordEnabled("_SPECULARHIGHLIGHTS_OFF"));
                    }
                }
            }

            foreach (Material mat in _workflow.targets)
            {
                SetupWorkflow(mat, (Workflow)_workflow.floatValue);
            }
            foreach (Material mat in _SpMode.targets)
            {
                SetupSpMode(mat, (SpMode)_SpMode.floatValue);
            }
        }
Exemple #2
0
 public override void OnAdd()
 {
     foreach (Material mat in _SpecularOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0));
     }
 }
 public override void OnAdd()
 {
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0);
     }
 }
Exemple #4
0
        public void CheckSpecularOptionsSection(bool isOpen, bool isEnabled)
        {
            _SpecularBox.floatValue = TSFunctions.floatBoolean(isOpen);
            foreach (Material mat in _SpecularOn.targets)
            {
                if (!isEnabled)
                {
                    if (!_SpecularOn.hasMixedValue)
                    {
                        TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", isEnabled);
                        _SpecularOn.floatValue = TSFunctions.floatBoolean(material.IsKeywordEnabled("_ENABLE_SPECULAR"));
                    }
                }
            }

            foreach (Material mat in _workflow.targets)
            {
                SetupWorkflow(mat, (Workflow)_workflow.floatValue);
            }
            foreach (Material mat in _SpMode.targets)
            {
                SetupSpMode(mat, (SpMode)_SpMode.floatValue);
            }
            foreach (Material mat in _indirectSpecular.targets)
            {
                SetupIndirectSource(mat, (IndirectSpecular)_indirectSpecular.floatValue);
            }
        }
Exemple #5
0
        public void DrawSection(MaterialEditor materialEditor)
        {
            EditorGUI.BeginChangeCheck();
            TSFunctions.DrawSelector(Enum.GetNames(typeof(ToonyStandardGUI.BlendMode)), _blendMode, Styles.blendMode, materialEditor);
            if (EditorGUI.EndChangeCheck())
            {
                foreach (Material mat in _blendMode.targets)
                {
                    ToonyStandardGUI.SetupMaterialWithBlendMode(mat, (ToonyStandardGUI.BlendMode)_blendMode.floatValue, mat.GetFloat("_OutlineOn") > 0);
                }
            }

            // Draw cull mode
            materialEditor.ShaderProperty(_Cull, Styles.cullMode);
            EditorGUILayout.Space();

            // Draw main properties
            materialEditor.TexturePropertySingleLine(Styles.mainTex, _MainTex, _Color);
            if ((ToonyStandardGUI.BlendMode)_blendMode.floatValue == ToonyStandardGUI.BlendMode.Cutout)
            {
                EditorGUI.indentLevel += MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1;
                materialEditor.ShaderProperty(_Cutoff, Styles.cutOff);
                EditorGUI.indentLevel -= MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1;
            }
            materialEditor.TexturePropertySingleLine(Styles.normal, _BumpMap, _BumpScale);

            materialEditor.TexturePropertySingleLine(Styles.ramp, _Ramp, _RampColor);
            materialEditor.ShaderProperty(_RampOffset, Styles.rampOffset);
            materialEditor.ShaderProperty(_ShadowIntensity, Styles.shadowIntensity);

            // Emission
            EditorGUI.BeginChangeCheck();
            if (materialEditor.EmissionEnabledProperty())
            {
                materialEditor.TexturePropertySingleLine(Styles.emission, _Emission, _EmissionColor);
                materialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel);
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (Material mat in _Emission.targets)
                {
                    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");
                    }
                }
            }

            materialEditor.TextureScaleOffsetProperty(_MainTex);

            EditorGUILayout.Space();
        }
        public DetailSection(MaterialProperty[] properties, bool open, bool enabled) : base(Styles.title, open, enabled)
        {
            FindProperties(properties);

            foreach (Material mat in _DetailMapOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", mat.GetFloat(_DetailMapOn.name) != 0);
            }
        }
Exemple #7
0
        public BasicSpecularSection(MaterialProperty[] properties, bool open, bool enabled) : base(Styles.title, open, enabled)
        {
            FindProperties(properties);

            foreach (Material mat in _SpecularOn.targets)
            {
                TSFunctions.SetKeyword(mat, "_SPECULARHIGHLIGHTS_OFF", !(mat.GetFloat(_SpecularOn.name) != 0));
            }
        }
 public override void OnAdd()
 {
     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);
     }
 }
Exemple #9
0
        /// <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();
        }
Exemple #10
0
 public void CheckBasicSpecularOptionsSection(bool isOpen, bool isEnabled)
 {
     _SpecularBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _SpecularOn.targets)
     {
         if (!isEnabled)
         {
             if (!_SpecularOn.hasMixedValue)
             {
                 TSFunctions.SetKeyword(mat, "_ENABLE_SPECULAR", isEnabled);
                 _SpecularOn.floatValue = TSFunctions.floatBoolean(material.IsKeywordEnabled("_ENABLE_SPECULAR"));
             }
         }
     }
 }
Exemple #11
0
 public void CheckDrawDetailOptionsSection(bool isOpen, bool isEnabled)
 {
     _DetailBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MAP", isEnabled);
     }
     if (!isEnabled)
     {
         if (!_DetailMapOn.hasMixedValue)
         {
             _DetailMapOn.floatValue = 0;
         }
     }
 }
 public override void EndBoxCheck(bool isOpen, bool isEnabled)
 {
     _DetailBox.floatValue = TSFunctions.floatBoolean(isOpen);
     foreach (Material mat in _DetailMapOn.targets)
     {
         TSFunctions.SetKeyword(mat, "_DETAIL_MULX2", isEnabled);
     }
     if (!isEnabled)
     {
         if (!_DetailMapOn.hasMixedValue)
         {
             _DetailMapOn.floatValue = 0;
         }
     }
 }
        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;
        }
Exemple #14
0
        public void DrawSection(MaterialEditor materialEditor)
        {
            EditorGUI.BeginChangeCheck();
            TSFunctions.DrawSelector(Enum.GetNames(typeof(ToonyStandardGUI.BlendMode)), _blendMode, Styles.blendMode, materialEditor);
            if (EditorGUI.EndChangeCheck())
            {
                foreach (Material mat in _blendMode.targets)
                {
                    ToonyStandardGUI.SetupMaterialWithBlendMode(mat, (ToonyStandardGUI.BlendMode)_blendMode.floatValue, mat.GetFloat("_OutlineOn") > 0);
                }
            }

            //draw cull mode
            materialEditor.ShaderProperty(_Cull, Styles.cullMode);
            EditorGUILayout.Space();

            //draw main properties
            materialEditor.TexturePropertySingleLine(Styles.mainTex, _MainTex, _Color);
            if ((ToonyStandardGUI.BlendMode)_blendMode.floatValue == ToonyStandardGUI.BlendMode.Cutout)
            {
                EditorGUI.indentLevel += MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1;
                materialEditor.ShaderProperty(_Cutoff, Styles.cutOff);
                EditorGUI.indentLevel -= MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1;
            }
            materialEditor.TexturePropertySingleLine(Styles.normal, _BumpMap, _BumpScale);

            if (level == InspectorLevel.Normal)
            {
                Rect r = TSFunctions.GetControlRectForSingleLine();
                EditorGUI.BeginChangeCheck();
                materialEditor.TexturePropertyMiniThumbnail(r, _OcclusionMap, Styles.occlusion.text, Styles.occlusion.tooltip);
                if (EditorGUI.EndChangeCheck())
                {
                    gui.RegenerateMSOT(false);
                }
                TSFunctions.ProperSlider(MaterialEditor.GetRectAfterLabelWidth(r), ref _Occlusion);
            }
            else
            {
                materialEditor.ShaderProperty(_Occlusion, Styles.occlusion);
            }

            //emission
            EditorGUI.BeginChangeCheck();
            if (materialEditor.EmissionEnabledProperty())
            {
                materialEditor.TexturePropertySingleLine(Styles.emission, _Emission, _EmissionColor);
                materialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel);
            }
            if (EditorGUI.EndChangeCheck())
            {
                foreach (Material mat in _Emission.targets)
                {
                    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");
                    }
                }
            }
            //if in expert mode show the MSOT map and a button for the texture packer
            if (level == InspectorLevel.Expert)
            {
                EditorGUILayout.BeginHorizontal();
                materialEditor.TexturePropertySingleLine(Styles.MSOT, _MSOT);
                if (GUILayout.Button(Styles.TexturePackerButton))
                {
                    EditorGUILayout.EndHorizontal();
                    isTexturePackerOpen = !isTexturePackerOpen;
                    Styles.ToggleTexturePackerContent(isTexturePackerOpen);
                }
                else
                {
                    EditorGUILayout.EndHorizontal();
                }

                if (isTexturePackerOpen)
                {
                    EditorGUILayout.BeginVertical("box");
                    packer.DrawGUI();
                    EditorGUILayout.EndVertical();
                    if (_MSOT.textureValue != (Texture)packer.resultTex && packer.resultTex != null)
                    {
                        _MSOT.textureValue = packer.resultTex;
                        packer.resultTex   = null;
                    }
                }
            }
            EditorGUILayout.Space();
            materialEditor.TextureScaleOffsetProperty(_MainTex);
            //EditorGUILayout.Space();
            //materialEditor.RenderQueueField();

            EditorGUILayout.Space();
        }
Exemple #15
0
        /// <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;
            }
        }
Exemple #16
0
        /// <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();
        }
Exemple #17
0
        /// <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));
            }
        }