81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using UnityEngine;
|
|
using uNature.Core.FoliageClasses;
|
|
|
|
public class StartEditGrass : MonoBehaviour
|
|
{
|
|
public string editLayer = "Imposter";
|
|
|
|
public string defaultLayer = "Terrain";
|
|
|
|
public GameObject foliageManager;
|
|
|
|
public List<GameObject> terrains = new List<GameObject>();
|
|
|
|
public string defaultLayerUnderwater = "Default";
|
|
|
|
public List<GameObject> terrainsUnderwater = new List<GameObject>();
|
|
|
|
public static bool getMapPixels = true;
|
|
|
|
private void Awake()
|
|
{
|
|
FinishEdit();
|
|
}
|
|
|
|
[Button]
|
|
public void StartEdit()
|
|
{
|
|
foliageManager.transform.localPosition = new Vector3(foliageManager.transform.localPosition.x, 0f, foliageManager.transform.localPosition.z);
|
|
foreach (GameObject terrain in terrains)
|
|
{
|
|
terrain.layer = LayerMask.NameToLayer(editLayer);
|
|
}
|
|
foreach (GameObject item in terrainsUnderwater)
|
|
{
|
|
item.layer = LayerMask.NameToLayer(editLayer);
|
|
}
|
|
getMapPixels = true;
|
|
}
|
|
|
|
[Button]
|
|
public void FinishEdit()
|
|
{
|
|
foliageManager.transform.localPosition = new Vector3(foliageManager.transform.localPosition.x, 0f, foliageManager.transform.localPosition.z);
|
|
foreach (GameObject terrain in terrains)
|
|
{
|
|
if (terrain != null)
|
|
{
|
|
terrain.layer = LayerMask.NameToLayer(defaultLayer);
|
|
}
|
|
}
|
|
foreach (GameObject item in terrainsUnderwater)
|
|
{
|
|
if (item != null)
|
|
{
|
|
item.layer = LayerMask.NameToLayer(defaultLayerUnderwater);
|
|
}
|
|
}
|
|
getMapPixels = false;
|
|
}
|
|
|
|
[Button]
|
|
public void RemoveUnwantedGrassTextures()
|
|
{
|
|
FoliageManagerInstance[] componentsInChildren = GetComponentsInChildren<FoliageManagerInstance>();
|
|
GameController gameController = Object.FindObjectOfType<GameController>();
|
|
for (int i = 0; i < gameController.grassIds.Count; i++)
|
|
{
|
|
Debug.Log("grassIds: " + gameController.grassIds[i]);
|
|
}
|
|
for (int j = 0; j < componentsInChildren.Length; j++)
|
|
{
|
|
for (int k = 0; k < componentsInChildren[j]._serializedGrassMaps.Count; k++)
|
|
{
|
|
gameController.CheckGrassMapAndResize(componentsInChildren[j]._serializedGrassMaps[k]);
|
|
}
|
|
}
|
|
}
|
|
}
|