コード例 #1
0
        public static void ConvertProfileToHDRP(SceneProfile lightingProfile, GaiaLightingProfileValues profile, bool convertToNewProfile = false)
        {
            try
            {
                if (GaiaUtils.GetActivePipeline() != GaiaConstants.EnvironmentRenderer.HighDefinition)
                {
                    Debug.Log("Need to be using High Definition render pipeline to use this function");
                    return;
                }

                GaiaLightingProfileValues profileValue = profile;
                if (convertToNewProfile)
                {
                    GaiaLightingProfileValues newProfileValues = new GaiaLightingProfileValues();
                    GaiaUtils.CopyFields(profile, newProfileValues);
                    profileValue = newProfileValues;
                    lightingProfile.m_lightingProfiles.Add(profileValue);
                    profileValue.m_typeOfLighting = "Converted HDRP Profile " + (lightingProfile.m_lightingProfiles.Count - 1);
                    lightingProfile.m_selectedLightingProfileValuesIndex = lightingProfile.m_lightingProfiles.Count - 1;
                }

                if (EditorUtility.DisplayDialog("Convert Sun", "Would you like to convert the Sun Values", "Yes", "No"))
                {
                    ConvertSun(profileValue, GaiaConstants.EnvironmentRenderer.HighDefinition);
                }

                //ConvertPWWeather(profileValue, GaiaConstants.EnvironmentRenderer.HighDefinition);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #2
0
        private void UpdateMaterial()
        {
            if (m_scanner != null)
            {
                if (m_scanner.m_previewMaterial != null)
                {
                    GaiaConstants.EnvironmentRenderer renderPipeline = GaiaUtils.GetActivePipeline();
                    Texture2D texture = m_scanner.m_previewMaterial.GetTexture("_MainTex") as Texture2D;
                    if (texture == null)
                    {
                        texture = m_scanner.m_previewMaterial.GetTexture("_BaseMap") as Texture2D;
                    }

                    switch (renderPipeline)
                    {
                    case GaiaConstants.EnvironmentRenderer.BuiltIn:
                        m_scanner.m_previewMaterial.shader = Shader.Find("Standard");
                        m_scanner.m_previewMaterial.SetTexture("_MainTex", texture);
                        break;

                    case GaiaConstants.EnvironmentRenderer.Universal:
                        m_scanner.m_previewMaterial.shader = Shader.Find("Universal Render Pipeline/Lit");
                        m_scanner.m_previewMaterial.SetTexture("_BaseMap", texture);
                        break;

                    case GaiaConstants.EnvironmentRenderer.HighDefinition:
                        m_scanner.m_previewMaterial.shader = Shader.Find("HDRP/Lit");
                        m_scanner.m_previewMaterial.SetTexture("_BaseMap", texture);
                        break;
                    }
                }
            }
        }
コード例 #3
0
 private void OnEnable()
 {
     m_renderpipeline = GaiaUtils.GetActivePipeline();
     if (m_editorUtils == null)
     {
         // Get editor utils for this
         m_editorUtils = PWApp.GetEditorUtils(this);
     }
 }
コード例 #4
0
        /// <summary>
        /// Function used to rebuild buffers
        /// </summary>
        public void RebuildBuffers(bool clear = true)
        {
            RenderPipeline = GaiaUtils.GetActivePipeline();
            if (clear)
            {
                ClearBuffers();
            }

            StartBuffers();
        }
コード例 #5
0
 public override void OnInspectorGUI()
 {
     if (GaiaUtils.GetActivePipeline() == GaiaConstants.EnvironmentRenderer.BuiltIn)
     {
         EditorGUILayout.HelpBox("This is the auto depth of field system for Gaia. To edit or remove please go to Gaia Player under Gaia Runtime", MessageType.Info);
     }
     else
     {
         EditorGUILayout.HelpBox("Auto Depth Of Field is not yet supported for SRP this will be available in a near future update", MessageType.Info);
     }
 }
コード例 #6
0
        private void OnEnable()
        {
            //Get Profile object
            m_profile = (GaiaUnderwaterEffects)target;
            if (m_editorUtils == null)
            {
                // Get editor utils for this
                m_editorUtils = PWApp.GetEditorUtils(this);
            }

            m_renderPipeline = GaiaUtils.GetActivePipeline();
        }
コード例 #7
0
 private void SetPostProcessing(GaiaLightingProfileValues profile)
 {
     if (m_gaiaSettings.m_currentRenderer == GaiaConstants.EnvironmentRenderer.BuiltIn)
     {
         if (m_profile.m_setupPostFX)
         {
             if (profile != null)
             {
                 GaiaLighting.SetupPostProcessing(profile, m_profile, GaiaUtils.GetActivePipeline(), true);
             }
         }
     }
 }
コード例 #8
0
        private void GlobalSettings(bool helpEnabled)
        {
            if (GaiaGlobal.Instance.SceneProfile.m_lightingProfiles.Count > 0)
            {
                if (m_profile.m_selectedLightingProfileValuesIndex != -99)
                {
                    profile = GaiaGlobal.Instance.SceneProfile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
                }
            }

            if (m_gaiaSettings.m_currentRenderer == GaiaConstants.EnvironmentRenderer.BuiltIn)
            {
                bool postfx = m_profile.m_setupPostFX;
                m_profile.m_setupPostFX = m_editorUtils.Toggle("SetupPostFX", m_profile.m_setupPostFX, helpEnabled);
                if (postfx != m_profile.m_setupPostFX)
                {
                    if (m_profile.m_setupPostFX)
                    {
                        if (profile != null)
                        {
                            GaiaLighting.SetupPostProcessing(profile, m_profile, GaiaUtils.GetActivePipeline(), true);
                        }
                    }
                    else
                    {
                        GaiaLighting.RemoveAllPostProcessV2CameraLayer();
                    }
                }
            }
            m_profile.m_spawnPlayerAtCurrentLocation = m_editorUtils.Toggle("SpawnPlayerAtCurrentLocation", m_profile.m_spawnPlayerAtCurrentLocation, helpEnabled);

            GaiaConstants.EnvironmentControllerType controller = m_profile.m_controllerType;
            controller = (GaiaConstants.EnvironmentControllerType)m_editorUtils.EnumPopup("ControllerType", controller, helpEnabled);
            if (controller != m_profile.m_controllerType)
            {
                m_gaiaSettings.m_currentController = controller;
                switch (controller)
                {
                case GaiaConstants.EnvironmentControllerType.FirstPerson:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFirstPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.FlyingCamera:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFlyCamName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.ThirdPerson:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerThirdPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.Car:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.m_carPlayerPrefabName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.XRController:
#if GAIA_XR
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "XRController", m_profile.m_spawnPlayerAtCurrentLocation);
#else
                    EditorUtility.DisplayDialog("XR Support not enabled", "The XR Controller is a default player for Virtual / Augmented Reality projects. Please open the Setup Panel in the Gaia Manager Standard Tab to enable XR Support in order to use the XR Player Controller. Please also make sure you have the Unity XR Interaction Toolkit package installed before doing so.", "OK");
                    controller = GaiaConstants.EnvironmentControllerType.FlyingCamera;
                    m_gaiaSettings.m_currentController = GaiaConstants.EnvironmentControllerType.FlyingCamera;
#endif
                    break;
                }

                SetPostProcessing(profile);
#if GAIA_PRO_PRESENT
                if (GaiaUtils.HasDynamicLoadedTerrains())
                {
                    TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren <TerrainLoader>();
                    if (tl != null)
                    {
                        m_profile.UpdateTerrainLoaderFromProfile(ref tl);
                    }
                }
#endif
                m_profile.m_controllerType = controller;
            }

            if (controller == GaiaConstants.EnvironmentControllerType.Custom)
            {
                m_profile.m_customPlayer = (GameObject)m_editorUtils.ObjectField("MainPlayer", m_profile.m_customPlayer, typeof(GameObject), true, helpEnabled);
                m_profile.m_customCamera = (Camera)m_editorUtils.ObjectField("MainCamera", m_profile.m_customCamera, typeof(Camera), true, helpEnabled);

                if (m_editorUtils.Button("ApplySetup"))
                {
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "Custom", m_profile.m_spawnPlayerAtCurrentLocation, m_profile.m_customPlayer, m_profile.m_customCamera, true);
                    SetPostProcessing(profile);
#if GAIA_PRO_PRESENT
                    if (GaiaUtils.HasDynamicLoadedTerrains())
                    {
                        TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren <TerrainLoader>();
                        if (tl != null)
                        {
                            m_profile.UpdateTerrainLoaderFromProfile(ref tl);
                        }
                    }
#endif
                }
            }

            EditorGUILayout.BeginHorizontal();

            if (m_editorUtils.Button("MoveCameraToPlayer"))
            {
                GaiaSceneManagement.MoveCameraToPlayer(m_gaiaSettings);
            }

            if (m_editorUtils.Button("MovePlayerToCamera"))
            {
                GaiaSceneManagement.MovePlayerToCamera(m_gaiaSettings);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            m_editorUtils.Panel("AutoDepthOfFieldSettings", AutoDepthOfField);
            m_editorUtils.Panel("LocationManagerSettings", LocationManagerSettings);
            m_editorUtils.Panel("PlayerCameraCullingSettings", CameraCullingSettings);
            if (GaiaUtils.HasDynamicLoadedTerrains())
            {
                m_editorUtils.Panel("TerrainLoadingSettings", TerrainLoadingSettings);
            }
        }
コード例 #9
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
        }
コード例 #10
0
        private void Start()
        {
            RenderPipeline = GaiaUtils.GetActivePipeline();
            m_instance     = this;

#if GAIA_PRO_PRESENT
            m_weatherSystemExists = ProceduralWorldsGlobalWeather.Instance;
#endif
            if (PWS_WaterSystem.Instance != null)
            {
                m_seaLevel = PWS_WaterSystem.Instance.SeaLevel;
            }

            if (m_playerCamera == null)
            {
                if (Camera.main != null)
                {
                    m_playerCamera = Camera.main.transform;
                }
            }
            if (m_playerCamera != null)
            {
                if (m_playerCamera.position.y > m_seaLevel)
                {
                    m_startingUnderwater = false;
                }
                else
                {
                    m_startingUnderwater = true;
                }
            }

            if (m_underwaterMaterial == null)
            {
                m_underwaterMaterial = GaiaUtils.GetWaterMaterial(GaiaConstants.waterSurfaceObject, true);
            }

            if (m_mainLight == null)
            {
                m_mainLight = GaiaUtils.GetMainDirectionalLight();
            }

            if (m_audioSource == null)
            {
                m_audioSource = GetAudioSource();
            }

            if (m_audioSourceUnderwater == null)
            {
                m_audioSourceUnderwater = GetAudioSource();
            }

            if (Application.isPlaying)
            {
                if (m_underwaterPostFX != null)
                {
                    m_underwaterPostFX.SetActive(true);
                }

                if (m_underwaterTransitionPostFX != null)
                {
                    m_underwaterTransitionPostFX.SetActive(true);
                }
            }

            if (m_audioSourceUnderwater != null)
            {
                m_audioSourceUnderwater.clip   = m_underwaterSoundFX;
                m_audioSourceUnderwater.loop   = true;
                m_audioSourceUnderwater.volume = m_playbackVolume;
                m_audioSourceUnderwater.Stop();
            }

            if (m_underwaterParticles != null)
            {
                m_underwaterParticleSystem = m_underwaterParticles.GetComponent <ParticleSystem>();
                if (m_underwaterParticleSystem != null)
                {
                    m_underwaterParticleSystem.Stop();
                }

                m_underwaterParticles.SetActive(false);
            }

            if (m_horizonObject != null)
            {
                m_horizonObject.SetActive(true);
                MeshRenderer[] meshRenders = m_horizonObject.GetComponentsInChildren <MeshRenderer>();
                foreach (MeshRenderer render in meshRenders)
                {
                    m_horizonMeshRenders.Add(render);
                    render.enabled = false;
                }
            }

            UpdateSurfaceFogSettings();
            if (m_startingUnderwater)
            {
                IsUnderwater      = SetupWaterSystems(true, m_startingUnderwater);
                m_underwaterSetup = true;
                m_surfaceSetup    = false;
            }
            else
            {
                m_underwaterSetup = true;
                m_surfaceSetup    = false;
            }
        }