Ejemplo n.º 1
0
 void OnEnable()
 {
     if (m_editorUtils == null)
     {
         // Get editor utils for this
         m_editorUtils = PWApp.GetEditorUtils(this);
     }
     m_profile = (AmbientSkyProfiles)target;
 }
        /// <summary>
        /// Load the selected profile and apply it
        /// </summary>
        /// <param name="profile">The profiles object</param>
        /// <param name="profileName">The name of the profile to load</param>
        /// <param name="useDefaults">Whether to load default settings or current user settings.</param>
        public static void SetFromProfileName(AmbientSkyProfiles skyProfiles, AmbientSkyProfiles profile, string profileName, bool useDefaults, bool updateRealtime, bool updateBaked)
        {
            AmbientLightingProfile p = profile.m_lightingProfiles.Find(x => x.name == profileName);

            if (p == null)
            {
                Debug.LogWarning("Invalid profile name supplied, can not apply post processing profile!");
                return;
            }
            SetLightmapSettings(skyProfiles, p, useDefaults, updateRealtime, updateBaked);
        }
Ejemplo n.º 3
0
        public static void CreateSkyProfiles()
        {
            AmbientSkyProfiles asset = ScriptableObject.CreateInstance <AmbientSkyProfiles>();

            #if UNITY_EDITOR
            AssetDatabase.CreateAsset(asset, "Assets/Ambient Skies Profile.asset");
            AssetDatabase.SaveAssets();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = asset;
            #endif
        }
        /// <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);
                }
            }
        }
 /// <summary>
 /// Get current profile index that has the profile name
 /// </summary>
 /// <param name="profiles">Profile list to search</param>
 /// <param name="profileName">Name of profile to find</param>
 /// <returns>Profile index, or -1 if failed</returns>
 public static int GetProfileIndexFromProfileName(AmbientSkyProfiles profiles, string profileName)
 {
     if (profiles.m_lightingProfiles.Count < 0)
     {
         return(-1);
     }
     else
     {
         for (int idx = 0; idx < profiles.m_lightingProfiles.Count; idx++)
         {
             if (profiles.m_lightingProfiles[idx].name == profileName)
             {
                 return(idx);
             }
         }
     }
     return(-1);
 }
        /// <summary>
        /// Finds all profiles, to find type search t:OBJECT
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="typeToSearch"></param>
        /// <returns></returns>
        public List <AmbientSkyProfiles> GetAllSkyProfilesProjectSearch(string typeToSearch)
        {
            string[] skyProfilesGUIDs = AssetDatabase.FindAssets(typeToSearch);
            List <AmbientSkyProfiles> newSkyProfiles = new List <AmbientSkyProfiles>(skyProfilesGUIDs.Length);

            for (int x = 0; x < skyProfilesGUIDs.Length; ++x)
            {
                string             path = AssetDatabase.GUIDToAssetPath(skyProfilesGUIDs[x]);
                AmbientSkyProfiles data = AssetDatabase.LoadAssetAtPath <AmbientSkyProfiles>(path);
                if (data == null)
                {
                    continue;
                }
                newSkyProfiles.Add(data);
            }

            return(newSkyProfiles);
        }
        /// <summary>
        /// Load the selected profile and apply to the lightmap settings
        /// </summary>
        /// <param name="profiles">The profiles object</param>
        /// <param name="profileIndex">The zero based index to load</param>
        /// <param name="useDefaults">Whether to load default settings or current user settings.</param>
        public static void SetFromProfileIndex(AmbientSkyProfiles skyProfiles, AmbientLightingProfile profiles, int profileName, bool useDefaults, bool updateRealtime, bool updateBaked)
        {
            if (skyProfiles == null)
            {
                Debug.LogError("Missing the sky profiles (m_profiles from Ambient Skies) try reopening ambient skies and try again. Exiting");
                return;
            }

            if (profiles == null)
            {
                Debug.LogError("Missing the sky profiles (m_selectedLightingProfile from Ambient Skies) try reopening ambient skies and try again. Exiting");
                return;
            }

            AmbientLightingProfile p = profiles;

            if (p == null)
            {
                Debug.LogWarning("Invalid profile index selected, can not apply lightmapping settings!");
                return;
            }

            SetLightmapSettings(skyProfiles, p, false, updateRealtime, updateBaked);
        }
        /// <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;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Sets the horizon shader material pramaters
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="enableSystem"></param>
        public static void SetHorizonShaderSettings(AmbientSkyProfiles skyProfiles, AmbientSkyboxProfile profile, AmbientProceduralSkyboxProfile proceduralProfile, AmbientGradientSkyboxProfile gradientProfile, bool hasChanged)
        {
            if (skyProfiles.m_selectedRenderPipeline == AmbientSkiesConsts.RenderPipelineSettings.BuiltIn)
            {
                if (skyProfiles.m_useSkies)
                {
                    if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies)
                    {
                        if (profile.horizonSkyEnabled)
                        {
                            AddHorizonSky("Ambient Skies Horizon");

                            if (horizonMaterial == null)
                            {
                                horizonMaterial = GetHorizonMaterial();
                            }
                            else
                            {
                                if (hasChanged)
                                {
                                    ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial);
                                }
                            }
                        }
                        else
                        {
                            RemoveHorizonSky();
                        }
                    }
                    else if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies)
                    {
                        if (proceduralProfile.horizonSkyEnabled)
                        {
                            AddHorizonSky("Ambient Skies Horizon");

                            if (horizonMaterial == null)
                            {
                                horizonMaterial = GetHorizonMaterial();
                            }
                            else
                            {
                                if (hasChanged)
                                {
                                    ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial);
                                }
                            }
                        }
                        else
                        {
                            RemoveHorizonSky();
                        }
                    }
                    else
                    {
                        if (gradientProfile.horizonSkyEnabled)
                        {
                            AddHorizonSky("Ambient Skies Horizon");

                            if (horizonMaterial == null)
                            {
                                horizonMaterial = GetHorizonMaterial();
                            }
                            else
                            {
                                ApplyHorizonSettings(skyProfiles, profile, proceduralProfile, horizonMaterial);
                            }
                        }
                        else
                        {
                            RemoveHorizonSky();
                        }
                    }
                }
                else
                {
                    RemoveHorizonSky();
                }
            }
            else
            {
                RemoveHorizonSky();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Applies the settings to the horizons material and gameobject
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="horizonMaterial"></param>
        public static void ApplyHorizonSettings(AmbientSkyProfiles skyProfiles, AmbientSkyboxProfile profile, AmbientProceduralSkyboxProfile proceduralProfile, Material horizonMaterial)
        {
            if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientHDRISkies)
            {
                horizonMaterial.SetFloat("_Scattering", profile.horizonScattering);
                horizonMaterial.SetFloat("_FogDensity", profile.horizonFogDensity);
                horizonMaterial.SetFloat("_HorizonFalloff", profile.horizonFalloff);
                horizonMaterial.SetFloat("_HorizonBlend", profile.horizonBlend);

                if (horizonSkyObject == null)
                {
                    horizonSkyObject = GameObject.Find("Ambient Skies Horizon");

                    if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear)
                    {
                        horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance);
                    }
                    else
                    {
                        horizonSkyObject.transform.localScale = profile.horizonSize;
                    }

                    if (!profile.followPlayer)
                    {
                        horizonSkyObject.transform.position = profile.horizonPosition;
                    }
                }
                else
                {
                    if (profile.scaleHorizonObjectWithFog && profile.fogType == AmbientSkiesConsts.VolumeFogType.Linear)
                    {
                        horizonSkyObject.transform.localScale = new Vector3(profile.fogDistance, profile.fogDistance * 1.2f, profile.fogDistance);
                    }
                    else
                    {
                        horizonSkyObject.transform.localScale = profile.horizonSize;
                    }

                    if (!profile.followPlayer)
                    {
                        horizonSkyObject.transform.position = profile.horizonPosition;
                    }
                }

                if (horizonSettings == null)
                {
                    horizonSettings = Object.FindObjectOfType <HorizonSky>();
                    horizonSettings.m_followsCameraPosition = profile.followPlayer;
                    horizonSettings.m_positionUpdate        = profile.horizonUpdateTime;
                    horizonSettings.UpdatePosition();
                }
                else
                {
                    horizonSettings.m_followsCameraPosition = profile.followPlayer;
                    horizonSettings.m_positionUpdate        = profile.horizonUpdateTime;
                    horizonSettings.UpdatePosition();
                }
            }
            else if (skyProfiles.m_systemTypes == AmbientSkiesConsts.SystemTypes.AmbientProceduralSkies)
            {
                horizonMaterial.SetFloat("_Scattering", proceduralProfile.horizonScattering);
                horizonMaterial.SetFloat("_FogDensity", proceduralProfile.horizonFogDensity);
                horizonMaterial.SetFloat("_HorizonFalloff", proceduralProfile.horizonFalloff);
                horizonMaterial.SetFloat("_HorizonBlend", proceduralProfile.horizonBlend);

                if (horizonSkyObject == null)
                {
                    horizonSkyObject = GameObject.Find("Ambient Skies Horizon");

                    if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear)
                    {
                        horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance);
                    }
                    else
                    {
                        horizonSkyObject.transform.localScale = proceduralProfile.horizonSize;
                    }

                    if (!proceduralProfile.followPlayer)
                    {
                        horizonSkyObject.transform.position = proceduralProfile.horizonPosition;
                    }
                }
                else
                {
                    if (proceduralProfile.scaleHorizonObjectWithFog && proceduralProfile.fogType == AmbientSkiesConsts.VolumeFogType.Linear)
                    {
                        horizonSkyObject.transform.localScale = new Vector3(proceduralProfile.proceduralFogDistance, proceduralProfile.proceduralFogDistance * 1.2f, proceduralProfile.proceduralFogDistance);
                    }
                    else
                    {
                        horizonSkyObject.transform.localScale = proceduralProfile.horizonSize;
                    }

                    if (!proceduralProfile.followPlayer)
                    {
                        horizonSkyObject.transform.position = proceduralProfile.horizonPosition;
                    }
                }

                if (horizonSettings == null)
                {
                    horizonSettings = Object.FindObjectOfType <HorizonSky>();
                    horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer;
                    horizonSettings.m_positionUpdate        = proceduralProfile.horizonUpdateTime;
                    horizonSettings.UpdatePosition();
                }
                else
                {
                    horizonSettings.m_followsCameraPosition = proceduralProfile.followPlayer;
                    horizonSettings.m_positionUpdate        = proceduralProfile.horizonUpdateTime;
                    horizonSettings.UpdatePosition();
                }
            }
        }
        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
            }
        }
Ejemplo n.º 12
0
        public override void OnInspectorGUI()
        {
            m_profile = (AmbientSkyProfiles)target;
            if (m_profile != null)
            {
                string version = PWApp.CONF.Version;

                EditorGUI.BeginChangeCheck();

                Color defaultBackgroundColor = GUI.backgroundColor;
                Color notDefaultsSetColor    = Color.red;
                Color defaultsSetColor       = Color.green;

                EditorGUILayout.LabelField("Version: " + version);

                if (!CheckIfDefaultsSet())
                {
                    GUI.backgroundColor = notDefaultsSetColor;
                    if (GUILayout.Button("Revert To Factory Settings"))
                    {
                        if (EditorUtility.DisplayDialog("Warning!", "You are about to revert to factory settings. This will close the editor window if open, and reset Ambient Skies back to it's default installation settings. Doing this will overwrite your changes, are you sure you want to proceed?", "Yes", "No"))
                        {
                            AmbientSkiesEditorWindow editor = (AmbientSkiesEditorWindow)EditorWindow.GetWindow(typeof(AmbientSkiesEditorWindow));
                            if (editor != null)
                            {
                                editor.Close();
                            }
                            m_profile.RevertAllDefaults(m_profile.m_selectedRenderPipeline);
                        }
                    }
                }

                if (m_profile.m_editSettings)
                {
                    GUI.backgroundColor = defaultBackgroundColor;
                    DrawDefaultInspector();
                    if (GUILayout.Button("Save All Defaults"))
                    {
                        m_profile.SaveAllDefaults(m_profile.m_selectedRenderPipeline);
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    if (m_profile.m_editSettings)
                    {
                        //Make sure profile indexes are correct
                        for (int profileIdx = 0; profileIdx < m_profile.m_skyProfiles.Count; profileIdx++)
                        {
                            m_profile.m_skyProfiles[profileIdx].profileIndex = profileIdx;
                        }
                        //Make sure profile indexes are correct
                        for (int profileIdx = 0; profileIdx < m_profile.m_proceduralSkyProfiles.Count; profileIdx++)
                        {
                            m_profile.m_proceduralSkyProfiles[profileIdx].profileIndex = profileIdx;
                        }
                        //Make sure profile indexes are correct
                        for (int profileIdx = 0; profileIdx < m_profile.m_gradientSkyProfiles.Count; profileIdx++)
                        {
                            m_profile.m_gradientSkyProfiles[profileIdx].profileIndex = profileIdx;
                        }
                        for (int profileIdx = 0; profileIdx < m_profile.m_ppProfiles.Count; profileIdx++)
                        {
                            m_profile.m_ppProfiles[profileIdx].profileIndex = profileIdx;
                        }
                    }
                    EditorUtility.SetDirty(m_profile);
                }
            }
        }