Firstborn/Assets/AwesomeTechnologies/VegetationStudioPro/Integration/MapMagicInfiniteTerrain.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

39 lines
1.1 KiB
C#

#if VEGETATION_STUDIO_PRO && VSP_PACKAGES
using AwesomeTechnologies.VegetationSystem;
using UnityEngine;
namespace AwesomeTechnologies.External.MapMagicInterface
{
public class MapMagicInfiniteTerrain : MonoBehaviour
{
// ReSharper disable once UnusedMember.Local
void OnEnable()
{
#if MAPMAGIC
MapMagic.MapMagic.OnApplyCompleted += OnGenerateCompleted;
#endif
}
private void OnDisable()
{
#if MAPMAGIC
MapMagic.MapMagic.OnApplyCompleted -= OnGenerateCompleted;
#endif
}
// ReSharper disable once UnusedMember.Local
void OnGenerateCompleted(Terrain terrain)
{
UnityTerrain unityTerrain = terrain.gameObject.GetComponent<UnityTerrain>();
if (!unityTerrain)
{
unityTerrain = terrain.gameObject.AddComponent<UnityTerrain>();
}
unityTerrain.TerrainPosition = terrain.transform.position;
unityTerrain.AutoAddToVegegetationSystem = true;
unityTerrain.AddTerrainToVegetationSystem();
}
}
}
#endif