//Prepare public void CheckAddComponent(Chunk chunk) { #if VEGETATION_STUDIO Profiler.BeginSample("VS Prepare"); //adding the main vegetation object VegetationStudioManager.AddVegetationStudioManagerToScene(); //checking if all packs for all of the generators are the same if (packageShared == null) { packageShared = package; } else { package = packageShared; } //finding/creating vegetation system component VegetationSystem vetSys = chunk.terrain.gameObject.GetComponentInChildren <VegetationSystem>(); if (vetSys == null) { vetSys = VegetationStudioManager.AddVegetationSystemToTerrain(chunk.terrain, package, createPersistentVegetationStoragePackage: true); } if (vetSys.VegetationPackageList.Count == 0) { vetSys.VegetationPackageList.Add(package); } if (vetSys.VegetationPackageList.Count == 1 && vetSys.VegetationPackageList[0] == null) { vetSys.VegetationPackageList[0] = package; } if (!vetSys.VegetationPackageList.Contains(package)) { vetSys.VegetationPackageList.Add(package); } if (!vetSys.InitDone) { vetSys.SetupVegetationSystem(); vetSys.RefreshVegetationPackage(); } cellSize = vetSys.CellSize; //saving per-chunk storage (to access it from thread) PersistentVegetationStorage storage = vetSys.gameObject.GetComponent <PersistentVegetationStorage>(); if (!vetStorComponents.ContainsKey(chunk.rect)) { vetStorComponents.Add(chunk.rect, null); } vetStorComponents[chunk.rect] = storage; Profiler.EndSample(); #endif }