/// <summary>
        /// Creates the reflection prrobe parent object
        /// </summary>
        /// <param name="parentWithAmbientSkies"></param>
        /// <returns></returns>
        private static GameObject ReflectionProbeParenting(bool parentWithAmbientSkies)
        {
            GameObject reflectionProbeParent = GameObject.Find("Scene Reflection Probes");
            GameObject ambientSkiesParent    = GameObject.Find("Ambient Skies Environment");

            if (reflectionProbeParent == null)
            {
                reflectionProbeParent = new GameObject("Scene Reflection Probes");

                if (parentWithAmbientSkies)
                {
                    if (ambientSkiesParent == null)
                    {
                        ambientSkiesParent = SkyboxUtils.GetOrCreateParentObject("Ambient Skies Environment", false);
                        reflectionProbeParent.transform.SetParent(ambientSkiesParent.transform);
                    }
                    else
                    {
                        reflectionProbeParent.transform.SetParent(ambientSkiesParent.transform);
                    }
                }

                return(reflectionProbeParent);
            }
            else
            {
                return(reflectionProbeParent);
            }
        }
 /// <summary>
 /// Applies the skies settings
 /// </summary>
 public void ApplySkies()
 {
     //Check if all profiles exist
     if (m_settings.m_profiles != null && m_settings.m_selectedSkyboxProfileIndex >= 0 && m_settings.m_selectedProceduralSkyboxProfileIndex >= 0 && m_settings.m_selectedGradientSkyboxProfileIndex >= 0)
     {
         //Apply profile settings
         SkyboxUtils.SetFromProfileIndex(m_settings.m_profiles, m_settings.m_selectedSkyboxProfileIndex, m_settings.m_selectedProceduralSkyboxProfileIndex, m_settings.m_selectedGradientSkyboxProfileIndex, false, m_updateVisualEnvironment, m_updateFog, m_updateShadows, m_updateAmbientLight, m_updateScreenSpaceReflections, m_updateScreenSpaceRefractions, m_updateSun);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the Horizon Sky
        /// </summary>
        public static void RemoveHorizonSky()
        {
            GameObject horizonSky = GameObject.Find("Ambient Skies Horizon");

            if (horizonSky != null)
            {
                Object.DestroyImmediate(horizonSky);
                SkyboxUtils.DestroyParent("Ambient Skies Environment");
            }
        }
        /// <summary>
        /// Sets up the lighting
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="useDefaults"></param>
        public static void SetLightmapSettings(AmbientSkyProfiles skyProfiles, AmbientLightingProfile profile, bool useDefaults, bool updateRealtime, bool updateBaked)
        {
            //Clear console if required
            if (skyProfiles.m_smartConsoleClean)
            {
                SkyboxUtils.ClearLog();
                Debug.Log("Console cleared successfully");
            }

            if (profile.autoLightmapGeneration)
            {
                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.Iterative;
            }
            else
            {
                Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
            }

            Lightmapping.bounceBoost         = profile.lightBoostIntensity;
            Lightmapping.indirectOutputScale = profile.lightIndirectIntensity;

            Lightmapping.realtimeGI = profile.realtimeGlobalIllumination;
            Lightmapping.bakedGI    = profile.bakedGlobalIllumination;

            if (profile.realtimeGlobalIllumination)
            {
                if (updateRealtime)
                {
                    if (skyProfiles.m_showFunctionDebugsOnly)
                    {
                        Debug.Log("Updating: SetRealtimeGISettings()");
                    }

                    SetRealtimeGISettings(profile);
                }
            }

            if (profile.bakedGlobalIllumination)
            {
                if (updateBaked)
                {
                    if (skyProfiles.m_showFunctionDebugsOnly)
                    {
                        Debug.Log("Updating: SetBakedGISettings()");
                    }

                    SetBakedGISettings(profile);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets our own horizon shader if in the scene
        /// </summary>
        /// <returns>The water material if there is one</returns>
        public static Material GetHorizonMaterial()
        {
            //Grabs water material and returns
            string   horizonObject = SkyboxUtils.GetAssetPath("Horizon Sky Material");
            Material horizonMaterial;

            if (!string.IsNullOrEmpty(horizonObject))
            {
                horizonMaterial = AssetDatabase.LoadAssetAtPath <Material>(horizonObject);
                if (horizonMaterial != null)
                {
                    //returns the material
                    return(horizonMaterial);
                }
            }
            return(null);
        }
        /// <summary>
        /// Add realtime global reflection probes
        /// </summary>
        public static void AddGlobalReflectionProbeRealtime()
        {
            AmbientSkyProfiles profiles = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(SkyboxUtils.GetAssetPath("Ambient Skies Volume 1"));

            GameObject theParent = SkyboxUtils.GetOrCreateParentObject("Ambient Skies Environment", false);

            //Get the camera
            GameObject mainCamera = SkyboxUtils.GetOrCreateMainCamera();

            //Sets up the probe to terrain size & location
            Vector3 probeLocation = Vector3.zero;
            Vector3 probeSize     = new Vector3(3000f, 1250f, 3000f);
            Terrain terrain       = Terrain.activeTerrain;

            if (terrain != null && GameObject.Find("Ambient Skies Water System") == null)
            {
                probeSize    = terrain.terrainData.size;
                probeSize.x += 50f;
                probeSize.z += 50f;

                probeLocation   = terrain.transform.position + (probeSize * 0.5f);
                probeLocation.y = terrain.SampleHeight(probeLocation) + 100f;
            }

            GameObject globalProbeGo = GameObject.Find("Global Reflection Probe");

            if (globalProbeGo == null)
            {
                globalProbeGo = new GameObject("Global Reflection Probe");
                globalProbeGo.AddComponent <ReflectionProbe>();
            }

            ReflectionProbe globalProbe = globalProbeGo.GetComponent <ReflectionProbe>();
            Camera          camera      = mainCamera.GetComponent <Camera>();

            globalProbeGo.transform.parent = theParent.transform;
            if (terrain != null)
            {
                globalProbeGo.transform.localPosition = probeLocation;
            }
            else
            {
                globalProbeGo.transform.localPosition = new Vector3(0f, 60f, 0f);
            }
            globalProbeGo.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);

            //Configure probe settings
            if (globalProbe != null)
            {
                if (terrain != null)
                {
                    globalProbe.size = new Vector3(8f, terrain.terrainData.size.y / 2, 8f);
                }
                else
                {
                    globalProbe.size = new Vector3(8f, 400f, 8f);
                }
                globalProbe.farClipPlane = camera.farClipPlane / 1.4f;
            }

            //Configures all probes
            if (Object.FindObjectsOfType <ReflectionProbe>() != null)
            {
                if (profiles != null)
                {
                    if (profiles.m_selectedRenderPipeline == AmbientSkiesConsts.RenderPipelineSettings.HighDefinition)
                    {
#if HDPipeline && UNITY_2018_3_OR_NEWER
                        HDAdditionalReflectionData[] reflectionData = Object.FindObjectsOfType <HDAdditionalReflectionData>();
                        foreach (HDAdditionalReflectionData data in reflectionData)
                        {
#if UNITY_2019_1_OR_NEWER
                            data.mode = ProbeSettings.Mode.Baked;
#elif UNITY_2018_3_OR_NEWER
                            data.mode = ReflectionProbeMode.Baked;
#endif
                        }
#endif
                    }
                    else
                    {
                        ReflectionProbe[] allProbes = Object.FindObjectsOfType <ReflectionProbe>();
                        foreach (ReflectionProbe theReflectionProbes in allProbes)
                        {
                            theReflectionProbes.clearFlags = ReflectionProbeClearFlags.Skybox;
                            theReflectionProbes.mode       = ReflectionProbeMode.Baked;
                        }
                    }
                }
                else
                {
                    ReflectionProbe[] allProbes = Object.FindObjectsOfType <ReflectionProbe>();
                    foreach (ReflectionProbe theReflectionProbes in allProbes)
                    {
                        theReflectionProbes.clearFlags = ReflectionProbeClearFlags.Skybox;
                        theReflectionProbes.mode       = ReflectionProbeMode.Baked;
                    }
                }
            }

            //Updated reflection probes to realtime support
            QualitySettings.realtimeReflectionProbes = true;
        }
        /// <summary>
        /// Add static global reflection probes
        /// </summary>
        public static void AddGlobalReflectionProbeStatic()
        {
            GameObject theParent = SkyboxUtils.GetOrCreateParentObject("Ambient Skies Environment", false);

            //Get the camera
            GameObject mainCamera = SkyboxUtils.GetOrCreateMainCamera();

            //Sets up the probe to terrain size & location
            Vector3 probeLocation = Vector3.zero;
            Vector3 probeSize     = new Vector3(3000f, 1250f, 3000f);
            Terrain terrain       = Terrain.activeTerrain;

            if (terrain != null)
            {
                probeSize    = terrain.terrainData.size;
                probeSize.x += 50f;
                probeSize.z += 50f;

                probeLocation   = terrain.transform.position + (probeSize * 0.5f);
                probeLocation.y = terrain.SampleHeight(probeLocation) + 100f;
            }

            GameObject globalProbeGo = GameObject.Find("Global Reflection Probe");

            if (globalProbeGo == null)
            {
                globalProbeGo = new GameObject("Global Reflection Probe");
                globalProbeGo.AddComponent <ReflectionProbe>();
            }

            globalProbeGo.transform.parent = theParent.transform;
            if (terrain != null)
            {
                globalProbeGo.transform.localPosition = probeLocation;
            }
            else
            {
                globalProbeGo.transform.localPosition = new Vector3(0f, 60f, 0f);
            }

            globalProbeGo.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);
            ReflectionProbe globalProbe = globalProbeGo.GetComponent <ReflectionProbe>();
            Camera          camera      = mainCamera.GetComponent <Camera>();

            //Configure probe settings
            if (globalProbe != null)
            {
                globalProbe.size         = probeSize;
                globalProbe.farClipPlane = camera.farClipPlane / 1.4f;
            }

            //Configures all probes
            if (Object.FindObjectsOfType <ReflectionProbe>() != null)
            {
                ReflectionProbe[] allProbes = Object.FindObjectsOfType <ReflectionProbe>();
                foreach (ReflectionProbe theReflectionProbes in allProbes)
                {
                    theReflectionProbes.mode        = ReflectionProbeMode.Realtime;
                    theReflectionProbes.refreshMode = ReflectionProbeRefreshMode.OnAwake;
                }
            }

            //Updated reflection probes to realtime support
            QualitySettings.realtimeReflectionProbes = true;
        }
        /// <summary>
        /// Sets scripting defines for pipeline
        /// </summary>
        public bool ApplyScriptingDefine()
        {
            bool isChanged = false;

            if (GraphicsSettings.renderPipelineAsset == null)
            {
                m_settings.m_profiles.m_selectedRenderPipeline = AmbientSkiesConsts.RenderPipelineSettings.BuiltIn;

                string currBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                if (currBuildSettings.Contains("LWPipeline"))
                {
                    currBuildSettings = currBuildSettings.Replace("LWPipeline;", "");
                    currBuildSettings = currBuildSettings.Replace("LWPipeline", "");
                    isChanged         = true;
                }
                if (currBuildSettings.Contains("HDPipeline"))
                {
                    currBuildSettings = currBuildSettings.Replace("HDPipeline;", "");
                    currBuildSettings = currBuildSettings.Replace("HDPipeline", "");
                    isChanged         = true;
                }
                if (!currBuildSettings.Contains("AMBIENT_SKIES"))
                {
                    currBuildSettings += "AMBIENT_SKIES;";
                    isChanged          = true;
                }
                //Check for enviro plugin is there
                bool enviroPresent = Directory.Exists(SkyboxUtils.GetAssetPath("Enviro - Sky and Weather"));
                if (enviroPresent)
                {
                    if (!currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings += "AMBIENT_SKIES_ENVIRO";
                        isChanged          = true;
                    }
                }
                else
                {
                    if (currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO;", "");
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO", "");
                        isChanged         = true;
                    }
                }

                if (isChanged)
                {
                    if (EditorUtility.DisplayDialog("Status Changed", "The scripting defines need to updated this will cause a code recompile. Depending on how big your project is this could take a few minutes", "Ok"))
                    {
                        PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currBuildSettings);
                    }

                    return(true);
                }
            }
            else if (GraphicsSettings.renderPipelineAsset.GetType().ToString().Contains("HDRenderPipelineAsset"))
            {
                m_settings.m_profiles.m_selectedRenderPipeline = AmbientSkiesConsts.RenderPipelineSettings.HighDefinition;

                if (GraphicsSettings.renderPipelineAsset.name != "Procedural Worlds HDRPRenderPipelineAsset")
                {
                    GraphicsSettings.renderPipelineAsset = AssetDatabase.LoadAssetAtPath <RenderPipelineAsset>(SkyboxUtils.GetAssetPath("Procedural Worlds HDRPRenderPipelineAsset"));
                }

                string currBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                if (!currBuildSettings.Contains("HDPipeline"))
                {
                    if (string.IsNullOrEmpty(currBuildSettings))
                    {
                        currBuildSettings = "HDPipeline";
                    }
                    else
                    {
                        currBuildSettings += ";HDPipeline";
                    }
                    isChanged = true;
                }
                if (currBuildSettings.Contains("LWPipeline"))
                {
                    currBuildSettings = currBuildSettings.Replace("LWPipeline;", "");
                    currBuildSettings = currBuildSettings.Replace("LWPipeline", "");
                    isChanged         = true;
                }
                if (!currBuildSettings.Contains("AMBIENT_SKIES"))
                {
                    currBuildSettings += "AMBIENT_SKIES;";
                    isChanged          = true;
                }
                //Check for enviro plugin is there
                bool enviroPresent = Directory.Exists(SkyboxUtils.GetAssetPath("Enviro - Sky and Weather"));
                if (enviroPresent)
                {
                    if (!currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings += "AMBIENT_SKIES_ENVIRO";
                        isChanged          = true;
                    }
                }
                else
                {
                    if (currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO;", "");
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO", "");
                        isChanged         = true;
                    }
                }

                if (isChanged)
                {
                    if (EditorUtility.DisplayDialog("Status Changed", "The scripting defines need to updated this will cause a code recompile. Depending on how big your project is this could take a few minutes", "Ok"))
                    {
                        PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currBuildSettings);
                    }

                    return(true);
                }
            }
            else
            {
                m_settings.m_profiles.m_selectedRenderPipeline = AmbientSkiesConsts.RenderPipelineSettings.Lightweight;

                if (GraphicsSettings.renderPipelineAsset.name != "Procedural Worlds Lightweight Pipeline Profile Ambient Skies")
                {
                    GraphicsSettings.renderPipelineAsset = AssetDatabase.LoadAssetAtPath <RenderPipelineAsset>(SkyboxUtils.GetAssetPath("Procedural Worlds Lightweight Pipeline Profile Ambient Skies"));
                }

                string currBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
                if (!currBuildSettings.Contains("LWPipeline"))
                {
                    if (string.IsNullOrEmpty(currBuildSettings))
                    {
                        currBuildSettings = "LWPipeline";
                    }
                    else
                    {
                        currBuildSettings += ";LWPipeline";
                    }
                    isChanged = true;
                }
                if (currBuildSettings.Contains("HDPipeline"))
                {
                    currBuildSettings = currBuildSettings.Replace("HDPipeline;", "");
                    currBuildSettings = currBuildSettings.Replace("HDPipeline", "");
                    isChanged         = true;
                }
                if (!currBuildSettings.Contains("AMBIENT_SKIES"))
                {
                    currBuildSettings += "AMBIENT_SKIES;";
                    isChanged          = true;
                }
                //Check for enviro plugin is there
                bool enviroPresent = Directory.Exists(SkyboxUtils.GetAssetPath("Enviro - Sky and Weather"));
                if (enviroPresent)
                {
                    if (!currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings += "AMBIENT_SKIES_ENVIRO";
                        isChanged          = true;
                    }
                }
                else
                {
                    if (currBuildSettings.Contains("AMBIENT_SKIES_ENVIRO"))
                    {
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO;", "");
                        currBuildSettings = currBuildSettings.Replace("AMBIENT_SKIES_ENVIRO", "");
                        isChanged         = true;
                    }
                }

                if (isChanged)
                {
                    if (EditorUtility.DisplayDialog("Status Changed", "The scripting defines need to updated this will cause a code recompile. Depending on how big your project is this could take a few minutes", "Ok"))
                    {
                        PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currBuildSettings);
                    }

                    return(true);
                }
            }

            return(false);
        }
        public override void OnInspectorGUI()
        {
            //Initialization

            //Set up the box style
            if (m_boxStyle == null)
            {
                m_boxStyle = new GUIStyle(GUI.skin.box);
                m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
                m_boxStyle.fontStyle        = FontStyle.Bold;
                m_boxStyle.alignment        = TextAnchor.UpperLeft;
            }

            //Get AmientSkiesOrigamiPlugin object
            AmientSkiesAPI ambientSkiesSettings = (AmientSkiesAPI)target;

            m_settings = ambientSkiesSettings;

            m_creationToolSettings = AssetDatabase.LoadAssetAtPath <CreationToolsSettings>(SkyboxUtils.GetAssetPath("Ambient Skies Creation Tool Settings"));

            //Monitor for changes
            EditorGUI.BeginChangeCheck();

            GUILayout.BeginVertical("Profile Configuration", m_boxStyle);
            GUILayout.Space(25f);

            //Load settings
            LoadAmbientSkiesProfiles();

            //Sets scripting define and sets selected pipeline
            ApplyScriptingDefine();


            #region Local Variables

            //Values
            List <AmbientSkyProfiles> profileList = ambientSkiesSettings.m_profileList;
            int newProfileListIndex = ambientSkiesSettings.newProfileListIndex;
            int profileListIndex    = ambientSkiesSettings.m_profileListIndex;

            int newSkyboxSelection           = m_creationToolSettings.m_selectedHDRI;
            int newProceduralSkyboxSelection = m_creationToolSettings.m_selectedProcedural;
            int newGradientSkyboxSelection   = m_creationToolSettings.m_selectedGradient;
            int newppSelection = m_creationToolSettings.m_selectedPostProcessing;

            List <string> profileChoices          = ambientSkiesSettings.profileChoices;
            List <string> skyboxChoices           = ambientSkiesSettings.skyboxChoices;
            List <string> proceduralSkyboxChoices = ambientSkiesSettings.proceduralSkyboxChoices;
#if UNITY_2018_3_OR_NEWER
            List <string> gradientSkyboxChoices = ambientSkiesSettings.gradientSkyboxChoices;
#endif
            List <string> ppChoices           = ambientSkiesSettings.ppChoices;
            List <string> lightmappingChoices = ambientSkiesSettings.lightmappingChoices;

            AmbientSkyProfiles                        profiles               = ambientSkiesSettings.m_profiles;
            AmbientSkiesConsts.SystemTypes            systemtype             = profiles.m_systemTypes;
            AmbientSkiesConsts.RenderPipelineSettings renderPipelineSettings = ambientSkiesSettings.m_renderPipelineSelected;

            #endregion

            #region System selection

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Select System", GUILayout.Width(146f));
            newProfileListIndex = EditorGUILayout.Popup(profileListIndex, profileChoices.ToArray(), GUILayout.ExpandWidth(true), GUILayout.Height(16f));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            if (newProfileListIndex != profileListIndex)
            {
                profileListIndex = newProfileListIndex;
                profiles         = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(SkyboxUtils.GetAssetPath(profileList[profileListIndex].name));

                EditorPrefs.SetString("AmbientSkiesActiveProfile_", profileList[profileListIndex].name);

                m_creationToolSettings.m_selectedSystem = profileListIndex;

                newSkyboxSelection           = 0;
                newProceduralSkyboxSelection = 0;
                newGradientSkyboxSelection   = 0;

                #region Load List Profiles

                //Add skies profile names
                m_settings.skyboxChoices.Clear();
                foreach (var profile in m_settings.m_profiles.m_skyProfiles)
                {
                    m_settings.skyboxChoices.Add(profile.name);
                }
                //Add procedural skies profile names
                m_settings.proceduralSkyboxChoices.Clear();
                foreach (var profile in m_settings.m_profiles.m_proceduralSkyProfiles)
                {
                    m_settings.proceduralSkyboxChoices.Add(profile.name);
                }
#if UNITY_2018_3_OR_NEWER
                //Add gradient skies profile names
                m_settings.gradientSkyboxChoices.Clear();
                foreach (var profile in m_settings.m_profiles.m_gradientSkyProfiles)
                {
                    m_settings.gradientSkyboxChoices.Add(profile.name);
                }
#endif
                //Add post processing profile names
                m_settings.ppChoices.Clear();
                foreach (var profile in m_settings.m_profiles.m_ppProfiles)
                {
                    m_settings.ppChoices.Add(profile.name);
                }
                //Add lightmaps profile names
                m_settings.lightmappingChoices.Clear();
                foreach (var profile in m_settings.m_profiles.m_lightingProfiles)
                {
                    m_settings.lightmappingChoices.Add(profile.name);
                }

                #endregion

                Repaint();
            }

            #endregion

            #region Profile Selection

            GUILayout.BeginVertical("Skybox Profile Selection", m_boxStyle);
            GUILayout.Space(25f);

            if (systemtype == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Select Skybox", GUILayout.Width(146f));
                newSkyboxSelection = EditorGUILayout.Popup(ambientSkiesSettings.m_selectedSkyboxProfileIndex, skyboxChoices.ToArray(), GUILayout.ExpandWidth(true), GUILayout.Height(16f));
                EditorGUILayout.EndHorizontal();
                //Prev / Next
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (newSkyboxSelection == 0)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Prev"))
                {
                    newSkyboxSelection--;
                }
                GUI.enabled = true;
                if (newSkyboxSelection == skyboxChoices.Count - 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Next"))
                {
                    newSkyboxSelection++;
                }
                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
            }
            else if (systemtype == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Select Skybox", GUILayout.Width(146f));
                newProceduralSkyboxSelection = EditorGUILayout.Popup(ambientSkiesSettings.m_selectedProceduralSkyboxProfileIndex, proceduralSkyboxChoices.ToArray(), GUILayout.ExpandWidth(true), GUILayout.Height(16f));
                EditorGUILayout.EndHorizontal();
                //Prev / Next
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (newProceduralSkyboxSelection == 0)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Prev"))
                {
                    newProceduralSkyboxSelection--;
                }
                GUI.enabled = true;
                if (newProceduralSkyboxSelection == skyboxChoices.Count - 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Next"))
                {
                    newProceduralSkyboxSelection++;
                }
                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
            }
            else
            {
#if UNITY_2018_3_OR_NEWER
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Select Skybox", GUILayout.Width(146f));
                newGradientSkyboxSelection = EditorGUILayout.Popup(ambientSkiesSettings.m_selectedGradientSkyboxProfileIndex, gradientSkyboxChoices.ToArray(), GUILayout.ExpandWidth(true), GUILayout.Height(16f));
                EditorGUILayout.EndHorizontal();
                //Prev / Next
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (newGradientSkyboxSelection == 0)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Prev"))
                {
                    newGradientSkyboxSelection--;
                }
                GUI.enabled = true;
                if (newGradientSkyboxSelection == gradientSkyboxChoices.Count - 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Next"))
                {
                    newGradientSkyboxSelection++;
                }
                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
#endif
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Select Post Processing", GUILayout.Width(146f));
            newppSelection = EditorGUILayout.Popup(ambientSkiesSettings.m_selectedPostProcessingProfileIndex, ppChoices.ToArray(), GUILayout.ExpandWidth(true), GUILayout.Height(16f));
            EditorGUILayout.EndHorizontal();
            //Prev / Next
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (newppSelection == 0)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Prev"))
            {
                newppSelection--;
            }
            GUI.enabled = true;
            if (newppSelection == ppChoices.Count - 1)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Next"))
            {
                newppSelection++;
            }
            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();

            #endregion

            GUILayout.EndVertical();

            #region Buttons

            if (GUILayout.Button("Apply Changes"))
            {
                //Apply sky settings
                ApplySkies();
                //Apply post processing settings
                ApplyPostProcessing();
            }

            if (GUILayout.Button("Open Ambient Skies Editor"))
            {
                //Opens up Ambient Skies window
                ShowMenu();
            }

            #endregion

            GUILayout.EndHorizontal();

            //Check for changes, make undo record, make changes and let editor know we are dirty
            if (EditorGUI.EndChangeCheck())
            {
                #region Apply Changes

                Undo.RecordObject(ambientSkiesSettings, "Made camera culling changes");
                EditorUtility.SetDirty(ambientSkiesSettings);

                ambientSkiesSettings.m_profileList       = profileList;
                ambientSkiesSettings.newProfileListIndex = newProfileListIndex;
                ambientSkiesSettings.m_profileListIndex  = profileListIndex;

                m_creationToolSettings.m_selectedSystem = profileListIndex;

                ambientSkiesSettings.newSkyboxSelection                     = newSkyboxSelection;
                ambientSkiesSettings.newProceduralSkyboxSelection           = newProceduralSkyboxSelection;
                ambientSkiesSettings.newGradientSkyboxSelection             = newGradientSkyboxSelection;
                ambientSkiesSettings.m_selectedSkyboxProfileIndex           = newSkyboxSelection;
                ambientSkiesSettings.m_selectedProceduralSkyboxProfileIndex = newProceduralSkyboxSelection;
                ambientSkiesSettings.m_selectedGradientSkyboxProfileIndex   = newGradientSkyboxSelection;
                ambientSkiesSettings.m_selectedPostProcessingProfileIndex   = newppSelection;

                m_creationToolSettings.m_selectedHDRI           = newSkyboxSelection;
                m_creationToolSettings.m_selectedProcedural     = newProceduralSkyboxSelection;
                m_creationToolSettings.m_selectedGradient       = newGradientSkyboxSelection;
                m_creationToolSettings.m_selectedPostProcessing = newppSelection;

                ambientSkiesSettings.profileChoices          = profileChoices;
                ambientSkiesSettings.skyboxChoices           = skyboxChoices;
                ambientSkiesSettings.proceduralSkyboxChoices = proceduralSkyboxChoices;
#if UNITY_2018_3_OR_NEWER
                ambientSkiesSettings.gradientSkyboxChoices = gradientSkyboxChoices;
#endif
                ambientSkiesSettings.ppChoices           = ppChoices;
                ambientSkiesSettings.lightmappingChoices = lightmappingChoices;

                ambientSkiesSettings.m_profiles = profiles;
                profiles.m_systemTypes          = systemtype;
                ambientSkiesSettings.m_renderPipelineSelected = renderPipelineSettings;

                #endregion
            }
        }
        /// <summary>
        /// Loads up the profiles and systems
        /// </summary>
        public void LoadAmbientSkiesProfiles()
        {
            #region Load Profile

            m_settings.m_profileList = GetAllSkyProfilesProjectSearch("t:AmbientSkyProfiles");

            //Add global profile names
            m_settings.profileChoices.Clear();
            foreach (var profile in m_settings.m_profileList)
            {
                m_settings.profileChoices.Add(profile.name);
            }

            m_settings.newProfileListIndex = 0;

            if (EditorPrefs.GetString("AmbientSkiesActiveProfile_") != null)
            {
                m_settings.newProfileListIndex = GetSkyProfile(m_settings.m_profileList, EditorPrefs.GetString("AmbientSkiesActiveProfile_"));
            }
            else
            {
                m_settings.newProfileListIndex = GetSkyProfile(m_settings.m_profileList, "Ambient Skies Volume 1");
            }

            //Get main Ambient Skies Volume 1 asset
            m_settings.m_profiles = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(SkyboxUtils.GetAssetPath(m_settings.m_profileList[m_settings.newProfileListIndex].name));

            if (m_settings.m_profiles == null)
            {
                m_settings.m_profileListIndex  = 0;
                m_settings.newProfileListIndex = 0;
                m_settings.m_profiles          = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(SkyboxUtils.GetAssetPath("Ambient Skies Volume 1"));
            }

            if (m_settings.m_profiles.name == "Ambient Skies Volume 1 Dev")
            {
                m_settings.m_profiles = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(SkyboxUtils.GetAssetPath("Ambient Skies Volume 1"));
            }

            #endregion

            #region Load List Profiles

            //Add skies profile names
            m_settings.skyboxChoices.Clear();
            foreach (var profile in m_settings.m_profiles.m_skyProfiles)
            {
                m_settings.skyboxChoices.Add(profile.name);
            }
            //Add procedural skies profile names
            m_settings.proceduralSkyboxChoices.Clear();
            foreach (var profile in m_settings.m_profiles.m_proceduralSkyProfiles)
            {
                m_settings.proceduralSkyboxChoices.Add(profile.name);
            }
#if UNITY_2018_3_OR_NEWER
            //Add gradient skies profile names
            m_settings.gradientSkyboxChoices.Clear();
            foreach (var profile in m_settings.m_profiles.m_gradientSkyProfiles)
            {
                m_settings.gradientSkyboxChoices.Add(profile.name);
            }
#endif
            //Add post processing profile names
            m_settings.ppChoices.Clear();
            foreach (var profile in m_settings.m_profiles.m_ppProfiles)
            {
                m_settings.ppChoices.Add(profile.name);
            }
            //Add lightmaps profile names
            m_settings.lightmappingChoices.Clear();
            foreach (var profile in m_settings.m_profiles.m_lightingProfiles)
            {
                m_settings.lightmappingChoices.Add(profile.name);
            }

            #endregion

            #region Load Index

            //Get Current Saved
            if (m_settings.m_selectedSkyboxProfileIndex >= 0)
            {
                m_settings.m_selectedSkyboxProfile = m_settings.m_profiles.m_skyProfiles[m_settings.m_selectedSkyboxProfileIndex];
            }
            else
            {
                if (m_settings.m_profiles.m_showDebug)
                {
                    Debug.Log("Skybox Profile Empty");
                }

                m_settings.m_selectedSkyboxProfile = null;
            }

            if (m_settings.m_selectedProceduralSkyboxProfileIndex >= 0)
            {
                m_settings.m_selectedProceduralSkyboxProfile = m_settings.m_profiles.m_proceduralSkyProfiles[m_settings.m_selectedProceduralSkyboxProfileIndex];
            }
            else
            {
                if (m_settings.m_profiles.m_showDebug)
                {
                    Debug.Log("Skybox Profile Empty");
                }

                m_settings.m_selectedProceduralSkyboxProfile = null;
            }

            if (m_settings.m_selectedGradientSkyboxProfileIndex >= 0)
            {
                m_settings.m_selectedGradientSkyboxProfile = m_settings.m_profiles.m_gradientSkyProfiles[m_settings.m_selectedGradientSkyboxProfileIndex];
            }
            else
            {
                if (m_settings.m_profiles.m_showDebug)
                {
                    Debug.Log("Skybox Profile Empty");
                }

                m_settings.m_selectedGradientSkyboxProfile = null;
            }

            if (m_settings.m_selectedPostProcessingProfileIndex >= 0)
            {
                m_settings.m_selectedPostProcessingProfile = m_settings.m_profiles.m_ppProfiles[m_settings.m_selectedPostProcessingProfileIndex];
            }
            else
            {
                if (m_settings.m_profiles.m_showDebug)
                {
                    Debug.Log("Skybox Profile Empty");
                }

                m_settings.m_selectedPostProcessingProfile = null;
            }

            #endregion
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Check if the default settings are not set
        /// </summary>
        /// <returns></returns>
        private bool CheckIfDefaultsSet()
        {
            bool isDefaulted = true;

            if (skyMaterial == null)
            {
                skyMaterial = AssetDatabase.LoadAssetAtPath <Material>(SkyboxUtils.GetAssetPath("Ambient Skies Skybox"));
            }
            else
            {
                if (skyMaterial.shader != Shader.Find("Skybox/Procedural"))
                {
                    isDefaulted = false;
                }
            }

            if (m_profile.m_CreationToolSettings.m_selectedSystem != 0)
            {
                isDefaulted = false;
            }
            if (m_profile.m_CreationToolSettings.m_selectedHDRI != 6)
            {
                isDefaulted = false;
            }
            if (m_profile.m_CreationToolSettings.m_selectedProcedural != 1)
            {
                isDefaulted = false;
            }
            if (m_profile.m_CreationToolSettings.m_selectedGradient != 1)
            {
                isDefaulted = false;
            }
            if (m_profile.m_CreationToolSettings.m_selectedPostProcessing != 14)
            {
                isDefaulted = false;
            }
            if (m_profile.m_CreationToolSettings.m_selectedLighting != 0)
            {
                isDefaulted = false;
            }

            if (m_profile.m_systemTypes != AmbientSkiesConsts.SystemTypes.ThirdParty)
            {
                isDefaulted = false;
            }

            if (m_profile.m_useTimeOfDay == AmbientSkiesConsts.DisableAndEnable.Enable)
            {
                isDefaulted = false;
            }

            if (m_profile.m_useSkies)
            {
                isDefaulted = false;
            }
            if (m_profile.m_usePostFX)
            {
                isDefaulted = false;
            }
            if (m_profile.m_useLighting)
            {
                isDefaulted = false;
            }
            if (m_profile.m_editSettings)
            {
                isDefaulted = false;
            }
            if (m_profile.m_showDebug)
            {
                isDefaulted = false;
            }
            if (m_profile.m_showFunctionDebugsOnly)
            {
                isDefaulted = false;
            }
            if (m_profile.m_showHasChangedDebug)
            {
                isDefaulted = false;
            }
            if (m_profile.m_showTimersInDebug)
            {
                isDefaulted = false;
            }
            if (m_profile.m_smartConsoleClean)
            {
                isDefaulted = false;
            }

            return(isDefaulted);
        }
        /// <summary>
        /// Applies the settings to the system
        /// </summary>
        /// <param name="profile"></param>
        public static void SetupMassiveCloudsSystem(AmbientPostProcessingProfile profile)
        {
#if Mewlist_Clouds && UNITY_POST_PROCESSING_STACK_V2
            GameObject         postProcessVolumeObj = GameObject.Find("Global Post Processing");
            PostProcessVolume  postProcessVolume;
            PostProcessProfile processProfile;
            if (postProcessVolumeObj != null)
            {
                postProcessVolume = postProcessVolumeObj.GetComponent <PostProcessVolume>();
                if (postProcessVolume != null)
                {
                    processProfile = postProcessVolume.sharedProfile;
                    if (processProfile != null)
                    {
                        EditorUtility.SetDirty(processProfile);

                        if (profile.massiveCloudsEnabled)
                        {
                            MassiveCloudsEffectSettings massiveClouds;
                            if (!processProfile.TryGetSettings(out massiveClouds))
                            {
                                if (Application.isPlaying)
                                {
                                    Debug.LogWarning("Trying to add 'MassiveCloudsEffectSettings' to " + processProfile + " Unable to add the component in play mode. Please stop the application enable the cloud system then play the application");
                                    profile.massiveCloudsEnabled = false;
                                }
                                else
                                {
                                    massiveClouds = processProfile.AddSettings <MassiveCloudsEffectSettings>();

                                    if (processProfile.TryGetSettings(out massiveClouds))
                                    {
                                        if (GraphicsSettings.renderPipelineAsset.GetType().ToString().Contains("HDRenderPipelineAsset"))
                                        {
                                            massiveClouds.IsHDRP.overrideState = true;
                                            massiveClouds.IsHDRP.value         = true;
                                        }
                                        else
                                        {
                                            massiveClouds.IsHDRP.value = false;
                                        }

                                        massiveClouds.active = true;
                                        massiveClouds.BaseColor.overrideState = true;
                                        massiveClouds.FogColor.overrideState  = true;
                                        massiveClouds.Profile.overrideState   = true;
                                        massiveClouds.SynchronizeBaseColorWithFogColor.overrideState = true;
                                        massiveClouds.SynchronizeGlobalFogColor.overrideState        = true;

                                        massiveClouds.SynchronizeBaseColorWithFogColor.value = profile.syncBaseFogColor;
                                        massiveClouds.SynchronizeGlobalFogColor.value        = profile.syncGlobalFogColor;
                                        massiveClouds.FogColor.value  = profile.cloudsFogColor;
                                        massiveClouds.BaseColor.value = profile.cloudsBaseFogColor;
                                        if (massiveClouds.Profile.value == null)
                                        {
                                            massiveClouds.Profile.value = AssetDatabase.LoadAssetAtPath <MassiveCloudsProfile>(SkyboxUtils.GetAssetPath("SolidRich"));
                                            profile.cloudProfile        = massiveClouds.Profile.value;
                                        }
                                        else
                                        {
                                            massiveClouds.Profile.value = profile.cloudProfile;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (processProfile.TryGetSettings(out massiveClouds))
                                {
                                    massiveClouds.active = true;
                                    massiveClouds.BaseColor.overrideState = true;
                                    massiveClouds.FogColor.overrideState  = true;
                                    massiveClouds.Profile.overrideState   = true;
                                    massiveClouds.SynchronizeBaseColorWithFogColor.overrideState = true;
                                    massiveClouds.SynchronizeGlobalFogColor.overrideState        = true;

                                    massiveClouds.SynchronizeBaseColorWithFogColor.value = profile.syncBaseFogColor;
                                    massiveClouds.SynchronizeGlobalFogColor.value        = profile.syncGlobalFogColor;
                                    massiveClouds.FogColor.value  = profile.cloudsFogColor;
                                    massiveClouds.BaseColor.value = profile.cloudsBaseFogColor;
                                    massiveClouds.Profile.value   = profile.cloudProfile;
                                }
                            }
                        }
                        else
                        {
                            MassiveCloudsEffectSettings massiveClouds;
                            if (Application.isPlaying)
                            {
                                if (processProfile.TryGetSettings(out massiveClouds))
                                {
                                    massiveClouds.active = false;
                                }
                            }
                            else
                            {
                                if (processProfile.TryGetSettings(out massiveClouds))
                                {
                                    processProfile.RemoveSettings <MassiveCloudsEffectSettings>();
                                }
                            }
                        }
                    }
                }
            }
#endif
        }