123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System;
- namespace TerrainComposer2
- {
- public class TC_TerrainLayerGroup : TC_GroupBehaviour
- {
- List<TerrainLayerGroupItem> itemList = new List<TerrainLayerGroupItem>();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public override void GetItems(bool refresh, bool rebuildGlobalLists, bool resetTextures)
- {
- Transform child;
- TC_TerrainLayerGroup terrainLayerGroup;
- TC_TerrainLayer terrainLayer;
- int childCount = transform.childCount;
-
- itemList.Clear();
- lastActive = -1;
- totalActive = 0;
-
- bool newBounds = true;
- active = visible;
- int listIndex = 0;
- for (int i = childCount - 1; i >= 0; i--)
- {
- child = transform.GetChild(i);
- terrainLayer = child.GetComponent<TC_TerrainLayer>();
- if (terrainLayer != null)
- {
- terrainLayer.SetParameters(this, listIndex++);
- terrainLayer.terrainLevel = terrainLevel + 1;
- terrainLayer.GetItems(refresh, rebuildGlobalLists, resetTextures);
- terrainLayer.GetItem(outputId, rebuildGlobalLists, resetTextures);
-
- ++totalActive;
- itemList.Add(new TerrainLayerGroupItem(null, terrainLayer));
- lastActive = itemList.Count - 1;
- if (newBounds) { bounds = terrainLayer.bounds; newBounds = false; }
- else bounds.Encapsulate(terrainLayer.bounds);
-
-
- }
- else
- {
- terrainLayerGroup = child.GetComponent<TC_TerrainLayerGroup>();
- if (terrainLayerGroup != null)
- {
- terrainLayerGroup.SetParameters(this, listIndex++);
- terrainLayerGroup.terrainLevel = terrainLevel + 1;
- terrainLayerGroup.GetItems(refresh, rebuildGlobalLists, resetTextures);
-
- ++totalActive;
- itemList.Add(new TerrainLayerGroupItem(terrainLayerGroup, null));
- lastActive = itemList.Count - 1;
- if (newBounds) { bounds = terrainLayerGroup.bounds; newBounds = false; }
- else bounds.Encapsulate(terrainLayerGroup.bounds);
-
- }
- }
- }
- TC_Reporter.Log(TC.outputNames[outputId] + " Level " + level + " activeTotal " + totalActive);
- if (!active) totalActive = 0;
- else if (totalActive == 0) active = false; else active = visible;
- }
- }
- [Serializable]
- public class TerrainLayerGroupItem
- {
- public TC_TerrainLayerGroup terrainLayerGroup;
- public TC_TerrainLayer terrainLayer;
- public TerrainLayerGroupItem(TC_TerrainLayerGroup terrainLayerGroup, TC_TerrainLayer terrainLayer)
- {
- this.terrainLayer = terrainLayer;
- this.terrainLayerGroup = terrainLayerGroup;
- }
- }
- }
|