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; } } } }
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")); }
private void OnEnable() { m_renderpipeline = GaiaUtils.GetActivePipeline(); if (m_editorUtils == null) { // Get editor utils for this m_editorUtils = PWApp.GetEditorUtils(this); } }
/// <summary> /// Function used to rebuild buffers /// </summary> public void RebuildBuffers(bool clear = true) { RenderPipeline = GaiaUtils.GetActivePipeline(); if (clear) { ClearBuffers(); } StartBuffers(); }
private static void ConvertPWWeather(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline) { ConvertCloudBrightness(profile, renderPipeline); ConvertAmbientIntensity(profile, renderPipeline); ConvertAtmosphereThickness(profile, renderPipeline); ConvertCloudHeightLevelDensity(profile, renderPipeline); ConvertCloudHeightLevelThickness(profile, renderPipeline); ConvertCloudOpacity(profile, renderPipeline); ConvertFogDensity(profile, renderPipeline); ConvertSunIntensity(profile, renderPipeline); }
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(); }
private static void ConvertSun(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline) { if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal) { profile.m_lWSunColor = profile.m_sunColor; profile.m_lWSunIntensity = profile.m_sunIntensity + 0.15f; } else { profile.m_hDSunColor = profile.m_sunColor; profile.m_hDSunIntensity = profile.m_sunIntensity * 3f; } }
private static void ConvertFogDensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline) { if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal) { //Does not need changing } else { for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODFogDensity.keys.Length; i++) { profile.m_pwSkyAtmosphereData.TODFogDensity.keys[i].value += 0.005f; } } }
//Private const strings public static void StartInstallation(string unityVersion, GaiaConstants.EnvironmentRenderer renderPipeline, ShaderMappingEntry[] materialLibrary, UnityPipelineProfile pipelineProfile, bool showDialog = true) { //Set settings m_materialLibrary = materialLibrary; m_progressTimer = m_timer; m_renderPipeline = renderPipeline; m_unityVersion = unityVersion; m_gaiaPipelineProfile = pipelineProfile; //Checks if the material library is empty if (m_materialLibrary.Length == 0) { Debug.LogError("Material Library is empty. Please check the pipeline profile that it contains the necessary information"); FinishInstallingPackages(); return; } //Popup dialog to proceed if (showDialog) { if (EditorUtility.DisplayDialog("Importing Shaders and Materials", "You are about to install new shaders and materials to targeted pipeline and unity version. Please make sure you're using the correct SRP before you proceed. Are you sure you want to proceed?", "Yes", "No")) { EditorUtility.DisplayProgressBar("Preparing Installation", "Preparing shader directories...", 0.5f); StartInstallingPackage(); } else { //Finish and exit FinishInstallingPackages(); } } else { EditorUtility.DisplayProgressBar("Preparing Installation", "Preparing shader directories...", 0.5f); StartInstallingPackage(); } var manager = EditorWindow.GetWindow <GaiaManagerEditor>(false, "Gaia Manager"); //Manager can be null if the dependency package installation is started upon opening the manager window. if (manager != null) { //Perform the status check in the manager again to update the UI to the (hopefully successful) installation manager.GaiaManagerStatusCheck(true); } m_installShaders = false; }
private static void ConvertSunIntensity(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline) { if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal) { for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODSunIntensity.keys.Length; i++) { profile.m_pwSkyAtmosphereData.TODSunIntensity.keys[i].value += 0.06f; } } else { for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODSunIntensity.keys.Length; i++) { profile.m_pwSkyAtmosphereData.TODSunIntensity.keys[i].value *= 3f; } } }
private static void ConvertCloudHeightLevelThickness(GaiaLightingProfileValues profile, GaiaConstants.EnvironmentRenderer renderPipeline) { if (renderPipeline == GaiaConstants.EnvironmentRenderer.Universal) { for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys.Length; i++) { profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys[i].value += 0.1f; } } else { for (int i = 0; i < profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys.Length; i++) { profile.m_pwSkyAtmosphereData.TODCloudHeightLevelThickness.keys[i].value += 0.125f; } } }
/// <summary> /// Create a terrain tile based on these settings /// </summary> /// <param name="tx">X location</param> /// <param name="tz">Z location</param> /// <param name="world">The array managing it</param> private void CreateTile(int tx, int tz, ref Terrain[,] world, GaiaResource resources) { if (tx < 0 || tx >= m_tilesX) { Debug.LogError("X value out of bounds"); return; } if (tz < 0 || tz >= m_tilesZ) { Debug.LogError("Z value out of bounds"); return; } //Look for issues in the terrain settings and fix them GetAndFixDefaults(); //this will center terrain at origin Vector2 m_offset = new Vector2(-m_terrainSize * m_tilesX * 0.5f, -m_terrainSize * m_tilesZ * 0.5f); //create the terrains if they dont already exist if (world.Length < m_tilesX) { world = new Terrain[m_tilesX, m_tilesZ]; } //Create the terrain Terrain terrain; TerrainData terrainData = new TerrainData(); terrainData.name = string.Format("Terrain_{0}_{1}-{2:yyyyMMdd-HHmmss}", tx, tz, DateTime.Now); terrainData.alphamapResolution = m_controlTextureResolution; terrainData.baseMapResolution = m_baseMapSize; terrainData.SetDetailResolution(m_detailResolution, m_detailResolutionPerPatch); terrainData.heightmapResolution = m_heightmapResolution; //terrainData.physicsMaterial = m_physicsMaterial; terrainData.wavingGrassAmount = m_bending; terrainData.wavingGrassSpeed = m_size; terrainData.wavingGrassStrength = m_speed; terrainData.wavingGrassTint = m_grassTint; terrainData.size = new Vector3(m_terrainSize, m_terrainHeight, m_terrainSize); #if UNITY_EDITOR AssetDatabase.CreateAsset(terrainData, string.Format("Assets/{0}.asset", terrainData.name)); #endif terrain = Terrain.CreateTerrainGameObject(terrainData).GetComponent <Terrain>(); terrain.name = terrainData.name; terrain.transform.position = new Vector3(m_terrainSize * tx + m_offset.x, 0, m_terrainSize * tz + m_offset.y); terrain.basemapDistance = m_baseMapDist; #if UNITY_2019_1_OR_NEWER terrain.shadowCastingMode = m_shaodwCastingMode; #else terrain.castShadows = m_castShadows; #endif terrain.detailObjectDensity = m_detailDensity; terrain.detailObjectDistance = m_detailDistance; terrain.heightmapPixelError = m_pixelError; terrain.treeBillboardDistance = m_billboardStart; terrain.treeCrossFadeLength = m_fadeLength; terrain.treeDistance = m_treeDistance; terrain.treeMaximumFullLODCount = m_maxMeshTrees; #if UNITY_EDITOR GameObjectUtility.SetStaticEditorFlags(terrain.gameObject, StaticEditorFlags.BatchingStatic | StaticEditorFlags.NavigationStatic | StaticEditorFlags.OccludeeStatic | StaticEditorFlags.OccluderStatic | StaticEditorFlags.OffMeshLinkGeneration | StaticEditorFlags.ReflectionProbeStatic | StaticEditorFlags.LightmapStatic ); terrain.bakeLightProbesForTrees = false; #if UNITY_2018_3_OR_NEWER terrain.drawInstanced = true; #endif #endif GaiaConstants.EnvironmentRenderer rendererType = GaiaConstants.EnvironmentRenderer.BuiltIn; GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings(); if (gaiaSettings != null) { rendererType = gaiaSettings.m_currentRenderer; #if !UNITY_2018_1_OR_NEWER rendererType = GaiaConstants.EnvironmentRenderer.BuiltIn; #endif } if (rendererType == GaiaConstants.EnvironmentRenderer.BuiltIn) { if (m_material != null) { #if UNITY_EDITOR GaiaPipelineUtils.SetupPipeline(rendererType, null, null, null, "Procedural Worlds/Simple Water", false); #endif } } else { terrain.materialType = Terrain.MaterialType.Custom; if (rendererType == GaiaConstants.EnvironmentRenderer.LightWeight2018x) { #if UNITY_EDITOR && UNITY_2018_3_OR_NEWER GaiaPipelineUtils.SetupPipeline(rendererType, "Procedural Worlds Lightweight Pipeline Profile", "Pipeline Terrain Material", "Lightweight Render Pipeline/Terrain/Lit", "Procedural Worlds/Simple Water LW", false); #else Debug.LogWarning("Lightweight Pipeline is only supposted in 2018.3 or newer"); #endif } else { #if UNITY_EDITOR && UNITY_2018_3_OR_NEWER GaiaPipelineUtils.SetupPipeline(rendererType, "Procedural Worlds HDRenderPipelineAsset", "Pipeline Terrain Material", "HDRP/TerrainLit", "Procedural Worlds/Simple Water HD", false); #else Debug.LogWarning("Lightweight Pipeline is only supposted in 2018.3 or newer"); #endif } } if (m_physicsMaterial != null) { TerrainCollider collider = terrain.GetComponent <TerrainCollider>(); if (collider != null) { collider.material = m_physicsMaterial; } else { Debug.LogWarning("Unable to assign physics material to terrain!"); } } //Assign prototypes if (resources != null) { resources.ApplyPrototypesToTerrain(terrain); } else { terrain.Flush(); } //Save the new tile world[tx, tz] = terrain; //Parent it to the environment GameObject gaiaObj = GameObject.Find("Gaia Environment"); if (gaiaObj == null) { gaiaObj = new GameObject("Gaia Environment"); } terrain.transform.parent = gaiaObj.transform; }
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; } }
private static void GenerateProbesOnTerrain(Terrain terrain, ReflectionProbeData reflectionProbeData, bool seaLevelActive, float seaLevel, GaiaConstants.EnvironmentRenderer renderPipelineSettings) { GameObject reflectionParentObject = ReflectionProbeParenting(terrain); Vector3 terrainSize = terrain.terrainData.size; #if GAIA_PRO_PRESENT ReflectionProbeManager rpManager = ReflectionProbeManager.Instance; for (int row = 0; row < reflectionProbeData.reflectionProbesPerRow; ++row) { for (int columns = 0; columns < reflectionProbeData.reflectionProbesPerRow; ++columns) { Vector3 newPosition = new Vector3 { x = ((columns + 1) * terrainSize.x / reflectionProbeData.reflectionProbesPerRow) - terrainSize.x / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.x, z = ((row + 1) * terrainSize.z / reflectionProbeData.reflectionProbesPerRow) - terrainSize.z / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.z }; Vector3 size = new Vector3(terrain.terrainData.size.x / reflectionProbeData.reflectionProbesPerRow, terrain.terrainData.size.y, terrain.terrainData.size.z / reflectionProbeData.reflectionProbesPerRow); if (rpManager != null) { ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition, rpManager.UseReflectionProbeCuller); m_storedProbes.Add(newProbe); } else { ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition); m_storedProbes.Add(newProbe); } m_currentProbeCount++; } } #else for (int row = 0; row < reflectionProbeData.reflectionProbesPerRow; ++row) { for (int columns = 0; columns < reflectionProbeData.reflectionProbesPerRow; ++columns) { Vector3 newPosition = new Vector3 { x = ((columns + 1) * terrainSize.x / reflectionProbeData.reflectionProbesPerRow) - terrainSize.x / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.x, z = ((row + 1) * terrainSize.z / reflectionProbeData.reflectionProbesPerRow) - terrainSize.z / reflectionProbeData.reflectionProbesPerRow / 2f + terrain.transform.position.z }; Vector3 size = new Vector3(terrain.terrainData.size.x / reflectionProbeData.reflectionProbesPerRow, terrain.terrainData.size.y, terrain.terrainData.size.z / reflectionProbeData.reflectionProbesPerRow); ReflectionProbe newProbe = ReflectionProbeUtils.CreateReflectionProbe(newPosition, size, terrain, reflectionProbeData, seaLevelActive, seaLevel, reflectionParentObject.transform, renderPipelineSettings == GaiaConstants.EnvironmentRenderer.HighDefinition); m_storedProbes.Add(newProbe); m_currentProbeCount++; } } #endif EditorGUIUtility.PingObject(reflectionParentObject); }
/// <summary> /// Setup for the automatically probe spawning /// </summary> /// <param name="reflectionProbeData"></param> public static void CreateAutomaticProbes(ReflectionProbeData reflectionProbeData, GaiaConstants.EnvironmentRenderer renderPipelineSettings) { if (reflectionProbeData == null) { return; } if (reflectionProbeData.reflectionProbeRefresh == GaiaConstants.ReflectionProbeRefreshModePW.ProbeManager && reflectionProbeData.reflectionProbeMode == ReflectionProbeMode.Realtime) { #if GAIA_PRO_PRESENT ReflectionProbeManager manager = ReflectionProbeManager.GetOrCreateProbeManager(); if (manager != null) { manager.ProbeLayerMask = reflectionProbeData.reflectionprobeCullingMask; } #endif } else { #if GAIA_PRO_PRESENT ReflectionProbeManager.RemoveReflectionProbeManager(); #endif } ClearCreatedReflectionProbes(); GameObject oldReflectionProbe = GameObject.Find("Global Reflection Probe"); if (oldReflectionProbe != null) { UnityEngine.Object.DestroyImmediate(oldReflectionProbe); Debug.Log("Old Reflection Probe Destroyed"); } if (reflectionProbeData.reflectionProbesPerRow < 2) { Debug.LogError("Please set Probes Per Row to a value of 2 or higher"); } else { m_currentProbeCount = 0; float seaLevel = 0f; bool seaLevelActive = false; PWS_WaterSystem gaiawater = GameObject.FindObjectOfType <PWS_WaterSystem>(); if (gaiawater != null) { seaLevel = gaiawater.SeaLevel; seaLevelActive = true; } if (GaiaUtils.HasDynamicLoadedTerrains()) { Action <Terrain> terrAction = (t) => GenerateProbesOnTerrain(t, reflectionProbeData, seaLevelActive, seaLevel, renderPipelineSettings); GaiaUtils.CallFunctionOnDynamicLoadedTerrains(terrAction, true, null, "Generating 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) { GenerateProbesOnTerrain(activeTerrain, reflectionProbeData, seaLevelActive, seaLevel, renderPipelineSettings); } } } m_probeRenderActive = true; } }
/// <summary> /// Create a terrain tile based on these settings /// </summary> /// <param name="tx">X location</param> /// <param name="tz">Z location</param> /// <param name="world">The array managing it</param> private void CreateTile(int tx, int tz, ref Terrain[,] world, GaiaResource resources) { if (tx < 0 || tx >= m_tilesX) { Debug.LogError("X value out of bounds"); return; } if (tz < 0 || tz >= m_tilesZ) { Debug.LogError("Z value out of bounds"); return; } //Look for issues in the terrain settings and fix them GetAndFixDefaults(); //this will center terrain at origin Vector2 m_offset = new Vector2(-m_terrainSize * m_tilesX * 0.5f, -m_terrainSize * m_tilesZ * 0.5f); //create the terrains if they dont already exist if (world.Length < m_tilesX) { world = new Terrain[m_tilesX, m_tilesZ]; } //Create the terrain Terrain terrain; TerrainData terrainData = new TerrainData(); terrainData.name = string.Format("Terrain_{0}_{1}-{2:yyyyMMdd-HHmmss}", tx, tz, DateTime.Now); terrainData.alphamapResolution = m_controlTextureResolution; terrainData.baseMapResolution = m_baseMapSize; terrainData.SetDetailResolution(m_detailResolution, m_detailResolutionPerPatch); terrainData.heightmapResolution = m_heightmapResolution; //terrainData.physicsMaterial = m_physicsMaterial; terrainData.wavingGrassAmount = m_bending; terrainData.wavingGrassSpeed = m_size; terrainData.wavingGrassStrength = m_speed; terrainData.wavingGrassTint = m_grassTint; terrainData.size = new Vector3(m_terrainSize, m_terrainHeight, m_terrainSize); #if UNITY_EDITOR AssetDatabase.CreateAsset(terrainData, string.Format("Assets/{0}.asset", terrainData.name)); #endif terrain = Terrain.CreateTerrainGameObject(terrainData).GetComponent <Terrain>(); terrain.name = terrainData.name; terrain.transform.position = new Vector3(m_terrainSize * tx + m_offset.x, 0, m_terrainSize * tz + m_offset.y); terrain.basemapDistance = m_baseMapDist; terrain.castShadows = m_castShadows; terrain.detailObjectDensity = m_detailDensity; terrain.detailObjectDistance = m_detailDistance; terrain.heightmapPixelError = m_pixelError; terrain.treeBillboardDistance = m_billboardStart; terrain.treeCrossFadeLength = m_fadeLength; terrain.treeDistance = m_treeDistance; terrain.treeMaximumFullLODCount = m_maxMeshTrees; #if UNITY_EDITOR terrain.bakeLightProbesForTrees = false; #endif GaiaConstants.EnvironmentRenderer rendererType = GaiaConstants.EnvironmentRenderer.BuiltIn; GaiaSettings gaiaSettings = Utils.GetGaiaSettings(); if (gaiaSettings != null) { rendererType = gaiaSettings.m_currentRenderer; #if !UNITY_2018_1_OR_NEWER rendererType = GaiaConstants.EnvironmentRenderer.BuiltIn; #endif } if (rendererType == GaiaConstants.EnvironmentRenderer.BuiltIn) { if (m_material != null) { terrain.materialType = Terrain.MaterialType.Custom; terrain.materialTemplate = m_material; } } else { terrain.materialType = Terrain.MaterialType.Custom; if (rendererType == GaiaConstants.EnvironmentRenderer.LightWeight2018x) { Shader terrainShader = Shader.Find("LightweightPipeline/Terrain/Standard Terrain"); Material terrainMaterial = new Material(terrainShader); terrainMaterial.name = "Lightweight-DefaultTerrain"; terrain.materialTemplate = terrainMaterial; } else { Shader terrainShader = Shader.Find("HDRenderPipeline/Terrain/Standard Terrain"); Material terrainMaterial = new Material(terrainShader); terrainMaterial.name = "HDRender-DefaultTerrain"; terrain.materialTemplate = terrainMaterial; } } if (m_physicsMaterial != null) { TerrainCollider collider = terrain.GetComponent <TerrainCollider>(); if (collider != null) { collider.material = m_physicsMaterial; } else { Debug.LogWarning("Unable to assign physics material to terrain!"); } } //Assign prototypes if (resources != null) { resources.ApplyPrototypesToTerrain(terrain); } else { terrain.Flush(); } //Save the new tile world[tx, tz] = terrain; //Parent it to the environment GameObject gaiaObj = GameObject.Find("Gaia Environment"); if (gaiaObj == null) { gaiaObj = new GameObject("Gaia Environment"); } terrain.transform.parent = gaiaObj.transform; }
/// <summary> /// On Enable /// </summary> private void OnEnable() { #if UNITY_EDITOR m_gaiaSettings = GaiaUtils.GetGaiaSettings(); m_gaiaSceneInfo = GaiaSceneInfo.GetSceneInfo(); if (m_gaiaSettings != null) { m_currentRenderer = m_gaiaSettings.m_currentRenderer; } #if UNITY_POST_PROCESSING_STACK_V2 transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (Application.isPlaying) { transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); if (transitionPostFX != null) { transitionPostFX.enabled = true; } underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (underwaterPostFX != null) { underwaterPostFX.enabled = true; } } else { transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); if (transitionPostFX != null) { transitionPostFX.enabled = false; } underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (underwaterPostFX != null) { underwaterPostFX.enabled = false; } } #endif #if UNITY_2019_1_OR_NEWER && HDPipeline if (m_currentRenderer == GaiaConstants.EnvironmentRenderer.HighDefinition2018x) { if (m_aboveWaterProfile == null) { m_aboveWaterProfile = AssetDatabase.LoadAssetAtPath <VolumeProfile>(GaiaPipelineUtils.GetAssetPath("Gaia HDRP Post Processing Profile")); } if (m_underwaterProfile == null) { m_underwaterProfile = AssetDatabase.LoadAssetAtPath <VolumeProfile>(GaiaPipelineUtils.GetAssetPath("Gaia HDRP Underwater Post Processing Profile")); } } #endif #endif if (m_currentRenderer == GaiaConstants.EnvironmentRenderer.HighDefinition2018x) { GameObject volumeObject = GameObject.Find("High Definition Environment Volume"); if (volumeObject != null) { #if !UNITY_2019_1_OR_NEWER && HDPipeline if (volume == null) { volume = GameObject.Find("High Definition Environment Volume").GetComponent <Volume>(); if (volume != null) { VolumeProfile profile = volume.sharedProfile; if (profile != null) { VolumetricFog fog; if (profile.TryGet(out fog)) { storedFogColor = fog.albedo.value; storedFogDistance = fog.meanFreePath.value; } } } } #endif } else { Debug.LogWarning("Unabled to find a HDRP environment volume in the scene. Please insure one is set in this scene."); } } #if UNITY_2019_1_OR_NEWER && HDPipeline postVolume = GameObject.Find("Gaia HDRP Post Processing").GetComponent <Volume>(); #endif }
public override void OnInspectorGUI() { //Initialization m_editorUtils.Initialize(); // Do not remove this! //Monitor for changes EditorGUI.BeginChangeCheck(); defaultBackground = GUI.backgroundColor; if (m_gaiaSettings == null) { m_gaiaSettings = GaiaUtils.GetGaiaSettings(); } if (m_renderPipeline != m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled) { m_renderPipeline = m_gaiaSettings.m_pipelineProfile.m_activePipelineInstalled; } if (m_profile.m_selectedLightingProfileValuesIndex > m_profile.m_lightingProfiles.Count - 1) { m_profile.m_selectedLightingProfileValuesIndex = 0; } EditorGUILayout.LabelField("Profile Version: " + m_version); if (enableEditMode) { m_profile.m_editSettings = EditorGUILayout.ToggleLeft("Use Procedural Worlds Editor Settings", m_profile.m_editSettings); } else { m_profile.m_editSettings = false; } if (m_profile.m_editSettings) { m_editorUtils.Panel("UpdateSettings", RealtimeUpdateEnabled); m_editorUtils.Panel("GlobalSettings", GlobalSettingsEnabled); m_editorUtils.Panel("LightingProfileSettings", LightingProfileSettingsEnabled); DrawDefaultInspector(); } //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); if (m_profile.m_updateInRealtime) { 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); } } }
/// <summary> /// Start function /// </summary> void Start() { #if UNITY_POST_PROCESSING_STACK_V2 transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (Application.isPlaying) { if (transitionPostFX != null) { transitionPostFX.enabled = true; } if (underwaterPostFX != null) { underwaterPostFX.enabled = true; } } else { if (transitionPostFX != null) { transitionPostFX.enabled = false; } if (underwaterPostFX != null) { underwaterPostFX.enabled = false; } } #endif if (m_gaiaSettings == null) { m_gaiaSettings = GaiaUtils.GetGaiaSettings(); } if (m_gaiaSceneInfo == null) { m_gaiaSceneInfo = GaiaSceneInfo.GetSceneInfo(); } if (m_gaiaSettings != null) { m_currentRenderer = m_gaiaSettings.m_currentRenderer; } #if HDPipeline if (m_currentRenderer == GaiaConstants.EnvironmentRenderer.HighDefinition2018x) { GameObject underwaterProbe = GameObject.Find("Underwater Reflection Probe"); if (underwaterProbe != null) { m_underwaterProbe = GameObject.Find("Underwater Reflection Probe").GetComponent <ReflectionProbe>(); } } #endif GameObject waterPlanar = GameObject.Find("Water Planar Reflections"); if (waterPlanar != null) { ReflectionProbe reflection = GameObject.Find("Water Planar Reflections").GetComponent <ReflectionProbe>(); { if (reflection != null) { reflection.mode = UnityEngine.Rendering.ReflectionProbeMode.Custom; } #if HDPipeline HDAdditionalReflectionData reflectionData = GameObject.Find("Water Planar Reflections").GetComponent <HDAdditionalReflectionData>(); if (reflectionData != null) { #if !UNITY_2019_1_OR_NEWER reflectionData.mode = UnityEngine.Rendering.ReflectionProbeMode.Custom; #else reflectionData.mode = ProbeSettings.Mode.Realtime; #endif } #endif } } #if HDPipeline if (m_underwaterProbe != null) { m_underwaterProbe.enabled = false; } #endif mainlight = gameObject.GetComponent <Light>(); mainlight.cookie = null; causticsObject = gameObject.transform; partentObject = GetOrCreateEnvironmentParent().transform; if (m_currentRenderer == GaiaConstants.EnvironmentRenderer.HighDefinition2018x) { #if UNITY_2019_1_OR_NEWER && HDPipeline postVolume = GameObject.Find("Gaia HDRP Post Processing").GetComponent <Volume>(); volume = GameObject.Find("High Definition Environment Volume").GetComponent <Volume>(); if (volume != null) { VolumeProfile profile = volume.sharedProfile; if (profile != null) { VolumetricFog fog; if (profile.TryGet(out fog)) { storedFogColor = fog.albedo.value; storedFogDistance = fog.meanFreePath.value; } } } #endif } else { storedFogColor = RenderSettings.fogColor; storedFogDistance = RenderSettings.fogEndDistance; } ambientAudio = null; if (ambientAudio == null) { ambientAudio = GameObject.Find("Ambient Audio"); } underwaterAudio = null; if (underwaterAudio == null) { underwaterAudio = GameObject.Find("Underwater SoundFX"); } #if UNITY_EDITOR if (player == null) { player = GetThePlayer(); } #endif if (m_gaiaSceneInfo != null) { m_sealevel = m_gaiaSceneInfo.m_seaLevel; } if (m_useHorizonFix) { horizonObject = GameObject.Find("Ambient Underwater Horizon"); if (horizonObjectStored != null) { horizonObject = Instantiate(horizonObjectStored); horizonObject.name = "Ambient Underwater Horizon"; if (partentObject != null) { horizonObject.transform.parent = partentObject; } MeshRenderer[] theRenders = horizonObject.GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer rends in theRenders) { rends.enabled = false; } } } if (m_useUnderwaterparticles) { underwaterParticles = GameObject.Find("Underwater Particles Effects"); if (underwaterParticlesStored != null) { underwaterParticles = Instantiate(underwaterParticlesStored); underwaterParticles.name = "Underwater Particles Effects"; underwaterParticles.SetActive(false); if (partentObject != null) { underwaterParticles.transform.parent = partentObject; } } } if (gameObject.GetComponent <AudioSource>() == null) { gameObject.AddComponent <AudioSource>(); objectAudioSource = gameObject.GetComponent <AudioSource>(); objectAudioSource.volume = m_waterSubmergeSounfFXVolume; } else { objectAudioSource = gameObject.GetComponent <AudioSource>(); objectAudioSource.volume = m_waterSubmergeSounfFXVolume; } if (mainlight.type == LightType.Directional) { mainlight.cookieSize = m_causticsSize; } StopAllCoroutines(); }
/// <summary> /// On Enable /// </summary> private void OnEnable() { #if UNITY_EDITOR m_gaiaSettings = GaiaUtils.GetGaiaSettings(); m_gaiaSceneInfo = GaiaSceneInfo.GetSceneInfo(); if (m_gaiaSettings != null) { m_currentRenderer = m_gaiaSettings.m_currentRenderer; } #if UNITY_POST_PROCESSING_STACK_V2 transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (Application.isPlaying) { transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); if (transitionPostFX != null) { transitionPostFX.enabled = true; } underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (underwaterPostFX != null) { underwaterPostFX.enabled = true; } } else { transitionPostFX = GameObject.Find("Underwater Transition PostFX").GetComponent <PostProcessVolume>(); if (transitionPostFX != null) { transitionPostFX.enabled = false; } underwaterPostFX = GameObject.Find("Underwater PostFX").GetComponent <PostProcessVolume>(); if (underwaterPostFX != null) { underwaterPostFX.enabled = false; } } #endif #if UNITY_2019_1_OR_NEWER && HDPipeline if (m_currentRenderer == GaiaConstants.EnvironmentRenderer.HighDefinition2018x) { if (m_aboveWaterProfile == null) { m_aboveWaterProfile = AssetDatabase.LoadAssetAtPath <VolumeProfile>(GaiaPipelineUtils.GetAssetPath("Gaia HDRP Post Processing Profile")); } if (m_underwaterProfile == null) { m_underwaterProfile = AssetDatabase.LoadAssetAtPath <VolumeProfile>(GaiaPipelineUtils.GetAssetPath("Gaia HDRP Underwater Post Processing Profile")); } } #endif #endif }