private static void RemoveOverCloud() { GameObject overCloudPrefab = GameObject.Find("OverCloud"); if (overCloudPrefab != null) { GameObject.DestroyImmediate(overCloudPrefab); } Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { OverCloudCamera ocCamera = mainCamera.gameObject.GetComponent <OverCloudCamera>(); if (ocCamera != null) { GameObject.DestroyImmediate(ocCamera); } } if (GaiaUtils.CheckIfSceneProfileExists()) { GaiaGlobal.Instance.SceneProfile.m_waterSystemMode = GaiaConstants.GlobalSystemMode.Gaia; GaiaSettings gaiaSettings = GaiaUtils.GetGaiaSettings(); if (gaiaSettings != null) { UnityPipelineProfile pipelineProfile = gaiaSettings.m_pipelineProfile; if (pipelineProfile != null) { GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, pipelineProfile, GaiaUtils.GetActivePipeline()); } } } }
private static void AddClouds() { Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { MassiveClouds clouds = mainCamera.GetComponent <MassiveClouds>(); if (clouds == null) { clouds = mainCamera.gameObject.AddComponent <MassiveClouds>(); } List <MassiveCloudsProfile> profiles = new List <MassiveCloudsProfile>(); MassiveCloudsProfile profile = AssetDatabase.LoadAssetAtPath <MassiveCloudsProfile>(GaiaUtils.GetAssetPath("Cloudy C.asset")); List <MassiveCloudsParameter> parameters = new List <MassiveCloudsParameter>(); if (profile != null) { profiles.Add(profile); parameters.Add(profile.Parameter); clouds.SetProfiles(profiles); clouds.SetParameters(parameters); } MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent <MassiveCloudsCameraEffect>(); if (cloudsEffect == null) { cloudsEffect = mainCamera.gameObject.AddComponent <MassiveCloudsCameraEffect>(); } } }
private static void AddOverCloud() { GameObject overCloudPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(GaiaUtils.GetAssetPath("OverCloud.prefab")); if (overCloudPrefab != null) { Light sunLight = GaiaUtils.GetMainDirectionalLight(); if (sunLight != null) { GameObject.DestroyImmediate(sunLight.gameObject); } PrefabUtility.InstantiatePrefab(overCloudPrefab, GetOrCreateParentObject(GaiaConstants.gaiaLightingObject, true).transform); Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { OverCloudCamera ocCamera = mainCamera.gameObject.GetComponent <OverCloudCamera>(); if (ocCamera == null) { ocCamera = mainCamera.gameObject.AddComponent <OverCloudCamera>(); } } GaiaUtils.SetCustomLightSystem(overCloudPrefab); } else { Debug.LogError("OverCloud Prefab was not found"); } }
private static void SetOverCloudQuality(OverCloudQuality quality) { Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { OverCloudCamera ocCamera = mainCamera.GetComponent <OverCloudCamera>(); if (ocCamera != null) { switch (quality) { case OverCloudQuality.High: ocCamera.downsample2DClouds = false; ocCamera.downsampleFactor = DownSampleFactor.Full; ocCamera.highQualityClouds = true; ocCamera.renderAtmosphere = true; ocCamera.renderScatteringMask = true; ocCamera.renderVolumetricClouds = true; ocCamera.scatteringMaskSamples = SampleCount.High; ocCamera.lightSampleCount = SampleCount.High; break; case OverCloudQuality.Medium: ocCamera.downsample2DClouds = true; ocCamera.downsampleFactor = DownSampleFactor.Half; ocCamera.highQualityClouds = true; ocCamera.renderAtmosphere = true; ocCamera.renderScatteringMask = true; ocCamera.renderVolumetricClouds = true; ocCamera.scatteringMaskSamples = SampleCount.Normal; ocCamera.lightSampleCount = SampleCount.Normal; break; case OverCloudQuality.Low: ocCamera.downsample2DClouds = true; ocCamera.downsampleFactor = DownSampleFactor.Eight; ocCamera.highQualityClouds = false; ocCamera.renderAtmosphere = true; ocCamera.renderScatteringMask = false; ocCamera.renderVolumetricClouds = false; ocCamera.scatteringMaskSamples = SampleCount.Low; ocCamera.lightSampleCount = SampleCount.Low; break; } } } }
private static void RemoveClouds() { Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent <MassiveCloudsCameraEffect>(); if (cloudsEffect != null) { GameObject.DestroyImmediate(cloudsEffect); } MassiveClouds clouds = mainCamera.GetComponent <MassiveClouds>(); if (clouds != null) { GameObject.DestroyImmediate(clouds); } } }
/// <summary> /// Configures camera to LWRP /// </summary> private static void ConfigureCamera() { try { Camera camera = GaiaUtils.GetCamera(); if (camera == null) { Debug.LogWarning("[GaiaUPRPPipelineUtils.ConfigureCamera()] A camera could not be found to upgrade in your scene."); } else { #if UPPipeline UniversalAdditionalCameraData cameraData = GaiaURPRuntimeUtils.GetUPCameraData(camera); cameraData.renderShadows = true; #endif } } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Cleans up LWRP components in the scene /// </summary> public static void CleanUpURP(UnityPipelineProfile profile, GaiaSettings gaiaSettings) { try { #if UPPipeline UniversalAdditionalCameraData[] camerasData = GameObject.FindObjectsOfType <UniversalAdditionalCameraData>(); GaiaURPRuntimeUtils.ClearUPCameraData(camerasData); UniversalAdditionalLightData[] lightsData = GameObject.FindObjectsOfType <UniversalAdditionalLightData>(); GaiaURPRuntimeUtils.ClearUPLightData(lightsData); GameObject volumeObject = GameObject.Find("Global Post Processing"); if (volumeObject != null) { GameObject.DestroyImmediate(volumeObject); } Camera camera = GaiaUtils.GetCamera(); if (camera != null) { UniversalAdditionalCameraData cameraData = camera.GetComponent <UniversalAdditionalCameraData>(); if (cameraData == null) { cameraData = camera.gameObject.AddComponent <UniversalAdditionalCameraData>(); } cameraData.renderPostProcessing = false; } #endif if (profile.m_underwaterHorizonMaterial != null) { profile.m_underwaterHorizonMaterial.shader = Shader.Find(profile.m_builtInHorizonObjectShader); } GameObject waterPrefab = GameObject.Find(gaiaSettings.m_gaiaWaterProfile.m_waterPrefab.name); if (waterPrefab != null) { //reverting default water mesh quality gaiaSettings.m_gaiaWaterProfile.m_customMeshQuality = 2; if (GaiaGlobal.Instance != null) { GaiaWater.UpdateWaterMeshQuality(GaiaGlobal.Instance.SceneProfile, gaiaSettings.m_gaiaWaterProfile.m_waterPrefab); } PWS_WaterSystem reflection = waterPrefab.GetComponent <PWS_WaterSystem>(); if (reflection == null) { reflection = waterPrefab.AddComponent <PWS_WaterSystem>(); } } Terrain[] terrains = Terrain.activeTerrains; if (terrains != null) { foreach (Terrain terrain in terrains) { #if !UNITY_2019_2_OR_NEWER terrain.materialType = Terrain.MaterialType.BuiltInStandard; #else terrain.materialTemplate = profile.m_builtInTerrainMaterial; #endif } } Terrain terrainDetail = Terrain.activeTerrain; if (terrainDetail != null) { if (terrainDetail.detailObjectDensity == 0f) { if (EditorUtility.DisplayDialog("Detail Density Disabled!", "Details density is disabled on your terrain would you like to activate it?", "Yes", "No")) { terrainDetail.detailObjectDensity = 0.3f; } } } GameObject LWRPReflections = GameObject.Find("URP Water Reflection Probe"); if (LWRPReflections != null) { Object.DestroyImmediate(LWRPReflections); } GraphicsSettings.renderPipelineAsset = null; QualitySettings.renderPipeline = null; if (GaiaGlobal.Instance != null) { //GaiaUtils.GetRuntimeSceneObject(); if (GaiaGlobal.Instance.SceneProfile != null && GaiaGlobal.Instance.SceneProfile.m_lightingProfiles.Count > 0) { GaiaLighting.GetProfile(GaiaGlobal.Instance.SceneProfile, gaiaSettings.m_pipelineProfile, GaiaConstants.EnvironmentRenderer.BuiltIn); } } //Clean up the UPR post processing objects in the underwater effects //We need to look for transform instead of GameObjects, since the GOs can be disabled and won't be found then GameObject uwe = GameObject.Find(GaiaConstants.underwaterEffectsName); if (uwe != null) { Transform utoTransform = uwe.transform.Find(GaiaConstants.underwaterTransitionObjectName); if (utoTransform != null) { Object.DestroyImmediate(utoTransform.gameObject); } Transform uppTransform = uwe.transform.Find(GaiaConstants.underwaterPostProcessingName); if (uppTransform != null) { Object.DestroyImmediate(uppTransform.gameObject); } Transform horizonTransform = uwe.transform.Find(GaiaConstants.underwaterHorizonName); if (horizonTransform != null) { Object.DestroyImmediate(horizonTransform.gameObject); } } if (waterPrefab != null) { Material waterMat = GaiaWater.GetGaiaOceanMaterial(); if (waterMat != null) { if (GaiaGlobal.Instance != null) { GaiaWater.GetProfile(gaiaSettings.m_gaiaWaterProfile.m_selectedWaterProfileValuesIndex, waterMat, GaiaGlobal.Instance.SceneProfile, true, false); } } else { Debug.Log("Material could not be found"); } } MarkSceneDirty(false); EditorUtility.SetDirty(profile); profile.m_activePipelineInstalled = GaiaConstants.EnvironmentRenderer.BuiltIn; GaiaManagerEditor manager = EditorWindow.GetWindow <Gaia.GaiaManagerEditor>(false, "Gaia Manager"); if (manager != null) { manager.GaiaManagerStatusCheck(true); } bool isChanged = false; string currBuildSettings = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); if (currBuildSettings.Contains("UPPipeline")) { currBuildSettings = currBuildSettings.Replace("UPPipeline;", ""); currBuildSettings = currBuildSettings.Replace("UPPipeline", ""); isChanged = true; } if (isChanged) { PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, currBuildSettings); } } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// Apply URP post fx /// </summary> /// <param name="profile"></param> /// <param name="lightingProfile"></param> public static GameObject ApplyURPPostProcessing(GaiaLightingProfileValues profile, SceneProfile lightingProfile) { try { GameObject volumeObject = null; #if UPPipeline if (lightingProfile.m_enablePostProcessing) { volumeObject = GameObject.Find("Global Post Processing"); if (volumeObject == null) { volumeObject = new GameObject("Global Post Processing"); } GameObject parentObject = GaiaLighting.GetOrCreateParentObject(GaiaConstants.gaiaLightingObject, true); if (parentObject != null) { volumeObject.transform.SetParent(parentObject.transform); } volumeObject.layer = 0; Volume volume = volumeObject.GetComponent <Volume>(); if (volume == null) { volume = volumeObject.AddComponent <Volume>(); } if (GaiaGlobal.Instance != null) { SceneProfile sceneProfile = GaiaGlobal.Instance.SceneProfile; if (sceneProfile != null) { if (sceneProfile.m_lightingEditSettings || profile.m_userCustomProfile) { sceneProfile.m_universalPostFXProfile = profile.PostProcessProfileURP; } else { CreatePostFXProfileInstance(sceneProfile, profile); } volume.sharedProfile = sceneProfile.m_universalPostFXProfile; Camera camera = GaiaUtils.GetCamera(); if (camera != null) { UniversalAdditionalCameraData cameraData = camera.GetComponent <UniversalAdditionalCameraData>(); if (cameraData == null) { cameraData = camera.gameObject.AddComponent <UniversalAdditionalCameraData>(); } cameraData.renderPostProcessing = true; GaiaLighting.ConfigureAntiAliasing(sceneProfile, GaiaConstants.EnvironmentRenderer.Universal); } } } } else { volumeObject = GameObject.Find("Global Post Processing"); if (volumeObject != null) { GameObject.DestroyImmediate(volumeObject); } Camera camera = GaiaUtils.GetCamera(); if (camera != null) { UniversalAdditionalCameraData cameraData = camera.GetComponent <UniversalAdditionalCameraData>(); if (cameraData == null) { cameraData = camera.gameObject.AddComponent <UniversalAdditionalCameraData>(); } cameraData.renderPostProcessing = false; } } #endif #if UNITY_POST_PROCESSING_STACK_V2 PostProcessLayer postProcessLayer = GameObject.FindObjectOfType <PostProcessLayer>(); if (postProcessLayer != null) { GameObject.DestroyImmediate(postProcessLayer); } PostProcessVolume postProcessVolume = GameObject.FindObjectOfType <PostProcessVolume>(); if (postProcessVolume != null) { GameObject.DestroyImmediate(postProcessVolume); } #endif return(volumeObject); } catch (Exception e) { Console.WriteLine(e); throw; } }