コード例 #1
0
    void DrawBaseInfo()
    {
        baseDrawInfo.value = EditorGUILayout.BeginFoldoutHeaderGroup(baseDrawInfo.value, new GUIContent("Base Info"));
        if (baseDrawInfo.value)
        {
            EditorGUI.BeginChangeCheck();
            bool closeLightGI = material.IsKeywordEnabled("LIGHT_MIX_GI_OFF");
            bool recvFogInfo  = material.IsKeywordEnabled("USED_FOG");
            materialEditor.TexturePropertySingleLine(new GUIContent("Control(RGBA)"), FindProperty("_Control"));
            recvFogInfo = EditorGUILayout.Toggle(new GUIContent("Fog"), recvFogInfo);
            if (recvFogInfo)
            {
                EditorGUI.indentLevel++;
                materialEditor.RangeProperty(FindProperty("_FogScale"), "fog scale");
                EditorGUI.indentLevel--;
            }
            closeLightGI = EditorGUILayout.Toggle(new GUIContent("close light gi"), closeLightGI);

            var prop = FindProperty("_SpecType");
            IBaseShaderGUI.DoPopup(new GUIContent("Specular Type"), prop, Enum.GetNames(typeof(IBaseShaderGUI.SpecularType)), materialEditor);
            if (EditorGUI.EndChangeCheck())
            {
                SetKeyWordState("USED_FOG", recvFogInfo);
                SetKeyWordState("LIGHT_MIX_GI_OFF", closeLightGI);
                var specType = (IBaseShaderGUI.SpecularType)(int) prop.floatValue;

                SetKeyWordState("SPECULAR_ADD", specType == IBaseShaderGUI.SpecularType.Additional);
                SetKeyWordState("SPECULAR_DEFAULT", specType == IBaseShaderGUI.SpecularType.Default);
                SetKeyWordState("SPECULAR_OFF", specType == IBaseShaderGUI.SpecularType.CloseSpecular);
            }
        }
        EditorGUILayout.EndFoldoutHeaderGroup();
    }
コード例 #2
0
ファイル: SSSSLightingGUI.cs プロジェクト: JiangXJ1/LWRP
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        if (isFirstOpen)
        {
            InitProperties(materialEditor, properties);
        }
        EditorGUI.BeginChangeCheck();
        materialEditor.TexturePropertySingleLine(new GUIContent("基础贴图"), FindProperty("_BaseMap"), FindProperty("_BaseColor"));
        materialEditor.TexturePropertySingleLine(new GUIContent("法线贴图"), FindProperty("_BumpMap"), FindProperty("_BumpScale"));
        materialEditor.TexturePropertySingleLine(new GUIContent("控制图", "(r 曲率 g 高光图)"), FindProperty("_FinalMap"));

        materialEditor.TexturePropertySingleLine(new GUIContent("SSSLUT", "控制Diffuse颜色"), FindProperty("_SSSLUTMap"));
        var specTypeProp = FindProperty("_SpecularType");

        IBaseShaderGUI.DoPopup(new GUIContent("SpecularType"), specTypeProp, Enum.GetNames(typeof(IBaseShaderGUI.SpecularType)), materialEditor);
        var specType = (IBaseShaderGUI.SpecularType)(int) specTypeProp.floatValue;

        if (specType != IBaseShaderGUI.SpecularType.CloseSpecular)
        {
            EditorGUI.indentLevel++;
            materialEditor.TexturePropertySingleLine(new GUIContent("KelementLUT", "控制Specular颜色"), FindProperty("_KelementLUTMap"), FindProperty("_SpecularColor"));
            materialEditor.RangeProperty(FindProperty("_SpecularScale"), "高光缩放");
            EditorGUI.indentLevel--;
        }

        bool recvShadow = material.IsKeywordEnabled("RECEIVE_SHADOWS");

        recvShadow = EditorGUILayout.Toggle(new GUIContent("接收阴影"), recvShadow);

        bool closeMixGI = material.IsKeywordEnabled("LIGHT_MIX_GI_OFF");

        closeMixGI = EditorGUILayout.Toggle(new GUIContent("close light gi"), closeMixGI);

        bool hasFog = material.IsKeywordEnabled("USED_FOG");

        hasFog = EditorGUILayout.Toggle(new GUIContent("开启雾效"), hasFog);
        if (hasFog)
        {
            EditorGUI.indentLevel++;
            materialEditor.RangeProperty(FindProperty("_FogScale"), "雾效缩放");
            EditorGUI.indentLevel--;
        }
        if (EditorGUI.EndChangeCheck())
        {
            SetKeyWordState("USED_FOG", hasFog);
            SetKeyWordState("RECEIVE_SHADOWS", recvShadow);
            SetKeyWordState("LIGHT_MIX_GI_OFF", closeMixGI);
            SetKeyWordState("SPECULAR_ADD", specType == IBaseShaderGUI.SpecularType.Additional);
            SetKeyWordState("SPECULAR_DEFAULT", specType == IBaseShaderGUI.SpecularType.Default);
            SetKeyWordState("SPECULAR_OFF", specType == IBaseShaderGUI.SpecularType.CloseSpecular);
        }
    }