Exemple #1
0
 public static bool BeginFolderGroup(string name, ref bool folder)
 {
     folder = EditorGUILayout.Foldout(folder, name);
     if (folder)
     {
         ToolsUtility.BeginGroup("");
     }
     return(folder);
 }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();

            Environment env = target as Environment;

            textureFolder = EditorGUILayout.Foldout(textureFolder, "Texture");
            if (textureFolder)
            {
                EditorGUILayout.PropertyField(envCube);
                EditorGUILayout.PropertyField(skyMat);
                if (m_Target.envCube != null)
                {
                    Cubemap cube = m_Target.envCube;
                    int     max  = cube.mipmapCount;
                    m_Target.iblLevel = EditorGUILayout.IntSlider("IBL Level", m_Target.iblLevel, 1, max);
                }
            }
            envLighingFolder = EditorGUILayout.Foldout(envLighingFolder, "EnvLighting");
            if (envLighingFolder)
            {
                EditorGUILayout.PropertyField(hdrScale);
                EditorGUILayout.PropertyField(hdrPow);
                EditorGUILayout.PropertyField(hdrAlpha);
                PropertyField(lightmapShadowMask);
                PropertyField(shadowIntensity);
            }
            fogFolder = EditorGUILayout.Foldout(fogFolder, "Fog");
            if (fogFolder)
            {
                EditorGUILayout.PropertyField(fogEnable);

                if (fogEnable.boolValue)
                {
                    FogModify fogParam = env.fog;
                    EditorGUI.BeginChangeCheck();
                    var fogDensity = EditorGUILayout.Slider("Fog Density", fogParam.Density, 0.0f, 1f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog Density");
                        fogParam.Density = fogDensity;
                    }

                    EditorGUI.BeginChangeCheck();
                    var FogMoveSpeed = EditorGUILayout.Slider("Fog Skybox Height", fogParam.SkyboxHeight, 0.0f, 10.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog Scale");
                        fogParam.SkyboxHeight = FogMoveSpeed;
                    }

                    EditorGUI.BeginChangeCheck();
                    var fogEndHeight = EditorGUILayout.Slider("Fog End Height", fogParam.EndHeight, 0.0f, 1000.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog End Height");
                        fogParam.EndHeight = fogEndHeight;
                    }

                    EditorGUI.BeginChangeCheck();
                    var fogStartDistance = EditorGUILayout.Slider("Fog StartDistance", fogParam.StartDistance, 0.0f, 200.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog StartDistance");
                        fogParam.StartDistance = fogStartDistance;
                    }

                    EditorGUI.BeginChangeCheck();
                    var fogColor0 = EditorGUILayout.ColorField("Fog Color 0", fogParam.Color0);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog Color 0");
                        fogParam.Color0 = fogColor0;
                    }
                    EditorGUI.BeginChangeCheck();
                    var fogColor1 = EditorGUILayout.ColorField("Fog Color 1", fogParam.Color1);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog Color 1");
                        fogParam.Color1 = fogColor1;
                    }
                    EditorGUI.BeginChangeCheck();
                    var fogColor2 = EditorGUILayout.ColorField("Fog Color 2", fogParam.Color2);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "Fog Color 2");
                        fogParam.Color2 = fogColor2;
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                if (env != null)
                {
                    env.enabled = false;
                    env.enabled = true;
                }
            }
            serializedObject.ApplyModifiedProperties();

            env.lightingFolder = EditorGUILayout.Foldout(env.lightingFolder, "Lighting");
            if (env.lightingFolder)
            {
                ToolsUtility.BeginGroup("RoleLight");
                LightInstpetorGui(roleLight0, env.roleLight0Rot, "RoleLight0");
                LightInstpetorGui(roleLight1, env.roleLight1Rot, "RoleLight1");
                ToolsUtility.EndGroup();
            }

            if (ToolsUtility.BeginFolderGroup("Shadow", ref env.shadowFolder))
            {
                shadowMapLevel.floatValue = EditorGUILayout.Slider("ShadowMap Scale", shadowMapLevel.floatValue, 0, 1);

                if (env.shadowMapLevel == 0 || env.shadowMap == null)
                {
                    EditorGUILayout.ObjectField(env.shadowMap, typeof(RenderTexture), false);
                }
                else
                {
                    float size = 256 * env.shadowMapLevel;
                    GUILayout.Space(size + 20);
                    Rect r = GUILayoutUtility.GetLastRect();
                    r.y     += 10;
                    r.width  = size;
                    r.height = size;
                    EditorGUI.DrawPreviewTexture(r, env.shadowMap);
                }
                EditorGUILayout.PropertyField(shadowBound);
                EditorGUILayout.PropertyField(lookTarget);
                EditorGUILayout.PropertyField(drawShadowLighing);
                ToolsUtility.EndFolderGroup();
            }

            if (ToolsUtility.BeginFolderGroup("Debug", ref env.debugFolder))
            {
                string[] debugNames = AssetsConfig.shaderDebugNames;
                env.debugContext.shaderID = Environment.debugShaderIDS;

                if (debugNames != null)
                {
                    EditorGUI.BeginChangeCheck();
                    debugMode.intValue = EditorGUILayout.Popup("DebugMode", debugMode.intValue, debugNames);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "GlobalDebugMode");
                        env.debugContext.modeModify = true;
                    }
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(debugDisplayType);
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(target, "DebugDisplay");
                        env.debugContext.typeModify = true;
                    }
                    if (debugDisplayType.intValue == (int)DebugDisplayType.Split)
                    {
                        EditorGUI.BeginChangeCheck();
                        PropertyField(splitAngle);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(target, "SplitAngle");
                            env.debugContext.angleModify = true;
                        }
                        EditorGUI.BeginChangeCheck();
                        splitPos.floatValue = EditorGUILayout.Slider("SplitPos", splitPos.floatValue, splitLeft, splitRight);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(target, "SplitPos");
                            env.debugContext.posModify = true;
                        }
                    }
                }
                ToolsUtility.EndFolderGroup();
            }
        }
Exemple #3
0
 public static void EndFolderGroup()
 {
     ToolsUtility.EndGroup();
 }