Fix lorax culler
This commit is contained in:
parent
988bc076c9
commit
4f3e09cdae
@ -7,31 +7,38 @@ public class LoraxCuller : MonoBehaviour {
|
||||
public Transform ChunkKeepAliveTransformsParent;
|
||||
|
||||
private List<Transform> ChunkKeepAliveTransforms = new List<Transform>();
|
||||
private GameObject[,] EnabledChunks;
|
||||
private List<GameObject>[] EnabledChunks;
|
||||
|
||||
private void Awake() {
|
||||
EnabledChunks = new List<GameObject>[Loraces.Length];
|
||||
foreach (Transform Child in ChunkKeepAliveTransformsParent) {
|
||||
ChunkKeepAliveTransforms.Add(Child);
|
||||
}
|
||||
EnabledChunks = new GameObject[Loraces.Length, ChunkKeepAliveTransforms.Count];
|
||||
for (int LoraxIndex = 0; LoraxIndex < Loraces.Length; LoraxIndex++) {
|
||||
EnabledChunks[LoraxIndex] = new List<GameObject>();
|
||||
for (int ChunkIndex = 0; ChunkIndex < ChunkKeepAliveTransforms.Count; ChunkIndex++) {
|
||||
EnabledChunks[LoraxIndex].Add(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
for (int LoraxIndex = 0; LoraxIndex < Loraces.Length; LoraxIndex++) {
|
||||
for (int ChunkIndex = 0; ChunkIndex < ChunkKeepAliveTransforms.Count; ChunkIndex++) {
|
||||
GameObject OldChunk = EnabledChunks[LoraxIndex][ChunkIndex];
|
||||
if (OldChunk != null) {
|
||||
OldChunk.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int LoraxIndex = 0; LoraxIndex < Loraces.Length; LoraxIndex++) {
|
||||
Lorax Lorax = Loraces[LoraxIndex];
|
||||
for (int ChunkIndex = 0; ChunkIndex < ChunkKeepAliveTransforms.Count; ChunkIndex++) {
|
||||
Vector3 KeepAlivePosition = ChunkKeepAliveTransforms[ChunkIndex].position;
|
||||
|
||||
Debug.DrawLine(KeepAlivePosition, KeepAlivePosition + Vector3.up * 5, Color.red);
|
||||
GameObject NewChunk = Lorax.GetChunkAt(KeepAlivePosition.x, KeepAlivePosition.z);
|
||||
|
||||
if (EnabledChunks[LoraxIndex, ChunkIndex] != NewChunk) {
|
||||
if (EnabledChunks[LoraxIndex, ChunkIndex] != null) {
|
||||
EnabledChunks[LoraxIndex, ChunkIndex].SetActive(false);
|
||||
}
|
||||
NewChunk.SetActive(true);
|
||||
EnabledChunks[LoraxIndex, ChunkIndex] = NewChunk;
|
||||
}
|
||||
EnabledChunks[LoraxIndex][ChunkIndex] = NewChunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user