예제 #1
0
 public override void OnAdd()
 {
     foreach (Material mat in _OutlineOn.targets)
     {
         ToonyStandardGUI.SetupMaterialWithBlendMode(mat, (ToonyStandardGUI.BlendMode)mat.GetFloat("_Mode"), mat.GetFloat("_OutlineOn") > 0);
     }
 }
예제 #2
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();
        }
예제 #3
0
 public override void EndBoxCheck(bool isOpen, bool isEnabled)
 {
     _OutlineBox.floatValue = TSFunctions.floatBoolean(isOpen);
     if (!isEnabled)
     {
         if (!_OutlineOn.hasMixedValue)
         {
             _OutlineOn.floatValue = 0;
             foreach (Material mat in _OutlineOn.targets)
             {
                 ToonyStandardGUI.SetupMaterialWithBlendMode(mat, (ToonyStandardGUI.BlendMode)mat.GetFloat("_Mode"), mat.GetFloat("_OutlineOn") > 0);
             }
         }
     }
 }
예제 #4
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();
        }