private void ColorRamp(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("8.Color Ramp", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("COLORRAMP_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[51], properties[51].displayName);
                materialEditor.ShaderProperty(properties[52], properties[52].displayName);
                materialEditor.ShaderProperty(properties[53], properties[53].displayName);
                MaterialProperty colorRampOut = ShaderGUI.FindProperty("_ColorRampOutline", properties);
                if (colorRampOut.floatValue == 1)
                {
                    targetMat.EnableKeyword("COLORRAMPOUTLINE_ON");
                }
                else
                {
                    targetMat.DisableKeyword("COLORRAMPOUTLINE_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("COLORRAMP_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void GreyScale(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("12.Greyscale", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("GREYSCALE_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[54], properties[54].displayName);
                materialEditor.ShaderProperty(properties[55], properties[55].displayName);
                materialEditor.ShaderProperty(properties[56], properties[56].displayName);
                MaterialProperty greyScaleOut = ShaderGUI.FindProperty("_GreyscaleOutline", properties);
                if (greyScaleOut.floatValue == 1)
                {
                    targetMat.EnableKeyword("GREYSCALEOUTLINE_ON");
                }
                else
                {
                    targetMat.DisableKeyword("GREYSCALEOUTLINE_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("GREYSCALE_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Posterize(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("13.Posterize", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("POSTERIZE_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[57], properties[57].displayName);
                materialEditor.ShaderProperty(properties[58], properties[58].displayName);
                materialEditor.ShaderProperty(properties[59], properties[59].displayName);
                MaterialProperty posterizeOut = ShaderGUI.FindProperty("_PosterizeOutline", properties);
                if (posterizeOut.floatValue == 1)
                {
                    targetMat.EnableKeyword("POSTERIZEOUTLINE_ON");
                }
                else
                {
                    targetMat.DisableKeyword("POSTERIZEOUTLINE_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("POSTERIZE_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Blur(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("14.Blur", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("BLUR_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[60], properties[60].displayName);
                materialEditor.ShaderProperty(properties[61], properties[61].displayName);
                MaterialProperty blurIsHd = ShaderGUI.FindProperty("_BlurHD", properties);
                if (blurIsHd.floatValue == 1)
                {
                    targetMat.EnableKeyword("BLURISHD_ON");
                }
                else
                {
                    targetMat.DisableKeyword("BLURISHD_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("BLUR_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void ZTest(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle, string inspector, string flag)
    {
        MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", properties);

        if (zTestM.floatValue == 0)
        {
            zTestM.floatValue = 4;
        }
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(flag);
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Look for 'ShaderLab culling and depth testing' if you don't know what this is", style);
                zTestMode         = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
                zTestMode         = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("zTestMode", zTestMode);
                zTestM.floatValue = (float)(zTestMode);
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(flag);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void ZWrite(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, string inspector)
    {
        MaterialProperty zWrite = ShaderGUI.FindProperty("_ZWrite", properties);
        bool             toggle = zWrite.floatValue > 0.9f ? true : false;
        bool             ini    = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Usually used to sort Billboarded sprites", style);
                GUILayout.Label("Use effect instead 23.Alpha Cutoff for more optimum results", style);
                zWrite.floatValue = 1.0f;
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            zWrite.floatValue = 0.0f;
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void Billboard(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle, string inspector, string flag)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(flag);
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Don't use this feature on UI elements!", style);
                materialEditor.ShaderProperty(properties[129], properties[129].displayName);
                MaterialProperty billboardY = ShaderGUI.FindProperty("_BillboardY", properties);
                if (billboardY.floatValue == 1)
                {
                    targetMat.EnableKeyword("BILBOARDY_ON");
                }
                else
                {
                    targetMat.DisableKeyword("BILBOARDY_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(flag);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void ZTest(string inspector, string keyword)
    {
        bool             toggle = oldKeyWords.Contains(keyword);
        MaterialProperty zTestM = ShaderGUI.FindProperty("_ZTestMode", matProperties);

        if (zTestM.floatValue == 0)
        {
            zTestM.floatValue = 4;
        }
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(keyword);
            EditorGUILayout.BeginVertical(style);
            {
                GUILayout.Label("Look for 'ShaderLab culling and depth testing' \nif you don't know what this is", smallLabelStyle);
                zTestMode         = (CompareFunction)zTestM.floatValue;
                zTestMode         = (CompareFunction)EditorGUILayout.EnumPopup("zTestMode", zTestMode);
                zTestM.floatValue = (float)(zTestMode);
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(keyword);
        }
        EditorGUILayout.EndToggleGroup();
    }
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty [] properties)
    {
        MaterialProperty outlineColor = ShaderGUI.FindProperty("_OutlineColor", properties);

        materialEditor.ShaderProperty(outlineColor, outlineColor.displayName);
        base.OnGUI(materialEditor, properties);
    }
示例#10
0
        public void FindProperties(MaterialProperty[] props)
        {
            this._MainTex     = ShaderGUI.FindProperty("_MainTex", props);
            this._BumpMap     = ShaderGUI.FindProperty("_BumpMap", props);
            this._ParallaxMap = ShaderGUI.FindProperty("_ParallaxMap", props);

            this._Tessellation = ShaderGUI.FindProperty("_Tessellation", props);
        }
示例#11
0
    void ShowMain()
    {
        var prop  = ShaderGUI.FindProperty("_MainTex", properties);
        var prop2 = ShaderGUI.FindProperty("_Color", properties);

        this.editor.TexturePropertySingleLine(MakeLabel(prop), prop, prop2);
        GUILayout.Space(15);
    }
示例#12
0
        private MaterialProperty BeginProperty(string name)
        {
            MaterialProperty materialProperty = ShaderGUI.FindProperty(name, properties);

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = materialProperty.hasMixedValue;
            editor.BeginAnimatedCheck(materialProperty);
            return(materialProperty);
        }
示例#13
0
    protected Vector4 ShowVector4(string name)
    {
        var property = ShaderGUI.FindProperty(name, properties);
        var res      = target.GetVector(name);
        var val      = EditorGUILayout.Vector4Field(property.displayName, res);

        target.SetVector(name, val);
        return(res);
    }
            public override void OnFindProperty(MaterialProperty[] props)
            {
                base.OnFindProperty(props);

                if (!string.IsNullOrEmpty(ExtraPropertyName))
                {
                    m_ExtraProperty = ShaderGUI.FindProperty(ExtraPropertyName, props, IsMandatory);
                }
            }
示例#15
0
    void ShowSoftParticle()
    {
        var _UseSoftParticle = ShaderGUI.FindProperty("_UseSoftParticle", properties);

        editor.ShaderProperty(_UseSoftParticle, _UseSoftParticle.displayName);
        if (FloatEqual(_UseSoftParticle.floatValue, 1))
        {
            ShowPropertys("_InvFade");
        }
    }
示例#16
0
    private void ShowSoftParticle()
    {
        var _UseSoftParticle = ShaderGUI.FindProperty("_UseSoftParticle", this._properties);

        this._editor.ShaderProperty(_UseSoftParticle, _UseSoftParticle.displayName);
        if (_UseSoftParticle.floatValue > 0.5f)
        {
            ShowPropertys("_InvFade");
        }
    }
示例#17
0
    override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        Material         material;
        MaterialProperty _DeepWaterColor;
        MaterialProperty _ShorelineColor;
        MaterialProperty _ShorelineDepth;
        MaterialProperty _WaterSpeed;
        MaterialProperty _WavesIntensity;
        MaterialProperty _WavesDensity;
        MaterialProperty _LightRamp;
        MaterialProperty _shallowWaterColor;
        MaterialProperty _TessellationValue;
        MaterialProperty _UseTessellation;
        MaterialProperty _Foam;
        MaterialProperty _FoamScale;

        material = materialEditor.target as Material;

        _DeepWaterColor    = ShaderGUI.FindProperty("_DeepWaterColor", properties);
        _ShorelineColor    = ShaderGUI.FindProperty("_ShorelineColor", properties);
        _ShorelineDepth    = ShaderGUI.FindProperty("_ShorelineDepth", properties);
        _WaterSpeed        = ShaderGUI.FindProperty("_WaterSpeed", properties);
        _WavesIntensity    = ShaderGUI.FindProperty("_WavesIntensity", properties);
        _WavesDensity      = ShaderGUI.FindProperty("_WavesDensity", properties);
        _LightRamp         = ShaderGUI.FindProperty("_LightRamp", properties);
        _shallowWaterColor = ShaderGUI.FindProperty("_shallowWaterColor", properties);
        _TessellationValue = ShaderGUI.FindProperty("_TessellationValue", properties);
        _UseTessellation   = ShaderGUI.FindProperty("_UseTessellation", properties);
        _Foam      = ShaderGUI.FindProperty("_Foam", properties);
        _FoamScale = ShaderGUI.FindProperty("_FoamScale", properties);
        //__________________________________________________________________________________
        EditorGUILayout.Space();
        materialEditor.TexturePropertySingleLine(new GUIContent("Light Ramp", ""), _LightRamp);
        materialEditor.TexturePropertySingleLine(new GUIContent("Foam", ""), _Foam, _FoamScale);
        //__________________________________________________________________________________
        EditorGUILayout.Space();
        materialEditor.ShaderProperty(_ShorelineDepth, _ShorelineDepth.displayName);
        //__________________________________________________________________________________
        EditorGUILayout.Space();
        materialEditor.ShaderProperty(_ShorelineColor, _ShorelineColor.displayName);
        materialEditor.ShaderProperty(_DeepWaterColor, _DeepWaterColor.displayName);
        materialEditor.ShaderProperty(_shallowWaterColor, _shallowWaterColor.displayName);
        //__________________________________________________________________________________
        EditorGUILayout.Space();
        materialEditor.ShaderProperty(_WaterSpeed, _WaterSpeed.displayName);
        materialEditor.ShaderProperty(_WavesDensity, _WavesDensity.displayName);
        materialEditor.ShaderProperty(_WavesIntensity, _WavesIntensity.displayName);
        //__________________________________________________________________________________
        EditorGUILayout.Space();
        materialEditor.ShaderProperty(_UseTessellation, _UseTessellation.displayName);
        if (_UseTessellation.floatValue == 1)
        {
            materialEditor.ShaderProperty(_TessellationValue, _TessellationValue.displayName);
        }
    }
示例#18
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        //Style similar to Standard shader
        this.m_MaterialEditor = materialEditor;
        m_MaterialEditor.SetDefaultGUIWidths();
        m_MaterialEditor.UseDefaultMargins();
        EditorGUIUtility.labelWidth = 0f;

        //Load Properties

        diff            = ShaderGUI.FindProperty("_Diffuse", properties);
        normal          = ShaderGUI.FindProperty("_Normal", properties);
        HoloMask        = ShaderGUI.FindProperty("_HoloMask", properties);
        tint            = ShaderGUI.FindProperty("_Tint", properties);
        ScanlinesToggle = ShaderGUI.FindProperty("_UseScreenSpaceScanlines", properties);
        SSSsize         = ShaderGUI.FindProperty("_SSSsize", properties);
        OSSsize         = ShaderGUI.FindProperty("_OSSsize", properties);
        BigScanFreq     = ShaderGUI.FindProperty("_BigScanFreq", properties);
        BigScanSpeed    = ShaderGUI.FindProperty("_BigScanSpeed", properties);

        Bias  = ShaderGUI.FindProperty("_Bias", properties);
        Scale = ShaderGUI.FindProperty("_Scale", properties);
        Power = ShaderGUI.FindProperty("_Power", properties);

        NoiseValue           = ShaderGUI.FindProperty("_RandomNoiseLevel", properties);
        GlitchToggle         = ShaderGUI.FindProperty("_ToggleGlitch", properties);
        ScanlineDeformToggle = ShaderGUI.FindProperty("_ToggleScanlineDeform", properties);
        DisplacementeToggle  = ShaderGUI.FindProperty("_DisplacementSwitch", properties);



        //Draw Gui
        HeaderGUI();
        GUILayout.Label("Main Textures", EditorStyles.boldLabel);
        GUILayout.Label("Albedo : Diffuse (RGB) and alpha (A)");
        GUIContent diffuseLabel = new GUIContent("", "Diffuse (RGB) and alpha (A)");
        GUIContent tintlabel    = new GUIContent("Tint", "Hologram color");

        //m_MaterialEditor.TexturePropertySingleLine(diffuseLabel, diff);
        m_MaterialEditor.ShaderProperty(diff, diffuseLabel);
        m_MaterialEditor.ShaderProperty(tint, tintlabel);

        GUILayout.Label("Normal");
        GUIContent normalLabel = new GUIContent("");

        m_MaterialEditor.ShaderProperty(normal, normalLabel);

        GUIContent ScanlinesLabel = new GUIContent("Scanlines texture");

        m_MaterialEditor.ShaderProperty(HoloMask, ScanlinesLabel);

        ScanlinesGUI();
        FresnelGUI();
        NoiseGUI();
    }
        private void ShowRenderMode()
        {
            ShowPropertys("_CullMode");
            var _BlendMode = ShaderGUI.FindProperty("_BlendMode", base._Properties);

            this._Editor.ShaderProperty(_BlendMode, _BlendMode.displayName);

            var blendMode = (BlendMode)Mathf.RoundToInt(_BlendMode.floatValue);

            SetupMaterialWithBlendMode(base._Target, blendMode, base._LastBlendMode != -1 && base._LastBlendMode != (int)blendMode);
            base._LastBlendMode = (int)blendMode;
        }
示例#20
0
    void ShowRenderMode()
    {
        ShowPropertys("_CullMode");
        var _BlendMode = ShaderGUI.FindProperty("_BlendMode", properties);

        editor.ShaderProperty(_BlendMode, _BlendMode.displayName);

        var blendMode = (BlendMode)Mathf.RoundToInt(_BlendMode.floatValue);

        SetupMaterialWithBlendMode(target, blendMode, lastBlendMode != -1 && lastBlendMode != (int)blendMode);
        lastBlendMode = (int)blendMode;
    }
示例#21
0
    public override void OnGUI(MaterialEditor m_MaterialEditor, MaterialProperty[] props)
    {
        Material material = m_MaterialEditor.target as Material;

        {
            //Find all the properties within the shader
            // = ShaderGUI.FindProperty("", props);
            _MainTex               = ShaderGUI.FindProperty("_MainTex", props);
            _RGBSubPixelTex        = ShaderGUI.FindProperty("_RGBSubPixelTex", props);
            _shiftColor            = ShaderGUI.FindProperty("_shiftColor", props);
            _EmissionIntensity     = ShaderGUI.FindProperty("_EmissionIntensity", props);
            _Glossiness            = ShaderGUI.FindProperty("_Glossiness", props);
            _ApplyGamma            = ShaderGUI.FindProperty("_ApplyGamma", props);
            _LightmapEmissionScale = ShaderGUI.FindProperty("_LightmapEmissionScale", props);
            _Saturation            = ShaderGUI.FindProperty("_Saturation", props);
            _Contrast              = ShaderGUI.FindProperty("_Contrast", props);
            _RedScale              = ShaderGUI.FindProperty("_RedScale", props);
            _GreenScale            = ShaderGUI.FindProperty("_GreenScale", props);
            _BlueScale             = ShaderGUI.FindProperty("_BlueScale", props);
            _Backlight             = ShaderGUI.FindProperty("_Backlight", props);
            _EmissionIntensity2    = ShaderGUI.FindProperty("_EmissionIntensity2", props);
        }

        EditorGUI.BeginChangeCheck();
        {
            //display all the settings
            m_MaterialEditor.TexturePropertySingleLine(Styles.mainTex, _MainTex);
            m_MaterialEditor.ShaderProperty(_shiftColor, "Shift Color", 2);
            m_MaterialEditor.ShaderProperty(_Glossiness, "Smoothness", 2);
            m_MaterialEditor.ShaderProperty(_EmissionIntensity, "Emission Scale", 2);
            m_MaterialEditor.ShaderProperty(_LightmapEmissionScale, "Lightmap Emission Scale", 2);
            // change the GI flag and fix it up with emissive as black if necessary
            m_MaterialEditor.LightmapEmissionFlagsProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel, true);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            m_MaterialEditor.TexturePropertySingleLine(Styles.RGBMatrixTex, _RGBSubPixelTex);
            m_MaterialEditor.ShaderProperty(_Backlight, "Backlit Panel(LCD)");
            m_MaterialEditor.TextureScaleOffsetProperty(_RGBSubPixelTex);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            m_MaterialEditor.ShaderProperty(_Saturation, "Saturation");
            m_MaterialEditor.ShaderProperty(_Contrast, "Contrast");
            m_MaterialEditor.ShaderProperty(_RedScale, "Red Scale");
            m_MaterialEditor.ShaderProperty(_GreenScale, "Green Scale");
            m_MaterialEditor.ShaderProperty(_BlueScale, "Blue Scale");
            m_MaterialEditor.ShaderProperty(_ApplyGamma, "Apply Gamma Fix");
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            //hacks
            m_MaterialEditor.ShaderProperty(_EmissionIntensity2, "Emission Hack");
        }
        DoFooter();
    }
示例#22
0
    private void Culling()
    {
        MaterialProperty cullO     = ShaderGUI.FindProperty("_CullingOption", matProperties);;
        float            tempValue = cullO.floatValue;

        cullMode         = (UnityEngine.Rendering.CullMode)cullO.floatValue;
        cullMode         = (UnityEngine.Rendering.CullMode)EditorGUILayout.EnumPopup("Culling Mode", cullMode);
        cullO.floatValue = (float)(cullMode);
        if (tempValue != cullO.floatValue && !Application.isPlaying)
        {
            Save();
        }
    }
示例#23
0
    private void ZTest()
    {
        MaterialProperty zTestM    = ShaderGUI.FindProperty("_ZTestMode", matProperties);
        float            tempValue = zTestM.floatValue;

        zTestMode         = (UnityEngine.Rendering.CompareFunction)zTestM.floatValue;
        zTestMode         = (UnityEngine.Rendering.CompareFunction)EditorGUILayout.EnumPopup("Z TestMode", zTestMode);
        zTestM.floatValue = (float)(zTestMode);
        if (tempValue != zTestM.floatValue && !Application.isPlaying)
        {
            Save();
        }
    }
示例#24
0
    private void ShowRenderMode()
    {
        ShowPropertys("_CullMode");
        var _BlendMode = ShaderGUI.FindProperty("_BlendMode", this._properties);

        this._editor.ShaderProperty(_BlendMode, _BlendMode.displayName);

        var blendMode = (BlendMode)Mathf.RoundToInt(_BlendMode.floatValue);

        SetupMaterialWithBlendMode(this._target, blendMode, this._lastBlendMode != -1 && this._lastBlendMode != (int)blendMode);
        this._lastBlendMode = (int)blendMode;
        this._editor.RenderQueueField();
    }
示例#25
0
    private void CheckFeature(Material targetMat, MaterialProperty[] materialProperties, string toggleName, string featureName, string[] properties, HashSet <string> disabledProperties)
    {
        bool isEnabled = Array.IndexOf(targetMat.shaderKeywords, featureName) != -1;

        MaterialProperty toggle = ShaderGUI.FindProperty(toggleName, materialProperties);

        if (toggle.floatValue == 0 && isEnabled == false)
        {
            foreach (string name in properties)
            {
                disabledProperties.Add(name);
            }
        }
    }
示例#26
0
    protected override void FindProperties(MaterialProperty[] props)
    {
        this.splat0  = ShaderGUI.FindProperty("_Splat0", props);
        this.splat1  = ShaderGUI.FindProperty("_Splat1", props);
        this.control = ShaderGUI.FindProperty("_Control", props);

        this.specularPower     = ShaderGUI.FindProperty("_SpecularPower", props);
        this.specularIntensity = ShaderGUI.FindProperty("_SpecularIntensity", props);
        this.specularColor     = ShaderGUI.FindProperty("_SpecularColor", props);

        this.reflectionOpacity   = ShaderGUI.FindProperty("_ReflectionOpacity", props);
        this.reflectionIntensity = ShaderGUI.FindProperty("_ReflectionIntensity", props);
        this.reflectionFresnel   = ShaderGUI.FindProperty("_ReflectionFresnel", props);
        this.reflectionMetallic  = ShaderGUI.FindProperty("_ReflectionMetallic", props);
    }
    private void Gradient(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle, string inspector, string flag, int first, int last)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup(inspector, toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword(flag);

            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[143], properties[143].displayName);
                MaterialProperty outlineDistort = ShaderGUI.FindProperty("_GradIsRadial", properties);
                if (outlineDistort.floatValue == 1)
                {
                    targetMat.EnableKeyword("RADIALGRADIENT_ON");
                    materialEditor.ShaderProperty(properties[31], properties[31].displayName);
                    materialEditor.ShaderProperty(properties[32], properties[32].displayName);
                    materialEditor.ShaderProperty(properties[34], properties[34].displayName);
                    materialEditor.ShaderProperty(properties[141], properties[141].displayName);
                }
                else
                {
                    targetMat.DisableKeyword("RADIALGRADIENT_ON");
                    if (first > 0)
                    {
                        for (int i = first; i <= last; i++)
                        {
                            materialEditor.ShaderProperty(properties[i], properties[i].displayName);
                        }
                        materialEditor.ShaderProperty(properties[141], properties[141].displayName);
                        materialEditor.ShaderProperty(properties[142], properties[142].displayName);
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword(flag);
        }
        EditorGUILayout.EndToggleGroup();
    }
    private void NormalMapping(MaterialEditor materialEditor, MaterialProperty[] properties, GUIStyle style, bool toggle)
    {
        bool ini = toggle;

        toggle = EditorGUILayout.BeginToggleGroup("2.Normal Mapping", toggle);
        if (ini != toggle && !Application.isPlaying)
        {
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
        if (toggle)
        {
            targetMat.EnableKeyword("NORMALMAP_ON");
            EditorGUILayout.BeginVertical(style);
            {
                materialEditor.ShaderProperty(properties[5], properties[5].displayName);
                materialEditor.ShaderProperty(properties[6], properties[6].displayName);

                materialEditor.ShaderProperty(properties[7], properties[7].displayName);
                MaterialProperty flipX = ShaderGUI.FindProperty("_NormalFlipX", properties);
                if (flipX.floatValue == 1)
                {
                    targetMat.EnableKeyword("NORMALMAPFLIPX_ON");
                }
                else
                {
                    targetMat.DisableKeyword("NORMALMAPFLIPX_ON");
                }

                materialEditor.ShaderProperty(properties[8], properties[8].displayName);
                MaterialProperty flipY = ShaderGUI.FindProperty("_NormalFlipY", properties);
                if (flipY.floatValue == 1)
                {
                    targetMat.EnableKeyword("NORMALMAPFLIPY_ON");
                }
                else
                {
                    targetMat.DisableKeyword("NORMALMAPFLIPY_ON");
                }
            }
            EditorGUILayout.EndVertical();
        }
        else
        {
            targetMat.DisableKeyword("NORMALMAP_ON");
        }
        EditorGUILayout.EndToggleGroup();
    }
示例#29
0
    private void SetAndSaveEnabledDrawers(uint iniDrawers)
    {
        uint currDrawers = 0;

        for (int i = 0; i < currEnabledDrawers.Length; i++)
        {
            if (currEnabledDrawers[i])
            {
                currDrawers |= materialDrawers[i];
            }
        }

        if (iniDrawers != currDrawers)
        {
            ShaderGUI.FindProperty("_EditorDrawers", matProperties).floatValue = currDrawers;
        }
    }
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        base.OnGUI(materialEditor, properties); // 显示默认面板

        Material targetMat = materialEditor.target as Material;

        // test1, shader 中增加一个 Toggle, 来决定编辑器是否显示 _Color2 属性
        MaterialProperty _UseTwoColors = ShaderGUI.FindProperty("_UseTwoColors", properties);

        if (_UseTwoColors.floatValue == 1)
        {
            MaterialProperty _Color2 = ShaderGUI.FindProperty("_Color2", properties);
            materialEditor.ShaderProperty(_Color2, _Color2.displayName);
        }

        // test2, 检测贴图是否有被用到, 来决定是否启用 _BLENDMAP 宏
        MaterialProperty blendMap     = ShaderGUI.FindProperty("_BlendTex", properties);
        bool             blendEnabled = blendMap.textureValue != null;

        if (blendEnabled)
        {
            targetMat.EnableKeyword("_BLENDMAP");
        }
        else
        {
            targetMat.DisableKeyword("_BLENDMAP");
        }

        // test3, 编辑器扩展一个 Toggle, 来决定是否启用 CS_BOOL 宏
        bool CS_BOOL = Array.IndexOf(targetMat.shaderKeywords, "CS_BOOL") != -1;

        EditorGUI.BeginChangeCheck();
        CS_BOOL = EditorGUILayout.Toggle("CS_BOOL", CS_BOOL);

        if (EditorGUI.EndChangeCheck())
        {
            if (CS_BOOL)
            {
                targetMat.EnableKeyword("CS_BOOL");
            }
            else
            {
                targetMat.DisableKeyword("CS_BOOL");
            }
        }
    }