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 }
public static IEnumerator Apply(CoordRect rect, Terrain terrain, object dataBox, Func <float, bool> stop = null) { #if VEGETATION_STUDIO_PRO Dictionary <string, List <ObjectPool.Transition> > transitions = (Dictionary <string, List <ObjectPool.Transition> >)dataBox; VegetationStudioTile vsTile = terrain.GetComponent <VegetationStudioTile>(); if (vsTile == null) { vsTile = terrain.gameObject.AddComponent <VegetationStudioTile>(); } vsTile.lastUsedTransitions = new List <ObjectPool.Transition> [transitions.Count]; transitions.Values.CopyTo(vsTile.lastUsedTransitions, 0); vsTile.lastUsedObjectIds = new string[transitions.Count]; transitions.Keys.CopyTo(vsTile.lastUsedObjectIds, 0); vsTile.objectApplied = false; /* * float pixelSize = 1f * MapMagic.instance.terrainSize / MapMagic.instance.resolution; * Rect terrainRect = new Rect(rect.offset.x*pixelSize, rect.offset.z*pixelSize, rect.size.x*pixelSize, rect.size.z*pixelSize); * * //adding * foreach (KeyValuePair<Transform,List<ObjectPool.Transition>> kvp in transitions) * { * Transform prefab = kvp.Key; * List<ObjectPool.Transition> transitionsList = kvp.Value; * * IEnumerator e = MapMagic.instance.objectsPool.RepositionCoroutine( * prefab, * terrainRect, * transitionsList, * parent:terrain.transform, * root:MapMagic.instance.transform.position.sqrMagnitude>Mathf.Epsilon? MapMagic.instance.transform : null, //don't use root if it is placed in the center of the scene * objsPerFrame:500); * //not truly "per frame"\ * * while (e.MoveNext()) * { yield return null; } * } * * //clear all of non-included pools from rect * MapMagic.instance.objectsPool.ClearAllRectBut(terrainRect, transitions); * * //remove empty pools * MapMagic.instance.objectsPool.RemoveEmptyPools(); * * //hiding wireframe * if (MapMagic.instance.hideWireframe) MapMagic.instance.transform.ToggleDisplayWireframe(!MapMagic.instance.guiHideWireframe);*/ #endif yield return(null); }
public void Apply(Terrain terrain) { 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; }