public static void GX_BakeColorMaps() { if (EditorUtility.DisplayDialog("Bake Terrain Color Maps", "This will bake the color maps for all Gaia Terrains in the scene (currently loaded or not). This can take a while depending on the number of your terrains.", "Bake Color Maps Now", "Cancel")) { bool bakeGrass = false; if (EditorUtility.DisplayDialog("Bake Grass?", "Do you want to bake the terrain details / grass in the color map?", "Yes", "No")) { bakeGrass = true; } if (GaiaUtils.HasDynamicLoadedTerrains()) { Action <Terrain> act = (t) => BakeCTSColorMapForTerrain(t, bakeGrass); GaiaUtils.CallFunctionOnDynamicLoadedTerrains(BakeCTSNormalsForTerrain, true); } else { foreach (Terrain t in Terrain.activeTerrains) { BakeCTSColorMapForTerrain(t, bakeGrass); } } } }
/// <summary> /// Adds a CTS profile with a certain name to all terrains (loaded or not) and then bakes the textures for that terrain /// </summary> /// <param name="profileName"></param> public static void AddCTSProfile(string profileName) { bool bakeTerrainNormals = false; if (EditorUtility.DisplayDialog("Bake Terrain Normals?", "Do you want CTS to bake terrain normal maps while applying the profile as well?", "Yes", "No")) { bakeTerrainNormals = true; } CTSProfile ctsProfile = (CTSProfile)AssetDatabase.LoadAssetAtPath(GetCTSProfilePath(profileName), typeof(CTSProfile)); if (ctsProfile != null) { if (GaiaUtils.HasDynamicLoadedTerrains()) { Action <Terrain> act = (t) => ApplyCTSProfile(t, ctsProfile, bakeTerrainNormals); GaiaUtils.CallFunctionOnDynamicLoadedTerrains(act, true); } else { foreach (Terrain t in Terrain.activeTerrains) { ApplyCTSProfile(t, ctsProfile, bakeTerrainNormals); } } if (ctsProfile.m_needsAlbedosArrayUpdate || ctsProfile.m_needsNormalsArrayUpdate) { CTSTerrainManager.Instance.BroadcastShaderSetup(ctsProfile); } } }
public static void GX_BakeTerrainNormals() { if (EditorUtility.DisplayDialog("Bake Terrain Normals", "This will bake the normal maps for all Gaia Terrains in the scene (currently loaded or not). This can take a while depending on the number of your terrains.", "Bake Normals Now", "Cancel")) { if (GaiaUtils.HasDynamicLoadedTerrains()) { GaiaUtils.CallFunctionOnDynamicLoadedTerrains(BakeCTSNormalsForTerrain, true); } else { foreach (Terrain t in Terrain.activeTerrains) { BakeCTSNormalsForTerrain(t); } } } }
public static void GX_RemoveCTS() { if (EditorUtility.DisplayDialog("Remove CTS", "Are you sure you want to completely remove CTS from all the terrains in your scene? This will also remove CTS from terrains which are currently not loaded in this scene.", "Remove CTS", "Cancel")) { if (GaiaUtils.HasDynamicLoadedTerrains()) { GaiaUtils.CallFunctionOnDynamicLoadedTerrains(RemoveCTSFromTerrain, true); } else { foreach (Terrain t in Terrain.activeTerrains) { RemoveCTSFromTerrain(t); } } GameObject wm = GameObject.Find("CTS Weather Manager"); if (wm != null) { UnityEngine.Object.DestroyImmediate(wm); } } }
/// <summary> /// Configures all GaiaHierarchyUtils components and in each of the objects showed in Hierarchy to be shown or hidden /// </summary> public void SetupAllHideInHierarchy() { bool localOnly = false; if (GaiaUtils.HasDynamicLoadedTerrains()) { #if UNITY_EDITOR if (EditorUtility.DisplayDialog("Apply to all terrains?", "Do you want to apply these settings to ALL terrains (inlcuding the ones which are currently not loaded), or the loaded ones only?", "All terrains", "Only loaded terrains")) { GaiaUtils.CallFunctionOnDynamicLoadedTerrains(SetupAllHideOnTerrain, true, null, "Applying hide settings to terrain scenes..."); } else { localOnly = true; } #endif } else { localOnly = true; } if (localOnly) { //Get all GaiaHierarchyUtils GaiaHierarchyUtils[] hierarchyUtils = FindObjectsOfType <GaiaHierarchyUtils>(); //Proceed if objects exist if (hierarchyUtils != null) { foreach (GaiaHierarchyUtils utils in hierarchyUtils) { utils.m_visibilityEntries = m_visibilityEntries; utils.SetupHideInHierarchy(); } } } }