示例#1
0
        /// <summary>
        /// Creates a default Gradient
        /// </summary>
        /// <returns></returns>
        private Gradient CreateGradient()
        {
            Gradient gradient = new Gradient();

            // Populate the color keys at the relative time 0 and 1 (0 and 100%)
            GradientColorKey[] colorKey = new GradientColorKey[3];
            colorKey[0].color = GaiaUtils.GetColorFromHTML("0C233A");
            colorKey[0].time  = 0.0f;
            colorKey[1].color = GaiaUtils.GetColorFromHTML("5686BC");
            colorKey[1].time  = 0.5f;
            colorKey[2].color = GaiaUtils.GetColorFromHTML("5C9BE0");
            colorKey[2].time  = 1f;

            // Populate the alpha  keys at relative time 0 and 1  (0 and 100%)
            GradientAlphaKey[] alphaKey = new GradientAlphaKey[3];
            alphaKey[0].alpha = 1.0f;
            alphaKey[0].time  = 0.0f;
            alphaKey[1].alpha = 1.0f;
            alphaKey[1].time  = 0.5f;
            alphaKey[2].alpha = 1.0f;
            alphaKey[2].time  = 1.0f;

            gradient.SetKeys(colorKey, alphaKey);

            return(gradient);
        }
        /// <summary>
        /// Associate any unallocated assets to this resource. Return true if something changes.
        /// </summary>
        /// <returns>True if the prototype was in some way modified</returns>
        public bool AssociateAssets()
        {
            bool isModified = false;

            #if UNITY_EDITOR
            if (m_desktopPrefab == null)
            {
                if (!string.IsNullOrEmpty(m_desktopPrefabFileName))
                {
                    m_desktopPrefab = GaiaUtils.GetAsset(m_desktopPrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
                    if (m_desktopPrefab != null)
                    {
                        isModified = true;
                    }
                }
            }

            if (m_mobilePrefab == null)
            {
                if (!string.IsNullOrEmpty(m_mobilePrefabFileName))
                {
                    m_mobilePrefab = GaiaUtils.GetAsset(m_mobilePrefabFileName, typeof(UnityEngine.GameObject)) as GameObject;
                    if (m_mobilePrefab != null)
                    {
                        isModified = true;
                    }
                }
            }
            #endif
            return(isModified);
        }
示例#3
0
        public static Stamper GetOrCreateSyncedStamper(string stamperName)
        {
            Stamper stamper = null;

            //No stamper passed in, does a session Stamper exist?
            if (stamper == null)
            {
                GameObject stamperObj = GameObject.Find(stamperName);
                if (stamperObj == null)
                {
                    GameObject wmeTempTools = GaiaUtils.GetOrCreateWorldMapTempTools();
                    stamperObj = new GameObject(stamperName);
                    stamperObj.transform.parent = wmeTempTools.transform;
                }
                if (stamperObj.GetComponent <Stamper>() == null)
                {
                    stamper = stamperObj.AddComponent <Stamper>();
#if GAIA_PRO_PRESENT
                    if (GaiaUtils.HasDynamicLoadedTerrains())
                    {
                        //We got placeholders, activate terrain loading
                        stamper.m_loadTerrainMode = LoadMode.EditorSelected;
                    }
#endif
                }
                stamper = stamperObj.GetComponent <Stamper>();
            }

            return(stamper);
        }
示例#4
0
        public static void Stop(bool outputData = true)
        {
#if GAIA_DEBUG
            if (!m_stopwatch.IsRunning || !m_isEnabled)
            {
                return;
            }

            //end any running events
            foreach (GaiaStopWatchEvent stopWatchEvent in m_events.FindAll(x => x.m_started == true))
            {
                EndEvent(stopWatchEvent.m_name);
            }
            m_currentEvent   = null;
            m_lastLogElapsed = 0;
            m_stopwatch.Stop();
            m_isEnabled = false;
            LogWithTime("Stopping the Gaia Stopwatch Log.");
            if (outputData)
            {
                GameObject parentGO            = GaiaUtils.GetStopwatchDataObject();
                GameObject stopWatchDataObject = new GameObject(string.Format("Gaia Stopwatch Run {0:yyyy-MM-dd--HH-mm-ss}", DateTime.Now));
                stopWatchDataObject.transform.parent = parentGO.transform;
                GaiaStopwatchDataset newDataset = stopWatchDataObject.AddComponent <GaiaStopwatchDataset>();
                newDataset.m_events = m_events;
            }
#endif
        }
        public void LoadCaustics()
        {
            #if UNITY_EDITOR
            m_cookies     = new Texture2D[16];
            m_cookies[0]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_001.tif"));
            m_cookies[1]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_002.tif"));
            m_cookies[2]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_003.tif"));
            m_cookies[3]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_004.tif"));
            m_cookies[4]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_005.tif"));
            m_cookies[5]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_006.tif"));
            m_cookies[6]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_007.tif"));
            m_cookies[7]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_008.tif"));
            m_cookies[8]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_009.tif"));
            m_cookies[9]  = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_010.tif"));
            m_cookies[10] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_011.tif"));
            m_cookies[11] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_012.tif"));
            m_cookies[12] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_013.tif"));
            m_cookies[13] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_014.tif"));
            m_cookies[14] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_015.tif"));
            m_cookies[15] = AssetDatabase.LoadAssetAtPath <Texture2D>(GaiaUtils.GetAssetPath("CausticsRender_016.tif"));

            m_submergeSoundFXDown     = AssetDatabase.LoadAssetAtPath <AudioClip>(GaiaUtils.GetAssetPath("Gaia Ambient Submerge Down.mp3"));
            m_submergeSoundFXUp       = AssetDatabase.LoadAssetAtPath <AudioClip>(GaiaUtils.GetAssetPath("Gaia Ambient Submerge Up.mp3"));
            underwaterParticlesStored = AssetDatabase.LoadAssetAtPath <GameObject>(GaiaUtils.GetAssetPath("Underwater Particles Effects.prefab"));
            horizonObjectStored       = AssetDatabase.LoadAssetAtPath <GameObject>(GaiaUtils.GetAssetPath("Ambient Underwater Horizon.prefab"));
            #endif
        }
示例#6
0
        private void RealtimeUpdateEnabled(bool helpEnabled)
        {
            m_profile.m_updateInRealtime = m_editorUtils.ToggleLeft("UpdateChangesInRealtime", m_profile.m_updateInRealtime, helpEnabled);
            if (m_profile.m_updateInRealtime)
            {
                EditorGUILayout.HelpBox("Update In Realtime is enabled this will allow profiles to be endited inside the editor and automatically apply changes every frame. This feature can be expensive and should not be left enabled in testing and builds", MessageType.Warning);
            }
            else
            {
                if (m_editorUtils.Button("UpdateToScene"))
                {
                    if (m_profile.m_selectedLightingProfileValuesIndex != -99)
                    {
                        GaiaUtils.GetRuntimeSceneObject();

                        if (GaiaGlobal.Instance != null)
                        {
                            //GaiaLighting.GetProfile(m_profile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
                            EditorUtility.SetDirty(m_profile);
                        }
                    }
                }

                m_editorUtils.InlineHelp("UpdateToScene", helpEnabled);

                if (m_editorUtils.Button("UpdateDynamicGI"))
                {
                    GaiaLighting.UpdateAmbientEnvironment();
                }

                m_editorUtils.InlineHelp("UpdateDynamicGI", helpEnabled);
            }
        }
示例#7
0
        /// <summary>
        /// Adds a new user profile
        /// </summary>
        private void AddNewCustomProfile()
        {
            //GaiaLightingProfileValues selectdValues = m_savedSettings.LoadSettings(m_profile, true);
            GaiaLightingProfileValues selectdValues = m_profileValues;
            GaiaLightingProfileValues newProfile    = new GaiaLightingProfileValues();

            GaiaUtils.CopyFields(selectdValues, newProfile);
            int count = m_profile.m_lightingProfiles.Count + 1;

            newProfile.m_typeOfLighting    = "New User Profile " + count;
            newProfile.m_userCustomProfile = true;
            m_profile.m_lightingProfiles.Add(newProfile);
            m_profile.m_selectedLightingProfileValuesIndex = m_profile.m_lightingProfiles.Count - 1;

            if (m_profile.m_selectedLightingProfileValuesIndex != -99)
            {
                GaiaUtils.GetRuntimeSceneObject();

                if (GaiaGlobal.Instance != null)
                {
                    GaiaLighting.GetProfile(m_profile, m_gaiaSettings.m_pipelineProfile, m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled);
                }
            }

            EditorUtility.SetDirty(m_profile);
        }
示例#8
0
        public override void OnInspectorGUI()
        {
            if (redStyle == null || redStyle.normal.background == null || greenStyle == null || greenStyle.normal.background == null)
            {
                redStyle = new GUIStyle();
                redStyle.normal.background = GaiaUtils.GetBGTexture(Color.red, m_tempTextureList);

                greenStyle = new GUIStyle();
                greenStyle.normal.background = GaiaUtils.GetBGTexture(Color.green, m_tempTextureList);
            }


            //Init editor utils
            if (m_editorUtils == null)
            {
                // Get editor utils for this
                m_editorUtils = PWApp.GetEditorUtils(this);
            }
            m_editorUtils.Initialize(); // Do not remove this!
            if (GaiaUtils.HasDynamicLoadedTerrains())
            {
                m_editorUtils.Panel("GeneralSettings", DrawGeneralSettings, true);
                m_editorUtils.Panel("LoaderPanel", DrawLoaders, false);
                m_editorUtils.Panel("PlaceholderPanel", DrawTerrains, false);
            }
            else
            {
                EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoTerrainLoadingMessage"), MessageType.Info);
            }
        }
示例#9
0
        public override void OnInspectorGUI()
        {
            if (dropdownGUIStyle == null)
            {
                dropdownGUIStyle = new GUIStyle(EditorStyles.popup)
                {
                    fixedHeight = 16f, margin = new RectOffset(0, 0, 4, 0)
                };
            }

            if (m_profile != null)
            {
                Transform transform = m_profile.gameObject.transform;
                transform.hideFlags = HideFlags.HideInInspector | HideFlags.NotEditable;
                if (m_profile.m_mainCamera == null)
                {
                    m_profile.m_mainCamera = GaiaUtils.GetCamera();
                }
            }

            //Initialization
            m_editorUtils.Initialize(); // Do not remove this!
            if (m_gaiaSettings == null)
            {
                m_gaiaSettings = GaiaUtils.GetGaiaSettings();
            }

            m_editorUtils.Panel("GlobalSettings", GlobalSettingsPanel, false, true, true);
        }
示例#10
0
//        public static void ShowWorldBiomeMasksSpawner()
//        {

//            Terrain worldMapTerrain = TerrainHelper.GetWorldMapTerrain();

//            if (worldMapTerrain == null)
//            {
//                Debug.LogError("No world map created yet! Please create a world map first before opening the Biome Masks setup!");
//                return;
//            }

//            GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(false);

//            //Get the Gaia Settings
//            GaiaSettings settings = GaiaUtils.GetGaiaSettings();

//            //Create or find the stamper
//            GameObject spawnerObj = GameObject.Find(GaiaConstants.worldBiomeMasks);
//            if (spawnerObj == null)
//            {
//                spawnerObj = new GameObject(GaiaConstants.worldBiomeMasks);
//                GameObject worldMapObj = GaiaUtils.GetOrCreateWorldDesigner();
//                spawnerObj.transform.parent = worldMapObj.transform;
//                Spawner spawner = spawnerObj.AddComponent<WorldBiomeMasks>();
//                //Existing settings for world mask biomes in session? -> Take those!
//                if (gsm.m_session.m_worldBiomeMaskSettings != null)
//                {
//                    spawner.LoadSettings(gsm.m_session.m_worldBiomeMaskSettings);
//                }
//                else
//                {
//                    //No session settings? Use default setup from Gaia settings then
//                    if (settings != null)
//                    {
//                        if (settings.m_defaultBiomeMaskSettings != null)
//                        {
//                            spawner.LoadSettings(settings.m_defaultBiomeMaskSettings);
//                        }
//                    }
//                }
//                spawner.m_settings.m_isWorldmapSpawner = true;
//                spawner.m_settings.m_worldmapSpawnerType = WorldmapSpawnerType.WorldBiomeMasks;
//                spawner.m_worldMapTerrain = worldMapTerrain;
//                spawner.FitToTerrain();
//                spawner.UpdateMinMaxHeight();
//                gsm.m_session.m_worldBiomeMaskSettings = spawner.m_settings;
//            }
//            else
//            {
//                Spawner spawner = spawnerObj.GetComponent<Spawner>();
//                spawner.m_settings.m_isWorldmapSpawner = true;
//                spawner.m_worldMapTerrain = worldMapTerrain;
//                spawner.FitToTerrain();
//                spawner.UpdateMinMaxHeight();
//                gsm.m_session.m_worldBiomeMaskSettings = spawner.m_settings;
//            }

//            gsm.SwitchToWorldMap();
//#if UNITY_EDITOR
//            Selection.activeGameObject = spawnerObj;
//#endif
//        }


        public static GameObject GetOrCreateWorldMapStamper()
        {
            //Create or find the stamper
            GameObject stamperObj = GameObject.Find(GaiaConstants.worldMapStamper);

            if (stamperObj == null)
            {
                stamperObj = new GameObject(GaiaConstants.worldMapStamper);
                GameObject worldMapObj = GaiaUtils.GetOrCreateWorldDesigner();
                stamperObj.transform.parent = worldMapObj.transform;
                Stamper stamper = stamperObj.AddComponent <Stamper>();
                stamper.m_settings = ScriptableObject.CreateInstance <StamperSettings>();
                stamper.m_settings.m_isWorldmapStamper = true;
                stamper.m_recordUndo = false;
                stamper.UpdateMinMaxHeight();
                //stamper.m_seaLevel = m_settings.m_currentDefaults.m_seaLevel;
                stamper.FitToTerrain();
            }
            else
            {
                Stamper stamper = stamperObj.GetComponent <Stamper>();
                stamper.m_settings.m_isWorldmapStamper = true;
                stamper.m_recordUndo = false;
                stamper.UpdateMinMaxHeight();
                //stamper.m_seaLevel = m_settings.m_currentDefaults.m_seaLevel;
                stamper.FitToTerrain();
            }
            Terrain worldMapTerrain = TerrainHelper.GetWorldMapTerrain();

            if (worldMapTerrain != null)
            {
                stamperObj.transform.position = worldMapTerrain.transform.position + worldMapTerrain.terrainData.size / 2f;
            }
            return(stamperObj);
        }
示例#11
0
        public override void OnInspectorGUI()
        {
            //Initialization
            m_editorUtils.Initialize(); // Do not remove this!

            if (m_profile != null)
            {
                //Monitor for changes
                EditorGUI.BeginChangeCheck();

                if (m_gaiaSettings == null)
                {
                    m_gaiaSettings = GaiaUtils.GetGaiaSettings();
                }

                m_editorUtils.Panel("GlobalSettings", GlobalSettings, false, true, true);

                //Check for changes, make undo record, make changes and let editor know we are dirty
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(m_profile, "Made changes");
                    EditorUtility.SetDirty(m_profile);
                }
            }
            else
            {
                if (GaiaGlobal.Instance != null)
                {
                    m_profile = GaiaGlobal.Instance.SceneProfile;
                }
            }
        }
示例#12
0
        public void OnWorldMapCreate()
        {
            m_worldMapTerrain = TerrainHelper.GetWorldMapTerrain();
            GaiaSettings gaiaSettings    = GaiaUtils.GetGaiaSettings();
            GaiaDefaults currentDefaults = gaiaSettings.m_currentDefaults;

            TerrainLoaderManager.Instance.TerrainSceneStorage.m_hasWorldMap = true;

            float worldheightmapRes = m_worldMapTerrain.terrainData.heightmapResolution / m_worldMapTerrain.terrainData.size.x;

            BoundsDouble bounds = new BoundsDouble();

            TerrainHelper.GetTerrainBounds(ref bounds);
            if (bounds.size.x > 0)
            {
                TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMaprelativeSize            = (float)m_currentWorldCreationSettings.m_tileSize / (float)bounds.size.x;
                TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMapRelativeHeightmapPixels = (((float)bounds.size.x / m_localTileSize) * m_localHeightmapRes / m_localHeightmapRes);
            }
            else
            {
                //no bounds size means no real terrains (yet) - set these parameters according to the current settings/defaults then
                TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMaprelativeSize            = (float)m_currentWorldCreationSettings.m_tileSize / (gaiaSettings.m_tilesX * currentDefaults.m_terrainSize);
                TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMapRelativeHeightmapPixels = ((gaiaSettings.m_tilesX * currentDefaults.m_terrainSize) / currentDefaults.m_terrainSize) * currentDefaults.m_heightmapResolution / currentDefaults.m_heightmapResolution;
            }
            SyncLocalMapToWorldMap();
            ShowWorldMapStampSpawner();
            GaiaSessionManager.OnWorldCreated -= OnWorldMapCreate;
        }
示例#13
0
 /// <summary>
 /// On Start find camera
 /// </summary>
 private void Start()
 {
     if (m_mainCamera == null)
     {
         m_mainCamera = GaiaUtils.GetCamera(true);
     }
 }
示例#14
0
        private void OnEnable()
        {
            m_instance = this;
            if (m_mainLight == null)
            {
                m_mainLight = GaiaUtils.GetMainDirectionalLight();
            }

            if (m_audioSource != null)
            {
                m_audioSource.playOnAwake = false;
            }

            if (m_audioSourceUnderwater != null)
            {
                m_audioSourceUnderwater.playOnAwake = false;
            }

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

            SetupTransitionVFX(m_enableTransitionFX);
        }
示例#15
0
        /// <summary>
        /// Associate any unallocated assets to this resource. Return true if something changes.
        /// </summary>
        /// <returns>True if the prototype was in some way modified</returns>
        public bool AssociateAssets()
        {
            bool isModified = false;

            #if UNITY_EDITOR
            if (m_detailProtoype == null)
            {
                if (!string.IsNullOrEmpty(m_detailPrototypeFileName))
                {
                    m_detailProtoype = GaiaUtils.GetAsset(m_detailPrototypeFileName, typeof(UnityEngine.GameObject)) as GameObject;
                    if (m_detailProtoype != null)
                    {
                        isModified = true;
                    }
                }
            }

            if (m_detailTexture == null)
            {
                if (!string.IsNullOrEmpty(m_detailTextureFileName))
                {
                    m_detailTexture = GaiaUtils.GetAsset(m_detailTextureFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
                    if (m_detailTexture != null)
                    {
                        isModified = true;
                    }
                }
            }
            #endif

            return(isModified);
        }
示例#16
0
        /// <summary>
        /// Returns the Gaia Session Directory. Will create it if it does not exist.
        /// </summary>
        /// <returns>The path to the Gaia Session directory</returns>
        public static string GetSessionDirectory()
        {
            GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();

            Directory.CreateDirectory(gaiaSettings.m_sessionsDirectory);
            return(gaiaSettings.m_sessionsDirectory);
        }
        /// <summary>
        /// Saves a unity terrain layer as asset file and returns a reference to the newly created Terrain Layerfile.
        /// </summary>
        /// <param name="terrainName">The name of the current Gaia terrain (for the filename).</param>
        /// <param name="layerId">The layer ID of the layer that is to be saved (for the filename).</param>
        /// <param name="terrainLayer">The terrain layer object to save.</param>
        /// <returns>Reference to the created TerrainLayer</returns>
        private static TerrainLayer SaveTerrainLayerAsAsset(string terrainName, string layerId, TerrainLayer terrainLayer)
        {
#if UNITY_EDITOR
            GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings();

            if (gaiaSettings.m_currentTerrainLayerStoragePath == "")
            {
                Debug.LogError("Current Terrain Layer Storage Path is empty, please check the Gaia Settings file!");
                return(null);
            }


            Directory.CreateDirectory(gaiaSettings.m_currentTerrainLayerStoragePath);

            //The combination of terrain name and layer id should be unique enough so that users don't overwrite layers between terrains.
            string path = gaiaSettings.m_currentTerrainLayerStoragePath + "/" + terrainName + "_" + layerId + ".asset";

            AssetDatabase.CreateAsset(terrainLayer, path);
            AssetDatabase.SaveAssets();

            return(AssetDatabase.LoadAssetAtPath <TerrainLayer>(path));
#else
            Debug.LogError("Runtime Gaia operation is not supported");
            return(new TerrainLayer());
#endif
        }
示例#18
0
        public override void OnInspectorGUI()
        {
            m_profile.gameObject.name = "Post Processing Converter";

#if UNITY_POST_PROCESSING_STACK_V2
            EditorGUILayout.HelpBox("This only support from Built-In to URP/HDRP conversions only", MessageType.Info);

            EditorGUILayout.LabelField("Setup", EditorStyles.boldLabel);
            m_profile.RenderPipeline = (GaiaConstants.EnvironmentRenderer)EditorGUILayout.EnumPopup("Selected Pipeline", m_profile.RenderPipeline);
            m_profile.ProcessProfile = (UnityEngine.Rendering.PostProcessing.PostProcessProfile)EditorGUILayout.ObjectField("Post Processing Profile", m_profile.ProcessProfile, typeof(UnityEngine.Rendering.PostProcessing.PostProcessProfile), false);
            EditorGUILayout.BeginHorizontal();
            m_profile.SavePath = EditorGUILayout.TextField("Save Path", m_profile.SavePath);
            if (GUILayout.Button("Selected Folder", GUILayout.MaxWidth(110f)))
            {
                string newPath = EditorUtility.SaveFolderPanel("Save Path", Application.dataPath, "");
                m_profile.SavePath = newPath;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField("Converting from Built-In to " + m_profile.RenderPipeline);
            if (GUILayout.Button("Convert Profile"))
            {
#if HDPipeline || UPPipeline
                GaiaUtils.CreateURPOrHDRPPostProcessing(m_profile.RenderPipeline, m_profile.ProcessProfile, m_profile.SavePath);
#endif
            }
#else
            EditorGUILayout.HelpBox("Post Processing V2 is not installed. To use this feature you need to install post processing v2 fromt he package manager. This only support from Built-In to URP/HDRP conversions only", MessageType.Info);
#endif
        }
示例#19
0
        public void OnEnable()
        {
            //Get Gaia Lighting Profile object
            m_profile = (GaiaLightingProfile)target;

            if (m_editorUtils == null)
            {
                // Get editor utils for this
                m_editorUtils = PWApp.GetEditorUtils(this);
            }

            if (m_gaiaSettings == null)
            {
                m_gaiaSettings = GaiaUtils.GetGaiaSettings();
            }

            m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled;
            m_version        = PWApp.CONF.Version;

            if (m_profile != null)
            {
                m_profileValues = m_profile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
            }

            enableEditMode = System.IO.Directory.Exists(GaiaUtils.GetAssetPath("Dev Utilities"));
        }
示例#20
0
        /// <summary>
        /// Starting function setup
        /// </summary>
        void Start()
        {
            storedColor = m_uiTextColor;

            if (m_textContent != null)
            {
                m_textContent.color = storedColor;

#if UNITY_EDITOR
                if (!m_textContent.text.Contains("Open the Location Manager"))
                {
                    string locationProfilePath = GaiaUtils.GetAssetPath("Location Profile.asset");
                    if (!string.IsNullOrEmpty(locationProfilePath))
                    {
                        LocationSystemScriptableObject locationProfile = AssetDatabase.LoadAssetAtPath <LocationSystemScriptableObject>(locationProfilePath);
                        if (locationProfile != null)
                        {
                            m_textContent.text += "\r\n\r\nOpen the Location Manager from the Advanced Tab in the Gaia Manager to bookmark interesting locations:\r\n";
                            m_textContent.text += string.Format("{0} + {1} (new bookmark), {0} + {2} / {3} (cycle bookmarks)", locationProfile.m_mainKey.ToString(), locationProfile.m_addBookmarkKey.ToString(), locationProfile.m_prevBookmark.ToString(), locationProfile.m_nextBookmark.ToString());
                            m_textContent.text += "\r\n\r\n";
                        }
                    }
                }
#endif
            }
        }
示例#21
0
        public void UpdateShadow()
        {
            //Shadows
            m_shadowLayerDistances = new float[32];
            for (int i = 0; i < m_shadowLayerDistances.Length; i++)
            {
                string layerName = LayerMask.LayerToName(i);
                switch (layerName)
                {
                case "Default":
                case "Water":
                case "PW_VFX":
                    m_shadowLayerDistances[i] = 0f;
                    break;

                case "PW_Object_Small":
                    m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Small, QualitySettings.shadowDistance, 0f, 0f, 5f);
                    break;

                case "PW_Object_Medium":
                    m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Medium, QualitySettings.shadowDistance, 0f, 3f, 0f);
                    break;

                case "PW_Object_Large":
                    m_shadowLayerDistances[i] = GaiaUtils.CalculateShadowCullingLayerValue(ShadowCullingType.Large, QualitySettings.shadowDistance, 1f, 0f, 0f);
                    break;

                default:
                    m_shadowLayerDistances[i] = 0f;
                    break;
                }
            }
        }
示例#22
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;
                    }
                }
            }
        }
示例#23
0
        /// <summary>
        /// Returns terrain names of terrains that intersect with the given bounds object
        /// </summary>
        /// <param name="bounds">A bounds object to check against the terrains. Needs to be in absolute world space position, mind the current origin offset!</param>
        /// <returns></returns>
        public static string[] GetTerrainsIntersectingBounds(BoundsDouble bounds)
        {
            //Reduce the bounds size a bit to prevent selecting terrains that are perfectly aligned with the bounds border
            //-this leads to too many terrains being logged as affected by an operation otherwise.
            Bounds intersectingBounds = new BoundsDouble();

            intersectingBounds.center = bounds.center;
            intersectingBounds.size   = bounds.size - new Vector3Double(0.001f, 0.001f, 0.001f);

            if (GaiaUtils.HasDynamicLoadedTerrains())
            {
                GaiaSessionManager sessionManager = GaiaSessionManager.GetSessionManager();
                if (sessionManager == null)
                {
                    Debug.LogError("Trying to get terrains that intersect with bounds, but there is no session manager in scene.");
                    return(null);
                }
                return(TerrainLoaderManager.TerrainScenes.Where(x => x.m_bounds.Intersects(intersectingBounds)).Select(x => x.GetTerrainName()).ToArray());
            }
            else
            {
                List <string> affectedTerrainNames = new List <string>();
                foreach (Terrain t in Terrain.activeTerrains)
                {
                    if (intersectingBounds.Intersects(TerrainHelper.GetWorldSpaceBounds(t)))
                    {
                        affectedTerrainNames.Add(t.name);
                    }
                }
                return(affectedTerrainNames.ToArray());
            }
        }
示例#24
0
 public void OverrideBookmark(LocationSystem locationSystem)
 {
     if (locationSystem != null)
     {
         GaiaUtils.CopyFields(GetCurrentLocation(locationSystem), m_bookmarkedSettings[locationSystem.m_selectedBookmark]);
     }
 }
        /// <summary>
        /// Start setup
        /// </summary>
        private void Start()
        {
            if (m_gaiaSettings == null)
            {
                m_gaiaSettings = GaiaUtils.GetGaiaSettings();
            }
            if (m_planarReflectionProbe == null)
            {
                m_planarReflectionProbe = FindObjectOfType <PlanarReflectionProbe>();
            }
            if (m_player == null)
            {
                m_player = GetThePlayer();
            }

            if (m_planarReflectionProbe != null)
            {
                OptimizePlanarReflections(m_planarReflectionProbe);
                #if UNITY_2019_1_OR_NEWER
                m_planarReflectionProbe.RequestRenderNextUpdate();
                #else
                m_planarReflectionProbe.RequestRealtimeRender();
#endif
            }
        }
示例#26
0
 private void Awake()
 {
     if (m_mainCamera == null)
     {
         m_mainCamera = GaiaUtils.GetCamera();
     }
 }
示例#27
0
        /// <summary>
        /// Clears reflection probes created
        /// </summary>
        public static void ClearCreatedReflectionProbes()
        {
            GameObject oldReflectionProbe = GameObject.Find("Global Reflection Probe");

            if (oldReflectionProbe != null)
            {
                UnityEngine.Object.DestroyImmediate(oldReflectionProbe);
                Debug.Log("Old Reflection Probe Destroyed");
            }

            if (GaiaUtils.HasDynamicLoadedTerrains())
            {
                Action <Terrain> terrAction = (t) => DeleteProbeGroup(t);
                GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Clearning Reflection Probes");
            }
            else
            {
                if (Terrain.activeTerrains.Length < 1)
                {
                    Debug.LogError("No terrains we're found, unable to generate reflection probes.");
                }
                else
                {
                    foreach (var activeTerrain in Terrain.activeTerrains)
                    {
                        DeleteProbeGroup(activeTerrain);
                    }
                }
            }
        }
示例#28
0
        private void Start()
        {
            m_instance     = this;
            WeatherPresent = CheckWeatherPresent();
            UpdateGaiaTimeOfDay(false);

            if (m_sunLight == null)
            {
                m_sunLight = GaiaUtils.GetMainDirectionalLight();
            }
            if (m_sunLight != null)
            {
                m_sunLightExists = true;
            }

            if (m_moonLight == null)
            {
                GameObject moonObject = GameObject.Find("Moon Light");
                if (moonObject != null)
                {
                    m_moonLight = moonObject.GetComponent <Light>();
                }
            }
#if GAIA_PRO_PRESENT
            if (m_moonLight != null)
            {
                m_moonLightExists = true;
            }
#endif
        }
示例#29
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;
            }
        }
示例#30
0
        /// <summary>
        /// Associate any unallocated assets to this resource. Return true if something changes.
        /// </summary>
        /// <returns>True if the prototype was in some way modified</returns>
        public bool AssociateAssets()
        {
            bool isModified = false;

            #if UNITY_EDITOR
            if (m_texture == null)
            {
                if (!string.IsNullOrEmpty(m_textureFileName))
                {
                    m_texture = GaiaUtils.GetAsset(m_textureFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
                    if (m_texture != null)
                    {
                        isModified = true;
                    }
                }
            }

            if (m_normal == null)
            {
                if (!string.IsNullOrEmpty(m_normalFileName))
                {
                    m_normal = GaiaUtils.GetAsset(m_normalFileName, typeof(UnityEngine.Texture2D)) as Texture2D;
                    if (m_normal != null)
                    {
                        isModified = true;
                    }
                }
            }
            #endif
            return(isModified);
        }