Exemple #1
0
        public static void ShowWorldMapStampSpawner()
        {
            Terrain worldMapTerrain = TerrainHelper.GetWorldMapTerrain();

            if (worldMapTerrain == null)
            {
                Debug.LogError("No world map created yet! Please create a world map first before opening the random terrain generator");
                return;
            }

            GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(false);

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

            //Create or find the stamper
            GameObject spawnerObj = GaiaUtils.GetOrCreateWorldDesigner();
            Spawner    spawner    = spawnerObj.GetComponent <WorldDesigner>();

            if (spawner == null)
            {
                spawner = spawnerObj.AddComponent <WorldDesigner>();
                if (settings != null)
                {
                    if (settings.m_defaultStampSpawnSettings != null)
                    {
                        spawner.LoadSettings(settings.m_defaultStampSpawnSettings);
                    }
                }
                spawner.m_settings.m_isWorldmapSpawner = true;
                spawner.m_worldMapTerrain = worldMapTerrain;

                //set up the export settings with the current Gaia Settings / defaults
                spawner.m_worldCreationSettings.m_targeSizePreset = settings.m_targeSizePreset;
                spawner.m_worldCreationSettings.m_xTiles          = settings.m_tilesX;
                spawner.m_worldCreationSettings.m_zTiles          = settings.m_tilesZ;
                spawner.m_worldTileSize = GaiaUtils.IntToEnvironmentSize(settings.m_currentDefaults.m_terrainSize);
                spawner.m_worldCreationSettings.m_tileSize              = settings.m_currentDefaults.m_terrainSize;
                spawner.m_worldCreationSettings.m_tileHeight            = settings.m_currentDefaults.m_terrainHeight;
                spawner.m_worldCreationSettings.m_createInScene         = settings.m_createTerrainScenes;
                spawner.m_worldCreationSettings.m_autoUnloadScenes      = settings.m_unloadTerrainScenes;
                spawner.m_worldCreationSettings.m_applyFloatingPointFix = settings.m_floatingPointFix;
                spawner.m_worldCreationSettings.m_qualityPreset         = settings.m_currentEnvironment;
                if (spawner.m_worldCreationSettings.m_gaiaDefaults == null)
                {
                    spawner.m_worldCreationSettings.m_gaiaDefaults = settings.m_currentDefaults;
                }

                spawner.StoreWorldSize();
                //spawner.StoreHeightmapResolution();

                //Check if we do have an existing terrain already, if yes, we would want to re-use it for the world map -> terrain export
                if (GaiaUtils.HasTerrains())
                {
                    spawner.m_useExistingTerrainForWorldMapExport = true;
                }
                else
                {
                    //No terrains yet - set up the terrain tiles in the session according to the current world creation settings
                    //so that the stamp previews will come out right.
                    TerrainLoaderManager.Instance.TerrainSceneStorage.m_terrainTilesX = settings.m_tilesX;
                    TerrainLoaderManager.Instance.TerrainSceneStorage.m_terrainTilesZ = settings.m_tilesZ;
                }

                spawner.FitToTerrain();
                spawner.UpdateMinMaxHeight();
            }
            else
            {
                spawner.m_settings.m_isWorldmapSpawner = true;
                spawner.m_worldMapTerrain = worldMapTerrain;
                spawner.FitToTerrain();
                spawner.UpdateMinMaxHeight();
            }
            gsm.m_session.m_worldBiomeMaskSettings = spawner.m_settings;
            TerrainLoaderManager.Instance.SwitchToWorldMap();
#if UNITY_EDITOR
            Selection.activeGameObject = spawnerObj;
#endif
        }