Exemple #1
0
        // ReSharper disable once UnusedMember.Local
        void OnEnable()
        {
            _initDone = true;

            //SetTerrainPosition();

            if (AutoAddToVegegetationSystem && Application.isPlaying)
            {
                VegetationStudioManager.AddTerrain(gameObject, false);
            }
            else
            {
                VegetationStudioManager.RefreshTerrainArea(TerrainBounds);
            }
        }
Exemple #2
0
        // ReSharper disable once UnusedMember.Local
        void OnEnable()
        {
            _debugMaterial = Resources.Load("MeshTerrainDebugMaterial", typeof(Material)) as Material;

            _initDone = true;


            if (AutoAddToVegegetationSystem && Application.isPlaying)
            {
                VegetationStudioManager.AddTerrain(gameObject, false);
            }
            else
            {
                VegetationStudioManager.RefreshTerrainArea(TerrainBounds);
            }
        }
Exemple #3
0
    void CreateMeshTerrains(bool addToVegetationSystem)
    {
        for (int i = 0; i <= _meshRendererList.Count - 1; i++)
        {
            MeshRenderer meshRenderer = _meshRendererList[i];
            if (meshRenderer == null)
            {
                continue;
            }

            GameObject go = new GameObject("MeshTerrain_" + meshRenderer.name);
            if (_addAsChild)
            {
                go.transform.SetParent(meshRenderer.transform);
            }
            MeshTerrain meshTerrain = go.AddComponent <MeshTerrain>();


            MeshTerrainData meshTerrainData = CreateInstance <MeshTerrainData>();

            if (!AssetDatabase.IsValidFolder("Assets/MeshTerrainData"))
            {
                AssetDatabase.CreateFolder("Assets", "MeshTerrainData");
            }

            string filename = "MeshTerrainData_" + Guid.NewGuid() + ".asset";
            AssetDatabase.CreateAsset(meshTerrainData, "Assets/MeshTerrainData/" + filename);

            MeshTerrainData loadedMeshTerrainData = AssetDatabase.LoadAssetAtPath <MeshTerrainData>("Assets/MeshTerrainData/" + filename);
            meshTerrain.MeshTerrainData = loadedMeshTerrainData;
            meshTerrain.AddMeshRenderer(meshRenderer.gameObject, TerrainSourceID.TerrainSourceID1);
            meshTerrain.GenerateMeshTerrain();

            if (addToVegetationSystem)
            {
                VegetationStudioManager.AddTerrain(go, true);
            }
        }
    }
Exemple #4
0
 public void AddTerrainToVegetationSystem()
 {
     VegetationStudioManager.AddTerrain(gameObject, false);
 }