Ejemplo n.º 1
0
        public static void UpdateSourceSystem(VegetationSystemPro srcSystem, Terrain terrain)
        {
            //erasing legacy settings on copyVS change
            //returning extents after using per-terrain systems
            VegetationSystemPro copySystem = VSProOps.GetCopyVegetationSystem(terrain);

            if (srcSystem.VegetationSystemBounds.extents.x < 1)
            {
                srcSystem.VegetationSystemBounds = new Bounds(
                    terrain.transform.position + terrain.terrainData.size / 2,
                    terrain.terrainData.size * 3.4f);
                srcSystem.RefreshVegetationSystem();
            }

            if (copySystem != null &&
                srcSystem.PersistentVegetationStorage != null &&
                srcSystem.PersistentVegetationStorage.PersistentVegetationStoragePackage == copySystem.PersistentVegetationStorage.PersistentVegetationStoragePackage)
            {
                srcSystem.PersistentVegetationStorage.InitializePersistentStorage();
            }

            if (copySystem != null)
            {
                GameObject.DestroyImmediate(copySystem.gameObject);
            }

            //unityterrain
            UnityTerrain unityTerrain = terrain.GetComponent <UnityTerrain>();             //VS Pro component added to terrain

            if (unityTerrain == null)
            {
                unityTerrain = VSProOps.AddUnityTerrain(terrain);
            }
            unityTerrain.TerrainPosition = terrain.transform.position;

            if (srcSystem != null && !srcSystem.VegetationStudioTerrainList.Contains(unityTerrain))                //check if already added since AddTerrain is long operation
            {
                srcSystem.AddTerrain(terrain.gameObject);
            }

            //refresh system (takes >100 ms)
            UnityEngine.Profiling.Profiler.BeginSample("VegetationSystemPro.RefreshVegetationSystem");
            srcSystem.RefreshVegetationSystem();
            UnityEngine.Profiling.Profiler.EndSample();
        }
Ejemplo n.º 2
0
            public void Apply(Terrain terrain)
            {
                //updating system
                VegetationSystemPro copySystem = null;                  //we'll need it to set up tile

                if (copyVS)
                {
                    copySystem = VSProOps.GetCopyVegetationSystem(terrain);
                    if (copySystem == null)
                    {
                        copySystem = VSProOps.CopyVegetationSystem(srcSystem, terrain.transform.parent);
                    }
                    VSProOps.UpdateCopySystem(copySystem, terrain, package, srcSystem);
                }

                else
                {
                    VSProOps.UpdateSourceSystem(srcSystem, terrain);
                }

                //applying
                Texture2D[] textures = WriteTextures(null, colors);
                VSProOps.SetTextures(
                    copyVS ? copySystem : srcSystem,
                    package, textures, maskGroupNums, terrain.GetWorldRect());

                //tile obj (serialization and disable purpose)
                Transform     tileTfm = terrain.transform.parent;
                VSProMapsTile vsTile  = tileTfm.GetComponent <VSProMapsTile>();

                if (vsTile == null)
                {
                    vsTile = tileTfm.gameObject.AddComponent <VSProMapsTile>();
                }
                vsTile.system        = copyVS ? copySystem : srcSystem;
                vsTile.package       = package;
                vsTile.terrainRect   = terrain.GetWorldRect();
                vsTile.textures      = textures;
                vsTile.maskGroupNums = maskGroupNums;
                vsTile.masksApplied  = true;
            }