public static IEnumerator Apply(CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { #if VEGETATION_STUDIO_PRO TupleSet <Color[][], int[], VegetationPackagePro> splatsTuple = (TupleSet <Color[][], int[], VegetationPackagePro>)dataBox; Color[][] colors = splatsTuple.item1; int[] maskGroupNums = splatsTuple.item2; VegetationPackagePro package = splatsTuple.item3; if (colors.Length == 0) { Purge(rect, terrain); yield break; } VegetationStudioTile vsTile = terrain.GetComponent <VegetationStudioTile>(); if (vsTile == null) { vsTile = terrain.gameObject.AddComponent <VegetationStudioTile>(); } Texture2D[] textures = WriteTextures(vsTile.lastUsedTextures, colors); //Rect terrainRect = new Rect(terrain.transform.position.x, terrain.transform.position.z, terrain.terrainData.size.x, terrain.terrainData.size.z); //SetTextures(terrainRect, textures, maskGroupNums, package); vsTile.lastUsedTextures = textures; vsTile.lastUsedMaskGroupNums = maskGroupNums; vsTile.lastUsedPackage = package; vsTile.masksApplied = false; yield return(null); #else yield return(null); #endif }
/// <summary> /// Returns a unique list of all VegetationPackages used in the scene. /// </summary> /// <returns></returns> public static List <VegetationPackagePro> GetVegetationPackageList(BiomeType biomeType) { List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>(); if (!Instance) { FindInstance(); } if (!Instance) { return(vegetationPackageList); } for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i]; if (vegetationSystemPro) { VegetationPackagePro vegetationPackagePro = vegetationSystemPro.GetVegetationPackageFromBiome(biomeType); if (vegetationPackagePro) { vegetationPackageList.Add(vegetationPackagePro); } } } return(vegetationPackageList); }
public override void OnActionPerformed(VegetationPackagePro vegetationPackagePro, VegetationItemInfoPro vegetationItemInfoPro) { // apply settings GameObject vegetationPrefab = vegetationItemInfoPro.VegetationPrefab; VegetationType vegetationType = vegetationItemInfoPro.VegetationType; // support only grass & plants. doesn't make much sense to have trees and objects use touch react if (vegetationType != VegetationType.Grass && vegetationType != VegetationType.Plant) { Debug.Log("Only Grass & Plant supported. Skipping " + vegetationPrefab.name); return; } // get materials Material[] vegetationItemMaterials = AwesomeTechnologies.Shaders.ShaderSelector.GetVegetationItemMaterials(vegetationPrefab); // process items foreach (Material material in vegetationItemMaterials) { if (material.HasProperty(propertyId)) { Debug.Log("Setting _TouchReactActive of " + vegetationItemInfoPro.Name + ", material: " + material.name + " from " + material.GetFloat(propertyId) + " to " + propertyValue); material.SetFloat(propertyId, propertyValue); } } }
private TerrainLayer SaveTerrainLayer(TerrainLayer terrainLayer, VegetationPackagePro vegetationPackagePro) { #if UNITY_EDITOR if (!vegetationPackagePro) { return(terrainLayer); } string terrainDataPath = AssetDatabase.GetAssetPath(vegetationPackagePro); var directory = Path.GetDirectoryName(terrainDataPath); var filename = Path.GetFileNameWithoutExtension(terrainDataPath); var folderName = filename + "_TerrainLayers"; if (!AssetDatabase.IsValidFolder(directory + "/" + folderName)) { AssetDatabase.CreateFolder(directory, folderName); } terrainDataPath = terrainDataPath.Replace(".asset", ""); string newTerrainLayerDataPath = directory + "/" + folderName + "/_TerrainLayer_" + Guid.NewGuid().ToString() + ".asset"; AssetDatabase.CreateAsset(terrainLayer, newTerrainLayerDataPath); AssetDatabase.SaveAssets(); return(AssetDatabase.LoadAssetAtPath <TerrainLayer>(newTerrainLayerDataPath)); #else return(null); #endif }
public override void OnActionPerformed(VegetationPackagePro vegetationPackagePro, VegetationItemInfoPro vegetationItemInfoPro) { Debug.Log("Refreshing Prefab " + vegetationItemInfoPro.Name); // apply settings vegetationPackagePro.RefreshVegetationItemPrefab(vegetationItemInfoPro); }
public static void CreateYourScriptableObject() { VegetationPackagePro vegetationPackagePro = ScriptableObjectUtility.CreateAndReturnAsset <VegetationPackagePro>(); vegetationPackagePro.TerrainTextureCount = 0; vegetationPackagePro.InitPackage(); }
public override void OnActionPerformed(VegetationPackagePro vegetationPackagePro, VegetationItemInfoPro vegetationItemInfoPro) { Debug.Log("Setting Render Mode of " + vegetationItemInfoPro.Name + " from " + vegetationItemInfoPro.VegetationRenderMode + " to " + vegetationRenderMode); // apply settings vegetationItemInfoPro.VegetationRenderMode = vegetationRenderMode; }
public override void OnActionPerformed(VegetationPackagePro vegetationPackagePro, VegetationItemInfoPro vegetationItemInfoPro) { Debug.Log("Setting Runtime Spawn of " + vegetationItemInfoPro.Name + " from " + vegetationItemInfoPro.EnableRuntimeSpawn + " to " + enabled); // apply settings vegetationItemInfoPro.EnableRuntimeSpawn = enabled; }
public void ShowTerrainHeatmap(bool value) { if (!VegetationSystemPro) { return; } VegetationSystemPro.ShowHeatMap = value; if (value) { float worldspaceMinHeight = VegetationSystemPro.VegetationSystemBounds.center.y - VegetationSystemPro.VegetationSystemBounds.extents.y; float worldspaceSeaLevel = worldspaceMinHeight + VegetationSystemPro.SeaLevel; float worldspaceMaxHeight = VegetationSystemPro.VegetationSystemBounds.center.y + VegetationSystemPro.VegetationSystemBounds.extents.y; for (int i = 0; i <= VegetationSystemPro.VegetationStudioTerrainList.Count - 1; i++) { VegetationSystemPro.VegetationStudioTerrainList[i].OverrideTerrainMaterial(); VegetationPackagePro vegetationPackagePro = VegetationSystemPro.VegetationPackageProList[VegetationPackageIndex]; TerrainTextureSettings terrainTextureSettings = vegetationPackagePro.TerrainTextureSettingsList[VegetationPackageTextureIndex]; VegetationSystemPro.VegetationStudioTerrainList[i].UpdateTerrainMaterial(worldspaceSeaLevel, worldspaceMaxHeight, terrainTextureSettings); } } else { for (int i = 0; i <= VegetationSystemPro.VegetationStudioTerrainList.Count - 1; i++) { VegetationSystemPro.VegetationStudioTerrainList[i].RestoreTerrainMaterial(); } } }
public static void SetTextures(VegetationSystemPro system, VegetationPackagePro package, Texture2D[] textures, int[] maskGroupNums, Rect terrainRect) { for (int i = 0; i < textures.Length; i++) { Texture2D tex = textures[i]; if (tex == null) { continue; } TextureMaskGroup maskGroup = package.TextureMaskGroupList[maskGroupNums[i]]; //creating new mask only if the mask with the same rect doesn't exist TextureMask mask = maskGroup.TextureMaskList.Find(m => m.TextureRect == terrainRect); if (mask == null) { mask = new TextureMask { TextureRect = terrainRect }; maskGroup.TextureMaskList.Add(mask); } mask.MaskTexture = tex; } //VegetationSystemPro system = GameObject.FindObjectOfType<VegetationSystemPro>(); //if (system != null) // system.ClearCache(); //clearing cache causes flickering system.RefreshTerrainHeightmap(); }
public void AddVegetationPackage(VegetationPackagePro vegetationPackagePro) { if (!VegetationPackageProList.Contains(vegetationPackagePro)) { VegetationPackageProList.Add(vegetationPackagePro); } }
public static void CreateVegetationPackageObject16Textures() { VegetationPackagePro vegetationPackagePro = ScriptableObjectUtility.CreateAndReturnAsset <VegetationPackagePro>(); vegetationPackagePro.TerrainTextureCount = 16; vegetationPackagePro.InitPackage(); vegetationPackagePro.LoadDefaultTextures(); vegetationPackagePro.SetupTerrainTextureSettings(); }
public static List <string> CreateVegetationInfoIdList(VegetationPackagePro vegetationPackage) { List <string> resultList = new List <string>(); for (int i = 0; i <= vegetationPackage.VegetationInfoList.Count - 1; i++) { resultList.Add(vegetationPackage.VegetationInfoList[i].VegetationItemID); } return(resultList); }
public VegetationPackageProModelInfo(VegetationPackagePro vegetationPackagePro, EnvironmentSettings environmentSettings, List <GameObject> windSamplerList, int cameraCount) { EnvironmentSettings = environmentSettings; for (int i = 0; i <= vegetationPackagePro.VegetationInfoList.Count - 1; i++) { VegetationItemModelInfo vegetationItemModelInfo = new VegetationItemModelInfo(vegetationPackagePro.VegetationInfoList[i], EnvironmentSettings, windSamplerList, cameraCount); VegetationItemModelList.Add(vegetationItemModelInfo); } }
public void OnGUI(Layout layout, bool selected, int num, object parent) { #if VEGETATION_STUDIO_PRO VSProObjectsOutput vsOut = (VSProObjectsOutput)parent; VegetationPackagePro package = vsOut.package; //(VegetationPackagePro)vsOut.serializedPackage; VegetationSystemPro system = GameObject.FindObjectOfType <VegetationSystemPro>(); Layer layer = vsOut.baseLayers[num]; layout.margin = 20; layout.rightMargin = 5; layout.Par(20); input.DrawIcon(layout); if (package != null) { int itemInfoIndex = package.VegetationInfoList.FindIndex(i => i.VegetationItemID == layer.id); VegetationItemInfoPro itemInfo = itemInfoIndex >= 0 ? package.VegetationInfoList[itemInfoIndex] : null; Texture2D icon = null; if (itemInfo != null) { #if UNITY_EDITOR if (itemInfo.PrefabType == VegetationPrefabType.Mesh) { icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationPrefab); } else { icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationTexture); } #endif } layout.Icon(icon, rect: layout.Inset(20), frame: true, alphaBlend: false); layout.Inset(10); itemInfoIndex = layout.Popup(itemInfoIndex, objectNames, rect: layout.Inset(layout.field.width - 20 - 45)); if (itemInfoIndex >= 0) { layer.id = package.VegetationInfoList[itemInfoIndex].VegetationItemID; } } if (selected) { layout.Toggle(ref relativeHeight, "Relative Height"); layout.Toggle(ref rotate, "Rotate"); layout.Toggle(ref takeTerrainNormal, "Incline by Terrain"); layout.Par(); layout.Toggle(ref scale, "Scale", rect: layout.Inset(60)); layout.disabled = !scale; layout.Toggle(ref scaleY, rect: layout.Inset(18)); layout.Label("Y only", rect: layout.Inset(45)); //if (layout.lastChange) scaleU = false; layout.disabled = false; } #endif }
public override void OnActionPerformed(VegetationPackagePro vegetationPackagePro, VegetationItemInfoPro vegetationItemInfoPro) { // skip all which have runtime spawn enabled if (vegetationItemInfoPro.EnableRuntimeSpawn) { return; } Debug.Log("Deleting Vegetation Item " + vegetationItemInfoPro.Name); // apply settings vegetationPackagePro.VegetationInfoList.Remove(vegetationItemInfoPro); }
public static void DrawVSProMapsOut(VSProMapsOut gen) { #if VEGETATION_STUDIO_PRO VegetationPackagePro package = null; if (GraphWindow.current.mapMagic != null) { package = GraphWindow.current.mapMagic.globals.vegetationPackage as VegetationPackagePro; using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref package, "Package"); GraphWindow.current.mapMagic.globals.vegetationPackage = package; } //populating masks list to choose from if (package != null) { int masksCount = package.TextureMaskGroupList.Count; if (maskNames == null || maskNames.Length != masksCount) { maskNames = new string[masksCount]; } for (int i = 0; i < masksCount; i++) { maskNames[i] = (i + 1).ToString() + ". " + package.TextureMaskGroupList[i].TextureMaskName + " - " + package.TextureMaskGroupList[i].TextureMaskType; } } using (Cell.LineStd) { if (package != null) { Draw.PopupSelector(ref gen.maskGroup, maskNames, "Group"); } else { Draw.Field(ref gen.maskGroup, "Group"); } } using (Cell.LineStd) Draw.PopupSelector(ref gen.textureChannel, channelNames, "Channel"); #else using (Cell.LinePx(76)) Draw.Helpbox("Vegetation Studio Pro doesn't seem to be installed, or Vegetation Studio Pro compatibility is not enabled in settings"); using (Cell.LineStd) Draw.Field(ref gen.maskGroup, "Group"); using (Cell.LineStd) Draw.PopupSelector(ref gen.textureChannel, channelNames, "Channel"); #endif }
public static FinalizeAction finalizeAction = Finalize; //class identified for FinalizeData public static void Finalize(TileData data, StopToken stop) { #if VEGETATION_STUDIO_PRO //creating splats and prototypes arrays int layersCount = data.finalize.GetTypeCount(finalizeAction, data.subDatas); int splatsSize = data.area.active.rect.size.x; //preparing texture colors VegetationPackagePro package = data.globals.vegetationPackage as VegetationPackagePro; Color[][] colors = new Color[package != null ? package.TextureMaskGroupList.Count : 0][]; for (int c = 0; c < colors.Length; c++) { colors[c] = new Color[splatsSize * splatsSize]; } int[] maskGroupNums = new int[colors.Length]; //filling colors int i = 0; foreach ((VSProMapsOut output, MatrixWorld matrix, MatrixWorld biomeMask) in data.finalize.ProductSets <VSProMapsOut, MatrixWorld, MatrixWorld>(finalizeAction, data.subDatas)) { if (matrix == null || package == null) { continue; } BlendLayer(colors, data.area, matrix, biomeMask, output.density, output.maskGroup, output.textureChannel, stop); maskGroupNums[i / 4] = output.maskGroup; i++; } //pushing to apply if (stop != null && stop.stop) { return; } ApplyData applyData = new ApplyData() { srcSystem = data.globals.vegetationSystem as VegetationSystemPro, package = package, colors = colors, maskGroupNums = maskGroupNums, copyVS = data.globals.vegetationSystemCopy }; Graph.OnBeforeOutputFinalize?.Invoke(typeof(VSProMapsOut), data, applyData, stop); data.apply.Add(applyData); #endif }
public static FinalizeAction finalizeAction = Finalize; //class identified for FinalizeData public static void Finalize(TileData data, StopToken stop) { #if VEGETATION_STUDIO_PRO //creating splats and prototypes arrays int layersCount = data.OutputsCount(finalizeAction, inSubs: true); int splatsSize = data.area.active.rect.size.x; //preparing texture colors VegetationPackagePro package = data.globals.vegetationPackage as VegetationPackagePro; Color[][] colors = new Color[package != null ? package.TextureMaskGroupList.Count : 0][]; for (int c = 0; c < colors.Length; c++) { colors[c] = new Color[splatsSize * splatsSize]; } int[] maskGroupNums = new int[colors.Length]; //filling colors int i = 0; foreach ((VSProMapsOut output, MatrixWorld matrix, MatrixWorld biomeMask) in data.Outputs <VSProMapsOut, MatrixWorld, MatrixWorld>(typeof(VSProMapsOut), inSubs:true)) { if (matrix == null || package == null) { continue; } BlendLayer(colors, data.area, matrix, biomeMask, output.density, output.maskGroup, output.textureChannel, stop); maskGroupNums[output.maskGroup] = output.maskGroup; //TODO: removed i/4, test this! (http://mm2.idea.informer.com/proj/?ia=134562) i++; } //pushing to apply if (stop != null && stop.stop) { return; } ApplyData applyData = new ApplyData() { srcSystem = data.globals.vegetationSystem as VegetationSystemPro, package = package, colors = colors, maskGroupNums = maskGroupNums, copyVS = data.globals.vegetationSystemCopy }; Graph.OnOutputFinalized?.Invoke(typeof(VSProMapsOut), data, applyData, stop); data.MarkApply(applyData); #endif }
public void SetupRuntimePrefabSystem() { if (!VegetationSystemPro) { return; } DisposeRuntimePrefabSystem(); CreateRuntimePrefabParent(); VisibleVegetationCellSelector = new VisibleVegetationCellSelector(); for (int i = 0; i <= VegetationSystemPro.VegetationPackageProList.Count - 1; i++) { VegetationPackagePro vegetationPackagePro = VegetationSystemPro.VegetationPackageProList[i]; VegetationPackageRuntimePrefabInfo vegetationPackageRuntimePrefabInfo = new VegetationPackageRuntimePrefabInfo(); for (int j = 0; j <= vegetationPackagePro.VegetationInfoList.Count - 1; j++) { VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j]; VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo = new VegetationItemRuntimePrefabInfo(); for (int k = 0; k <= vegetationItemInfoPro.RuntimePrefabRuleList.Count - 1; k++) { RuntimePrefabRule runtimePrefabRule = vegetationItemInfoPro.RuntimePrefabRuleList[k]; RuntimePrefabManager runtimePrefabManager = new RuntimePrefabManager(VisibleVegetationCellSelector, VegetationSystemPro, vegetationItemInfoPro, runtimePrefabRule, _runtimePrefabParent, ShowRuntimePrefabs); vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Add(runtimePrefabManager); } vegetationPackageRuntimePrefabInfo.RuntimePrefabManagerList.Add(vegetationItemRuntimePrefabInfo); } PackageRuntimePrefabInfoList.Add(vegetationPackageRuntimePrefabInfo); } VisibleVegetationCellSelector.Init(VegetationSystemPro); }
private void ChangeTerrainTextureCount(VegetationPackagePro vegetationPackagePro, int newCount) { if (vegetationPackagePro.TerrainTextureCount == newCount) { return; } if (newCount > vegetationPackagePro.TerrainTextureCount) { vegetationPackagePro.TerrainTextureCount = newCount; vegetationPackagePro.LoadDefaultTextures(); vegetationPackagePro.SetupTerrainTextureSettings(); } else { vegetationPackagePro.TerrainTextureCount = newCount; vegetationPackagePro.ResizeTerrainTextureList(newCount); vegetationPackagePro.ResizeTerrainTextureSettingsList(newCount); } }
public void SetupColliderSystem() { if (!VegetationSystemPro) { return; } DisposeColliderSystem(); JobHandleList = new NativeList <JobHandle>(64, Allocator.Persistent); CreateColliderParent(); VisibleVegetationCellSelector = new VisibleVegetationCellSelector(); for (int i = 0; i <= VegetationSystemPro.VegetationPackageProList.Count - 1; i++) { VegetationPackagePro vegetationPackagePro = VegetationSystemPro.VegetationPackageProList[i]; VegetationPackageColliderInfo vegetationPackageColliderInfo = new VegetationPackageColliderInfo(); for (int j = 0; j <= vegetationPackagePro.VegetationInfoList.Count - 1; j++) { VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j]; if (vegetationItemInfoPro.ColliderType != ColliderType.Disabled) { ColliderManager tmpColliderManager = new ColliderManager(VisibleVegetationCellSelector, VegetationSystemPro, vegetationItemInfoPro, _colliderParent, ShowColliders); tmpColliderManager.OnCreateColliderDelegate += OnCreateCollider; tmpColliderManager.OnBeforeDestroyColliderDelegate += OnBeforeDestroyCollider; vegetationPackageColliderInfo.ColliderManagerList.Add(tmpColliderManager); } else { vegetationPackageColliderInfo.ColliderManagerList.Add(null); } } PackageColliderInfoList.Add(vegetationPackageColliderInfo); } VisibleVegetationCellSelector.Init(VegetationSystemPro); }
void LoadAssetToManager(string AssetName) { TerrainLayers = new TerrainLayer[0]; AssetDatabase.StartAssetEditing(); for (int i = 0; i < VPI.Length; i++) { if (VPI[i].PopupName == AssetName) { VegetationPackage = (VegetationPackagePro)AssetDatabase.LoadAssetAtPath(VPI[i]._VegetationPackage, typeof(VegetationPackagePro)); CTSProfilePackage = (CTSProfile)AssetDatabase.LoadAssetAtPath(VPI[i]._CTSProfile, typeof(CTSProfile)); for (int index = 0; index < VPI[i].TerrainLayersCount; index++) { TerrainLayers = TerrainLayers.Concat(new TerrainLayer[] { (TerrainLayer)AssetDatabase.LoadAssetAtPath(VPI[i]._TerrainLayers[index], typeof(TerrainLayer)) }).ToArray(); } } } AssetDatabase.StopAssetEditing(); }
static void DrawSelectedName(string vegetationItemID, VegetationPackagePro vegetationPackage) { if (vegetationItemID != "") { GUIStyle selectedStyle = new GUIStyle("Label") { fontStyle = FontStyle.Italic, richText = true }; //GUIStyle if (EditorGUIUtility.isProSkin) { LabelStyle.normal.textColor = new Color(1f, 1f, 1f); } else { LabelStyle.normal.textColor = new Color(0f, 0f, 0f); } VegetationItemInfoPro vegetationItemInfo = vegetationPackage.GetVegetationInfo(vegetationItemID); EditorGUILayout.LabelField("Selected: <b>" + vegetationItemInfo.Name + "</b>", selectedStyle); } }
public void GetSplatPrototypesFromTerrain(VegetationPackagePro vegetationPackage) { for (int i = 0; i <= VegetationSystemPro.VegetationStudioTerrainList.Count - 1; i++) { IVegetationStudioTerrain iVegetationStudioTerrain = VegetationSystemPro.VegetationStudioTerrainList[i]; if (iVegetationStudioTerrain.HasTerrainTextures()) { #if UNITY_2018_3_OR_NEWER TerrainLayer[] terrainLayers = iVegetationStudioTerrain.GetTerrainLayers(); for (int j = 0; j <= vegetationPackage.TerrainTextureList.Count - 1; j++) { if (j < terrainLayers.Length) { vegetationPackage.TerrainTextureList[j].Texture = terrainLayers[j].diffuseTexture; vegetationPackage.TerrainTextureList[j].TextureNormals = terrainLayers[j].normalMapTexture; vegetationPackage.TerrainTextureList[j].Offset = terrainLayers[j].tileOffset; vegetationPackage.TerrainTextureList[j].TileSize = terrainLayers[j].tileSize; } } break; #else SplatPrototype[] splatPrototypes = iVegetationStudioTerrain.GetSplatPrototypes(); for (int j = 0; j <= vegetationPackage.TerrainTextureList.Count - 1; j++) { if (j < splatPrototypes.Length) { vegetationPackage.TerrainTextureList[j].Texture = splatPrototypes[j].texture; vegetationPackage.TerrainTextureList[j].TextureNormals = splatPrototypes[j].normalMap; vegetationPackage.TerrainTextureList[j].Offset = splatPrototypes[j].tileOffset; vegetationPackage.TerrainTextureList[j].TileSize = splatPrototypes[j].tileSize; } } break; #endif } } }
public void BakeCollidersToScene() { for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++) { VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i]; VegetationPackagePro vegetationPackagePro = VegetationSystemPro.VegetationPackageProList[i]; for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++) { VegetationItemInfoPro vegetationItemInfoPro = vegetationPackagePro.VegetationInfoList[j]; if (!vegetationItemInfoPro.ColliderUseForBake) { continue; } ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j]; if (colliderManager != null) { BakeVegetationItemColliders(colliderManager, vegetationItemInfoPro); } } } }
private int GetTerrainTextureIndex(VegetationPackagePro vegetationPackage) { switch (vegetationPackage.TerrainTextureCount) { case 0: return(0); case 4: return(1); case 8: return(2); case 12: return(3); case 16: return(4); } return(0); }
void ConnectToCTI_VSP(CTSProfile profile, VegetationPackagePro PackagePro) { CTSTerrainManager.Instance.AddCTSToAllTerrains(); CTSTerrainManager.Instance.BroadcastProfileSelect(profile); VegetationStudioManager vegetationStudioManager = FindObjectOfType <VegetationStudioManager>(); if (!vegetationStudioManager) { GameObject go = new GameObject { name = "VegetationStudioPro" }; go.AddComponent <VegetationStudioManager>(); GameObject vegetationSystem = new GameObject { name = "VegetationSystemPro" }; vegetationSystem.transform.SetParent(go.transform); VSP = vegetationSystem.AddComponent <VegetationSystemPro>(); vegetationSystem.AddComponent <TerrainSystemPro>(); VSP.AddAllUnityTerrains(); VSP.AddVegetationPackage(PackagePro); PackagePro.SetupTerrainTextureSettings(); #if TOUCH_REACT GameObject touchReactSystem = new GameObject { name = "TouchReactSystem" }; touchReactSystem.transform.SetParent(go.transform); touchReactSystem.AddComponent <TouchReactSystem>(); #endif vegetationSystem.AddComponent <ColliderSystemPro>(); vegetationSystem.AddComponent <PersistentVegetationStorage>(); RuntimePrefabSpawner runtimePrefabSpawner = vegetationSystem.AddComponent <RuntimePrefabSpawner>(); runtimePrefabSpawner.enabled = false; } }
void CreateVegetationPackage() { var v = new VegetationPackagePro(); v.name = VegetationPackageName; switch (VegetationPackageTextureCount) { case TerrainTextureCount.None: v.TerrainTextureCount = 0; break; case TerrainTextureCount.Four: v.TerrainTextureCount = 4; break; case TerrainTextureCount.Eight: v.TerrainTextureCount = 8; break; case TerrainTextureCount.Twelve: v.TerrainTextureCount = 12; break; case TerrainTextureCount.Sixteen: v.TerrainTextureCount = 16; break; } v.InitPackage(); v.LoadDefaultTextures(); v.SetupTerrainTextureSettings(); AssetDatabase.CreateAsset(v, pathMain + "/" + v.name + ".asset"); VPI[VPI.Length - 1].PopupName = v.name; VPINames = VPINames.Concat(new string[] { v.name }).ToArray(); VPI[VPI.Length - 1]._VegetationPackage = (pathMain + "/" + v.name + ".asset"); VegetationPackage = v; }
public static void FlushTextures(Rect terrainRect, VegetationPackagePro package) { if (package == null) { return; } foreach (TextureMaskGroup maskGroup in package.TextureMaskGroupList) { for (int i = maskGroup.TextureMaskList.Count - 1; i >= 0; i--) { TextureMask mask = maskGroup.TextureMaskList[i]; if (mask.MaskTexture == null || mask.TextureRect == terrainRect) { mask.Dispose(); maskGroup.TextureMaskList.RemoveAt(i); //if (system != null) system.SelectedTextureMaskGroupTextureIndex = 0; } } } //if (system != null) // system.ClearCache(); }