public static VegetationSystemPro UpdateCopySystem(VegetationSystemPro copySystem, Terrain terrain, VegetationPackagePro package, VegetationSystemPro srcSystem) { Transform tileTfm = terrain.transform.parent; //erasing legacy settings on copyVS change //checking if src system has any extents, and resetting them - otherwise refreshing clone systems will take too long if (srcSystem.VegetationSystemBounds.extents.x > 1) { srcSystem.VegetationSystemBounds = new Bounds(Vector3.zero, Vector3.zero); srcSystem.RefreshVegetationSystem(); } if (srcSystem.VegetationStudioTerrainObjectList.Count != 0) { srcSystem.RemoveAllTerrains(); } //unityterrain UnityTerrain unityTerrain = terrain.GetComponent <UnityTerrain>(); //VS Pro component added to terrain if (unityTerrain == null) { unityTerrain = VSProOps.AddUnityTerrain(terrain); } unityTerrain.TerrainPosition = terrain.transform.position; //resetting clone package just in case if (copySystem.VegetationPackageProList.Count == 0 || copySystem.VegetationPackageProList[0] != package) { copySystem.VegetationPackageProList.Clear(); copySystem.AddVegetationPackage(package); } //reset bounds copySystem.AutomaticBoundsCalculation = false; copySystem.VegetationSystemBounds = new Bounds( //or use unityTerrain.TerrainBounds; terrain.terrainData.bounds.center + terrain.transform.position, terrain.terrainData.bounds.extents * 2); //add terrain if (copySystem.VegetationStudioTerrainObjectList.Count != 1 || copySystem.VegetationStudioTerrainObjectList[0] != terrain.gameObject) { if (copySystem.VegetationStudioTerrainObjectList.Count != 0) { copySystem.RemoveAllTerrains(); } copySystem.AddTerrain(terrain.gameObject); //will call RefreshVegetationStudioTerrains and RefreshVegetationStudioTerrains } //clearing storage if (copySystem.PersistentVegetationStorage.PersistentVegetationStoragePackage == null) { copySystem.PersistentVegetationStorage.PersistentVegetationStoragePackage = ScriptableObject.CreateInstance <PersistentVegetationStoragePackage>(); //new PersistentVegetationStoragePackage(); //changed on feedback from forum } //clearing is done in apply //refresh system (takes >100 ms) UnityEngine.Profiling.Profiler.BeginSample("VegetationSystemPro.RefreshVegetationSystem"); // copySystem.RefreshVegetationSystem(); if (copySystem != null) //re-initializing { copySystem.enabled = false; copySystem.enabled = true; //to call private OnEnable } UnityEngine.Profiling.Profiler.EndSample(); return(copySystem); }