示例#1
0
 private void ColorModePopup()
 {
     if (this.colorMode != null)
     {
         EditorGUI.showMixedValue = this.colorMode.hasMixedValue;
         StandardParticlesShaderGUI.ColorMode colorMode = (StandardParticlesShaderGUI.ColorMode) this.colorMode.floatValue;
         EditorGUI.BeginChangeCheck();
         colorMode = (StandardParticlesShaderGUI.ColorMode)EditorGUILayout.Popup(StandardParticlesShaderGUI.Styles.colorMode, (int)colorMode, StandardParticlesShaderGUI.Styles.colorNames, new GUILayoutOption[0]);
         if (EditorGUI.EndChangeCheck())
         {
             this.m_MaterialEditor.RegisterPropertyChangeUndo("Color Mode");
             this.colorMode.floatValue = (float)colorMode;
         }
         EditorGUI.showMixedValue = false;
     }
 }
示例#2
0
        public static void SetupMaterialWithColorMode(Material material, StandardParticlesShaderGUI.ColorMode colorMode)
        {
            switch (colorMode)
            {
            case StandardParticlesShaderGUI.ColorMode.Multiply:
                material.DisableKeyword("_COLOROVERLAY_ON");
                material.DisableKeyword("_COLORCOLOR_ON");
                material.DisableKeyword("_COLORADDSUBDIFF_ON");
                break;

            case StandardParticlesShaderGUI.ColorMode.Additive:
                material.DisableKeyword("_COLOROVERLAY_ON");
                material.DisableKeyword("_COLORCOLOR_ON");
                material.EnableKeyword("_COLORADDSUBDIFF_ON");
                material.SetVector("_ColorAddSubDiff", new Vector4(1f, 0f, 0f, 0f));
                break;

            case StandardParticlesShaderGUI.ColorMode.Subtractive:
                material.DisableKeyword("_COLOROVERLAY_ON");
                material.DisableKeyword("_COLORCOLOR_ON");
                material.EnableKeyword("_COLORADDSUBDIFF_ON");
                material.SetVector("_ColorAddSubDiff", new Vector4(-1f, 0f, 0f, 0f));
                break;

            case StandardParticlesShaderGUI.ColorMode.Overlay:
                material.DisableKeyword("_COLORCOLOR_ON");
                material.DisableKeyword("_COLORADDSUBDIFF_ON");
                material.EnableKeyword("_COLOROVERLAY_ON");
                break;

            case StandardParticlesShaderGUI.ColorMode.Color:
                material.DisableKeyword("_COLOROVERLAY_ON");
                material.DisableKeyword("_COLORADDSUBDIFF_ON");
                material.EnableKeyword("_COLORCOLOR_ON");
                break;

            case StandardParticlesShaderGUI.ColorMode.Difference:
                material.DisableKeyword("_COLOROVERLAY_ON");
                material.DisableKeyword("_COLORCOLOR_ON");
                material.EnableKeyword("_COLORADDSUBDIFF_ON");
                material.SetVector("_ColorAddSubDiff", new Vector4(-1f, 1f, 0f, 0f));
                break;
            }
        }