#if UNITY_EDITOR using System.Collections.Generic; using System.IO; #if MEWLIST_MASSIVE_CLOUDS using Mewlist; #endif using UnityEditor; using UnityEngine; namespace Gaia.GX.ProceduralWorlds { public class MassiveCloudGX { #if MEWLIST_MASSIVE_CLOUDS #region Generic informational methods /// /// Returns the publisher name if provided. /// This will override the publisher name in the namespace ie Gaia.GX.PublisherName /// /// Publisher name public static string GetPublisherName() { return "Mewlist"; } /// /// Returns the package name if provided /// This will override the package name in the class name ie public class PackageName. /// /// Package name public static string GetPackageName() { return "Massive Clouds - Screen Space Volumetric Clouds"; } #endregion #region Methods exposed by Gaia as buttons must be prefixed with GX_ /// /// Adds water system to the scene /// public static void GX_AddClouds() { AddClouds(); } /// /// Removes water system from the scene /// public static void GX_RemoveClouds() { RemoveClouds(); } #endregion #region Utils private static void AddClouds() { Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { MassiveClouds clouds = mainCamera.GetComponent(); if (clouds == null) { clouds = mainCamera.gameObject.AddComponent(); } List profiles = new List(); MassiveCloudsProfile profile = AssetDatabase.LoadAssetAtPath(GaiaUtils.GetAssetPath("Cloudy C.asset")); List parameters = new List(); if (profile != null) { profiles.Add(profile); parameters.Add(profile.Parameter); clouds.SetProfiles(profiles); clouds.SetParameters(parameters); } MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent(); if (cloudsEffect == null) { cloudsEffect = mainCamera.gameObject.AddComponent(); } } } private static void RemoveClouds() { Camera mainCamera = GaiaUtils.GetCamera(); if (mainCamera != null) { MassiveCloudsCameraEffect cloudsEffect = mainCamera.GetComponent(); if (cloudsEffect != null) { GameObject.DestroyImmediate(cloudsEffect); } MassiveClouds clouds = mainCamera.GetComponent(); if (clouds != null) { GameObject.DestroyImmediate(clouds); } } } #endregion #endif } [InitializeOnLoad] public static class MewlistMassiveClouds { static MewlistMassiveClouds() { string folderName = "MassiveClouds"; if (Directory.Exists(GaiaUtils.GetAssetPath(folderName))) { //Make sure we inject GAIA_2_PRESENT bool updateScripting = false; var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup); if (!symbols.Contains("MEWLIST_MASSIVE_CLOUDS")) { updateScripting = true; if (symbols.Length < 1) { symbols += "MEWLIST_MASSIVE_CLOUDS"; } else { symbols += ";MEWLIST_MASSIVE_CLOUDS"; } } if (updateScripting) { PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, symbols); } } } } } #endif