public static void CreateSkyProfiles()
        {
            CreationToolsSettings asset = ScriptableObject.CreateInstance <CreationToolsSettings>();

            AssetDatabase.CreateAsset(asset, "Assets/Ambient Skies Creation Tool Settings.asset");
            AssetDatabase.SaveAssets();
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = asset;
        }
        //Inspector GUI
        public override void OnInspectorGUI()
        {
            //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 Auto Focus Sky object
            CreationToolsSettings creation = (CreationToolsSettings)target;

            //Monitor for changess
            EditorGUI.BeginChangeCheck();

            //Locked values
            bool lockValues = m_lockValues;

            GUILayout.BeginVertical("Creation Tools Settings", m_boxStyle);
            GUILayout.Space(20);

            string version = PWApp.CONF.Version;

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

            //Repairs the profile values
            if (GUILayout.Button("Repair Creation Tools Settings"))
            {
                creation.RepairScriptableObject();
            }

            //If not locked
            if (!lockValues)
            {
                //Button to lock the profile
                if (GUILayout.Button("Lock Settings"))
                {
                    lockValues = true;
                }
            }
            else
            {
                //Button to unlcok the profile
                if (GUILayout.Button("Unlock Settings"))
                {
                    lockValues = false;
                }
            }

            //Selected values
            int selectedSystem         = creation.m_selectedSystem;
            int selectedHDRI           = creation.m_selectedHDRI;
            int selectedProcedural     = creation.m_selectedProcedural;
            int selectedGradient       = creation.m_selectedGradient;
            int selectedPostProcessing = creation.m_selectedPostProcessing;
            int selectedLighting       = creation.m_selectedLighting;

            //If not locked
            if (!lockValues)
            {
                EditorGUILayout.LabelField("Selected System: " + selectedSystem.ToString(), m_boxStyle);

                EditorGUILayout.LabelField("Selected HDRI Skybox: " + selectedHDRI.ToString(), m_boxStyle);
                EditorGUILayout.LabelField("Selected Procedural Skybox: " + selectedProcedural.ToString(), m_boxStyle);
                EditorGUILayout.LabelField("Selected Gradient Skybox: " + selectedGradient.ToString(), m_boxStyle);

                EditorGUILayout.LabelField("Selected Post Processing: " + selectedPostProcessing.ToString(), m_boxStyle);

                EditorGUILayout.LabelField("Selected Lighting: " + selectedLighting.ToString(), m_boxStyle);
            }

            GUILayout.EndVertical();

            //Check for changes, make undo record, make changes and let editor know we are dirty
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(creation, "Made camera culling changes");
                EditorUtility.SetDirty(creation);

                m_lockValues = lockValues;
            }
        }
        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
            }
        }
示例#4
0
        /// <summary>
        /// Saves all the settings in all profiles
        /// </summary>
        /// <param name="renderPipelineSettings"></param>
        public void RevertAllDefaults(AmbientSkiesConsts.RenderPipelineSettings renderPipelineSettings)
        {
#if UNITY_EDITOR
            EditorUtility.SetDirty(this);

            m_systemTypes            = AmbientSkiesConsts.SystemTypes.ThirdParty;
            m_useTimeOfDay           = AmbientSkiesConsts.DisableAndEnable.Disable;
            m_useSkies               = false;
            m_usePostFX              = false;
            m_useLighting            = false;
            m_editSettings           = false;
            m_showDebug              = false;
            m_showFunctionDebugsOnly = false;
            m_showHasChangedDebug    = false;
            m_showTimersInDebug      = false;
            m_smartConsoleClean      = false;

            GameObject postProcessObject = GameObject.Find("Global Post Processing");
            if (postProcessObject != null)
            {
                DestroyImmediate(postProcessObject);
            }

            GameObject hdrpPPVolume = GameObject.Find("Post Processing HDRP Volume");
            if (hdrpPPVolume != null)
            {
                DestroyImmediate(hdrpPPVolume);
            }

            foreach (AmbientSkyboxProfile skyboxProfile in m_skyProfiles)
            {
                skyboxProfile.RevertToDefault();
            }

            foreach (AmbientProceduralSkyboxProfile proceduralProfile in m_proceduralSkyProfiles)
            {
                proceduralProfile.RevertToDefault();
            }

            foreach (AmbientGradientSkyboxProfile gradientProfile in m_gradientSkyProfiles)
            {
                gradientProfile.RevertToDefault();
            }

            foreach (AmbientPostProcessingProfile processProfile in m_ppProfiles)
            {
                processProfile.RevertToDefault(renderPipelineSettings);
            }

            foreach (AmbientLightingProfile lightingProfile in m_lightingProfiles)
            {
                lightingProfile.RevertToDefault();
            }

            if (m_selectedRenderPipeline == AmbientSkiesConsts.RenderPipelineSettings.BuiltIn)
            {
                UpdateAllFogType(AmbientSkiesConsts.VolumeFogType.Linear);
            }
            else if (m_selectedRenderPipeline == AmbientSkiesConsts.RenderPipelineSettings.Lightweight)
            {
                UpdateAllFogType(AmbientSkiesConsts.VolumeFogType.Linear);
            }
            else
            {
                UpdateAllFogType(AmbientSkiesConsts.VolumeFogType.Volumetric);
            }

            m_CreationToolSettings = AssetDatabase.LoadAssetAtPath <CreationToolsSettings>(GetAssetPath("Ambient Skies Creation Tool Settings"));
            if (m_CreationToolSettings != null)
            {
                EditorUtility.SetDirty(m_CreationToolSettings);
                m_CreationToolSettings.RevertToFactorySettings();
            }

            Material skyMaterial = AssetDatabase.LoadAssetAtPath <Material>(GetAssetPath("Ambient Skies Skybox"));
            if (skyMaterial != null)
            {
                skyMaterial.shader = Shader.Find("Skybox/Procedural");
                skyMaterial.SetFloat("_SunDisk", 2f);
                skyMaterial.EnableKeyword("_SUNDISK_HIGH_QUALITY");
            }

            DestroyParent("Ambient Skies Environment");

            Debug.Log("Reverted to factory settings successfully");
#endif
        }