Exemple #1
0
        /// <summary>
        /// Helper function to create a GUIContent for button icons - decided whether to use Unity Standard or Pro Icons and adds the tooltip text
        /// </summary>
        /// <param name="key">Localization key to get the tooltip from</param>
        /// <param name="standardIcon">Icon to use for Unity Standard Skin</param>
        /// <param name="proIcon">Icon to use for Unity Pro Skin</param>
        /// <param name="editorUtils">Current Editor Utils class to pass in to look up the localized tooltip</param>
        /// <returns>GUIContent with correct texture and tooltip.</returns>
        public static GUIContent GetIconGUIContent(string key, Texture2D standardIcon, Texture2D proIcon, EditorUtils editorUtils)
        {
            Texture icon = null;

            if (EditorGUIUtility.isProSkin)
            {
                icon = proIcon;
            }
            else
            {
                icon = standardIcon;
            }

            return(new GUIContent(icon, editorUtils.GetTooltip(key)));
        }
Exemple #2
0
        private void BookmarkSetup(bool helpEnabled)
        {
            if (m_profile.m_locationProfile != null)
            {
                m_editorUtils.Heading("BookmarkSetup");
                m_profile.m_locationProfile.m_autoLoad = m_editorUtils.Toggle("AutoLoad", m_profile.m_locationProfile.m_autoLoad, helpEnabled);
                if (m_profile.m_locationProfile.m_bookmarkedLocationNames.Count > 0)
                {
                    int selected = m_profile.m_selectedBookmark;
                    for (int i = 0; i < m_profile.m_locationProfile.m_bookmarkedLocationNames.Count; i++)
                    {
                        if (m_profile.m_locationProfile.m_bookmarkedLocationNames[i] == m_profile.m_bookmarkName)
                        {
                            m_profile.m_bookmarkName = ObjectNames.GetUniqueName(m_profile.m_locationProfile.m_bookmarkedLocationNames.ToArray(), m_profile.m_bookmarkName);
                        }
                    }

                    EditorGUILayout.BeginHorizontal();
                    m_profile.m_bookmarkName = m_editorUtils.TextField("BookmarkName", m_profile.m_bookmarkName);
                    if (m_editorUtils.Button("AddBookmark", GUILayout.MaxWidth(60f)))
                    {
                        m_profile.m_locationProfile.AddNewBookmark(m_profile);
                        selected = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
                        m_profile.m_selectedBookmark = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
                    }
                    EditorGUILayout.EndHorizontal();
                    m_editorUtils.InlineHelp("BookmarkName", helpEnabled);

                    if (!m_profile.m_rename)
                    {
                        EditorGUILayout.BeginHorizontal();
                        selected = EditorGUILayout.Popup(new GUIContent(m_editorUtils.GetTextValue("SelectedBookmark"), m_editorUtils.GetTooltip("SelectedBookmark")), selected, m_profile.m_locationProfile.m_bookmarkedLocationNames.ToArray());
                        if (selected != m_profile.m_selectedBookmark)
                        {
                            m_profile.m_selectedBookmark = selected;
                            if (m_profile.m_locationProfile.m_autoLoad)
                            {
                                m_profile.m_locationProfile.LoadBookmark(m_profile);
                            }
                        }

                        if (m_editorUtils.Button("Rename", GUILayout.MaxWidth(60f)))
                        {
                            m_profile.m_savedName = m_profile.m_locationProfile.m_bookmarkedLocationNames[m_profile.m_selectedBookmark];
                            m_profile.m_rename    = true;
                        }

                        if (m_editorUtils.Button("Override", GUILayout.MaxWidth(60f)))
                        {
                            m_profile.m_locationProfile.OverrideBookmark(m_profile);
                        }
                        if (!m_profile.m_locationProfile.m_autoLoad)
                        {
                            if (m_editorUtils.Button("LoadBookmark", GUILayout.MaxWidth(60f)))
                            {
                                m_profile.m_locationProfile.LoadBookmark(m_profile);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        m_editorUtils.InlineHelp("SelectedBookmark", helpEnabled);
                        if (m_profile.m_locationProfile.m_bookmarkedLocationNames.Count > 0)
                        {
                            EditorGUILayout.LabelField("Current Bookmark Controller Type Used: " + m_profile.m_locationProfile.m_bookmarkedSettings[selected].m_controllerUsed, EditorStyles.boldLabel);
                        }

                        EditorGUILayout.LabelField("Current Bookmark Was Created In Scene: " + m_profile.m_locationProfile.m_bookmarkedSettings[selected].m_sceneName, EditorStyles.boldLabel);
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();
                        m_profile.m_savedName = m_editorUtils.TextField("BookmarkRename", m_profile.m_savedName);
                        if (m_editorUtils.Button("Save", GUILayout.MaxWidth(55f)))
                        {
                            m_profile.m_locationProfile.m_bookmarkedLocationNames[m_profile.m_selectedBookmark] = m_profile.m_savedName;
                            m_profile.m_rename = false;
                        }
                        EditorGUILayout.EndHorizontal();
                        m_editorUtils.InlineHelp("BookmarkRename", helpEnabled);
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (m_editorUtils.Button("RemoveBookmark"))
                    {
                        if (EditorUtility.DisplayDialog("Removing Bookmark", "Are you sure you want to remove " + m_profile.m_locationProfile.m_bookmarkedLocationNames[selected] + " bookmark?", "Yes", "No"))
                        {
                            m_profile.m_locationProfile.RemoveBookmark(m_profile.m_selectedBookmark, m_profile);
                        }
                    }

                    if (m_editorUtils.Button("RemoveAllBookmark"))
                    {
                        if (EditorUtility.DisplayDialog("Removing All Bookmarks", "Are you sure you want to remove all the bookmarks?", "Yes", "No"))
                        {
                            m_profile.m_locationProfile.RemoveAllBookmarks();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    m_profile.m_selectedBookmark = 0;
                    EditorGUILayout.BeginHorizontal();
                    m_profile.m_bookmarkName = m_editorUtils.TextField("BookmarkName", m_profile.m_bookmarkName);
                    if (m_editorUtils.Button("AddBookmark", GUILayout.MaxWidth(55f)))
                    {
                        m_profile.m_locationProfile.AddNewBookmark(m_profile);
                        m_profile.m_selectedBookmark = m_profile.m_locationProfile.m_bookmarkedLocationNames.Count - 1;
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.HelpBox("No bookmarks added to use bookmark features please press 'Add Bookmark'", MessageType.Info);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No location profile provided. Please add one.", MessageType.Info);
            }
        }
Exemple #3
0
        private void AutoDepthOfField(bool helpEnabled)
        {
#if UNITY_POST_PROCESSING_STACK_V2
            if (GaiaUtils.GetActivePipeline() == GaiaConstants.EnvironmentRenderer.BuiltIn)
            {
                //Get Auto Focus object
                AutoDepthOfField autoFocus = GaiaSceneManagement.SetupAutoDepthOfField(m_profile);

                //Monitor for changes
                EditorGUI.BeginChangeCheck();
                bool enableDOF = m_profile.m_enableAutoDOF;
                enableDOF = m_editorUtils.Toggle("EnableAutoDepthOfField", enableDOF, helpEnabled);
                if (m_profile.m_enableAutoDOF != enableDOF)
                {
                    m_profile.m_enableAutoDOF = enableDOF;
                    autoFocus = GaiaSceneManagement.SetupAutoDepthOfField(m_profile);
                }
                if (autoFocus != null && m_profile.m_enableAutoDOF)
                {
                    if (enableDOF)
                    {
                        bool oldDebugValue = autoFocus.m_debug;
                        autoFocus.m_debug = m_editorUtils.Toggle("ShowDebugInfo", autoFocus.m_debug);
                        if (oldDebugValue != autoFocus.m_debug && !autoFocus.m_debug)
                        {
                            autoFocus.RemoveDebugSphere();
                        }
                    }

#if !UNITY_POST_PROCESSING_STACK_V2
                    EditorGUILayout.HelpBox("Post Processing is not installed. Please install post processing from the package manager to use this feature. (Window/Package Manager)", MessageType.Warning);
                    GUI.enabled = false;
#endif
                    m_editorUtils.Heading("AutoFocusDependencies");
                    EditorGUI.indentLevel++;
                    autoFocus.m_sourceCamera = (Camera)m_editorUtils.ObjectField("SourceCamera", autoFocus.m_sourceCamera, typeof(Camera), true, helpEnabled);
                    if (autoFocus.m_sourceCamera == null)
                    {
                        EditorGUILayout.HelpBox("Source Camera is missing. Either add it manually or it will be added on start of application if present", MessageType.Error);
                    }
                    autoFocus.m_targetObject = (GameObject)m_editorUtils.ObjectField("TargetObject", autoFocus.m_targetObject, typeof(GameObject), true, helpEnabled);
                    if (autoFocus.m_targetObject == null && autoFocus.m_trackingType == GaiaConstants.DOFTrackingType.FollowTarget)
                    {
                        EditorGUILayout.HelpBox("Target Object is missing. Add it to use target focus mode", MessageType.Error);
                    }
                    autoFocus.m_targetLayer = GaiaEditorUtils.LayerMaskField(new GUIContent(m_editorUtils.GetTextValue("TargetLayer"), m_editorUtils.GetTooltip("TargetLayer")), autoFocus.m_targetLayer);
                    m_editorUtils.InlineHelp("TargetLayer", helpEnabled);
                    EditorGUI.indentLevel--;

                    m_editorUtils.Heading("AutoFocusConfiguration");
                    EditorGUI.indentLevel++;
                    autoFocus.m_interactWithPlayer = m_editorUtils.Toggle("InteractWithPlayer", autoFocus.m_interactWithPlayer, helpEnabled);
                    autoFocus.m_trackingType       = (GaiaConstants.DOFTrackingType)m_editorUtils.EnumPopup("TrackingMode", autoFocus.m_trackingType, helpEnabled);
                    autoFocus.m_focusOffset        = m_editorUtils.FloatField("FocusOffset", autoFocus.m_focusOffset, helpEnabled);
                    autoFocus.m_maxFocusDistance   = m_editorUtils.FloatField("MaxFocusDistance", autoFocus.m_maxFocusDistance, helpEnabled);
                    autoFocus.m_dofAperture        = m_editorUtils.Slider("Aperture", autoFocus.m_dofAperture, 0.1f, 32f, helpEnabled);
                    autoFocus.m_dofFocalLength     = m_editorUtils.Slider("FocalLength", autoFocus.m_dofFocalLength, 1f, 300f, helpEnabled);
                    if (Application.isPlaying)
                    {
                        EditorGUILayout.LabelField("Actual Focal Distance: " + autoFocus.m_actualFocusDistance);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Actual Focal Distance: Will be updated at runtime");
                    }
                    m_editorUtils.InlineHelp("ActualFocalDistance", helpEnabled);

                    EditorGUI.indentLevel--;
                }

                //Check for changes, make undo record, make changes and let editor know we are dirty
                if (EditorGUI.EndChangeCheck())
                {
                    if (autoFocus != null)
                    {
                        Undo.RecordObject(autoFocus, "Made depth of field changes");
                        EditorUtility.SetDirty(autoFocus);
                        autoFocus.SetDOFMainSettings(autoFocus.m_dofAperture, autoFocus.m_dofFocalLength);
                    }

                    EditorUtility.SetDirty(m_profile);
                }
            }
            else
            {
                m_profile.m_enableAutoDOF = false;
                GaiaSceneManagement.SetupAutoDepthOfField(m_profile);
                EditorGUILayout.HelpBox("Auto Depth Of Field is not yet supported for SRP this will be available in a near future update", MessageType.Info);
            }
#else
            EditorGUILayout.HelpBox("Post Processing V2 has not been isntalled. Please install Post Processing from the package manager to use auto depth of field.", MessageType.Info);
#endif
        }
Exemple #4
0
        private void GlobalSettingsEnabled(bool helpEnabled)
        {
            if (PlayerSettings.colorSpace != ColorSpace.Linear)
            {
                GUI.backgroundColor = Color.yellow;
                EditorGUILayout.HelpBox("Gaia lighting looks best in Linear Color Space. Go to Gaia standard tab and press Set Linear Deferred", MessageType.Warning);
            }

            GUI.backgroundColor = defaultBackground;

            m_editorUtils.Heading("SetupSettings");
            m_profile.m_multiSceneLightingSupport = m_editorUtils.Toggle("MultiSceneSupport", m_profile.m_multiSceneLightingSupport, helpEnabled);
            if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
            {
                m_profile.m_masterSkyboxMaterial = (Material)m_editorUtils.ObjectField("MasterSkyboxMaterial", m_profile.m_masterSkyboxMaterial, typeof(Material), false, GUILayout.Height(16f));
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("LightmappingSettings");
            m_profile.m_lightingBakeMode = (GaiaConstants.BakeMode)m_editorUtils.EnumPopup("LightmappingBakeMode", m_profile.m_lightingBakeMode, helpEnabled);
#if UNITY_2020_1_OR_NEWER
            m_profile.m_lightmappingMode = (LightingSettings.Lightmapper)EditorGUILayout.EnumPopup("Lightmapping Mode", m_profile.m_lightmappingMode);
#else
            m_profile.m_lightmappingMode = (LightmapEditorSettings.Lightmapper)EditorGUILayout.EnumPopup("Lightmapping Mode", m_profile.m_lightmappingMode);
#endif
            EditorGUILayout.Space();

            m_editorUtils.Heading("PostProcessingSettings");
            m_profile.m_enablePostProcessing = m_editorUtils.ToggleLeft("EnablePostProcessing", m_profile.m_enablePostProcessing);
            if (m_profile.m_enablePostProcessing)
            {
                m_profile.m_hideProcessVolume = m_editorUtils.ToggleLeft("HidePostProcessingVolumesInScene", m_profile.m_hideProcessVolume);
                m_profile.m_antiAliasingMode  = (GaiaConstants.GaiaProAntiAliasingMode)EditorGUILayout.EnumPopup("Anti-Aliasing Mode", m_profile.m_antiAliasingMode);
                if (m_renderPipeline == GaiaConstants.EnvironmentRenderer.BuiltIn)
                {
                    if (m_profile.m_antiAliasingMode == GaiaConstants.GaiaProAntiAliasingMode.TAA)
                    {
                        m_profile.m_AAJitterSpread       = m_editorUtils.Slider("AAJitterSpread", m_profile.m_AAJitterSpread, 0f, 1f, helpEnabled);
                        m_profile.m_AAStationaryBlending = m_editorUtils.Slider("AAStationaryBlending", m_profile.m_AAStationaryBlending, 0f, 1f, helpEnabled);
                        m_profile.m_AAMotionBlending     = m_editorUtils.Slider("AAMotionBlending", m_profile.m_AAMotionBlending, 0f, 1f, helpEnabled);
                        m_profile.m_AASharpness          = m_editorUtils.Slider("AASharpness", m_profile.m_AASharpness, 0f, 1f, helpEnabled);
                    }
                }
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("CameraSettings");
            m_profile.m_enableAutoDOF = m_editorUtils.Toggle("UseAutoDOF", m_profile.m_enableAutoDOF, helpEnabled);
            if (m_profile.m_enableAutoDOF)
            {
                m_profile.m_dofLayerDetection = GaiaEditorUtils.LayerMaskField(new GUIContent(m_editorUtils.GetTextValue("DOFLayerDetection"), m_editorUtils.GetTooltip("DOFLayerDetection")), m_profile.m_dofLayerDetection);
            }
            EditorGUILayout.Space();

            m_profile.m_usePhysicalCamera = m_editorUtils.Toggle("UsePhysicalCamera", m_profile.m_usePhysicalCamera, helpEnabled);
            if (m_profile.m_usePhysicalCamera)
            {
                m_profile.m_cameraFocalLength = m_editorUtils.FloatField("CameraFocalLength", m_profile.m_cameraFocalLength, helpEnabled);
                m_profile.m_cameraSensorSize  = m_editorUtils.Vector2Field("CameraSensorSize", m_profile.m_cameraSensorSize, helpEnabled);
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("MiscellaneousSettings");
            m_profile.m_globalReflectionProbe = m_editorUtils.ToggleLeft("GlobalReflectionProbe", m_profile.m_globalReflectionProbe);
            m_profile.m_parentObjects         = m_editorUtils.ToggleLeft("ParentObjectsToGaia", m_profile.m_parentObjects);
            m_profile.m_enableAmbientAudio    = m_editorUtils.ToggleLeft("EnableAmbientAudio", m_profile.m_enableAmbientAudio);

            if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
            {
                m_profile.m_enableFog = m_editorUtils.ToggleLeft("EnableFog", m_profile.m_enableFog);
            }
            else
            {
#if UNITY_2019_3_OR_NEWER
                EditorGUILayout.Space();
                m_editorUtils.Heading("HDRPSettings");
                if (m_profile.m_antiAliasingMode == GaiaConstants.GaiaProAntiAliasingMode.TAA)
                {
                    m_profile.m_antiAliasingTAAStrength = m_editorUtils.Slider("TAAStrength", m_profile.m_antiAliasingTAAStrength, 0f, 2f, helpEnabled);
                }
                m_profile.m_cameraDithering = m_editorUtils.Toggle("CameraDithering", m_profile.m_cameraDithering, helpEnabled);
                m_profile.m_cameraAperture  = m_editorUtils.Slider("CameraAperture", m_profile.m_cameraAperture, 1f, 32f, helpEnabled);
#endif
            }
        }
Exemple #5
0
        private void GlobalSettings(bool helpEnabled)
        {
            m_editorUtils.Heading("GlobalSettings");
            m_profile.EnableUnderwaterEffects = m_editorUtils.Toggle("EnableUnderwaterEffects", m_profile.EnableUnderwaterEffects, helpEnabled);
            m_profile.m_seaLevel           = m_editorUtils.FloatField("SeaLevel", m_profile.m_seaLevel, helpEnabled);
            m_profile.m_playerCamera       = (Transform)m_editorUtils.ObjectField("PlayerCamera", m_profile.m_playerCamera, typeof(Transform), helpEnabled);
            m_profile.m_startingUnderwater = m_editorUtils.Toggle("StartingUnderwater", m_profile.m_startingUnderwater, helpEnabled);
            bool transitionEnabled = m_profile.m_enableTransitionFX;

            transitionEnabled = m_editorUtils.Toggle("EnableTransitionFX", transitionEnabled, helpEnabled);
            if (m_profile.m_enableTransitionFX != transitionEnabled)
            {
                m_profile.m_enableTransitionFX = transitionEnabled;
                m_profile.SetupTransitionVFX(m_profile.m_enableTransitionFX);
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("CausticSettings");
            m_profile.m_useCaustics = m_editorUtils.Toggle("UseCaustics", m_profile.m_useCaustics, helpEnabled);
            if (m_profile.m_useCaustics)
            {
                m_profile.m_mainLight           = (Light)m_editorUtils.ObjectField("MainLight", m_profile.m_mainLight, typeof(Light), helpEnabled);
                m_profile.m_framesPerSecond     = m_editorUtils.IntField("FramesPerSecond", m_profile.m_framesPerSecond, helpEnabled);
                m_profile.m_causticSize         = m_editorUtils.Slider("CausticSize", m_profile.m_causticSize, 1f, 100f, helpEnabled);
                m_profile.m_editCausticTextures = m_editorUtils.Toggle("EditCausticTextures", m_profile.m_editCausticTextures, helpEnabled);
                if (m_profile.m_editCausticTextures)
                {
                    for (int i = 0; i < m_profile.m_causticTextures.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        m_profile.m_causticTextures[i] = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("[" + i + "]" + m_editorUtils.GetTextValue("CausticTexture"), m_editorUtils.GetTooltip("CausticTexture")), m_profile.m_causticTextures[i], typeof(Texture2D), false, GUILayout.MaxHeight(16f));
                        if (m_editorUtils.Button("Remove", GUILayout.MaxWidth(30f)))
                        {
                            m_profile.m_causticTextures.RemoveAt(i);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    if (m_editorUtils.Button("Add"))
                    {
                        m_profile.m_causticTextures.Add(null);
                    }
                }
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("FogSettings");
            m_profile.m_supportFog = m_editorUtils.Toggle("SupportFog", m_profile.m_supportFog, helpEnabled);
            if (m_profile.m_supportFog)
            {
                m_profile.m_fogColorGradient = EditorGUILayout.GradientField(new GUIContent(m_editorUtils.GetTextValue("FogColor"), m_editorUtils.GetTooltip("FogColor")), m_profile.m_fogColorGradient);
                m_editorUtils.InlineHelp("FogColor", helpEnabled);
                if (m_renderPipeline != GaiaConstants.EnvironmentRenderer.HighDefinition)
                {
                    if (RenderSettings.fogMode == FogMode.Linear)
                    {
                        m_profile.m_nearFogDistance = m_editorUtils.FloatField("FogStartDistance", m_profile.m_nearFogDistance, helpEnabled);
                        m_profile.m_fogDistance     = m_editorUtils.FloatField("FogEndDistance", m_profile.m_fogDistance, helpEnabled);
                    }
                    else
                    {
                        m_profile.m_fogDensity = m_editorUtils.Slider("FogDensity", m_profile.m_fogDensity, 0f, 1f, helpEnabled);
                    }
                }
                else
                {
                    m_profile.m_fogDistance = m_editorUtils.FloatField("FogEndDistance", m_profile.m_fogDistance, helpEnabled);
                }
            }
            EditorGUILayout.Space();

            m_editorUtils.Heading("AudioSettings");
            m_profile.m_playbackVolume      = m_editorUtils.Slider("PlaybackVolume", m_profile.m_playbackVolume, 0f, 1f, helpEnabled);
            m_profile.m_submergeSoundFXDown = (AudioClip)m_editorUtils.ObjectField("SubmergeSoundFXDown", m_profile.m_submergeSoundFXDown, typeof(AudioClip), helpEnabled);
            m_profile.m_submergeSoundFXUp   = (AudioClip)m_editorUtils.ObjectField("SubmergeSoundFXUp", m_profile.m_submergeSoundFXUp, typeof(AudioClip), helpEnabled);
            m_profile.m_underwaterSoundFX   = (AudioClip)m_editorUtils.ObjectField("UnderwaterSoundFX", m_profile.m_underwaterSoundFX, typeof(AudioClip), helpEnabled);
        }