示例#1
0
 private void Awake()
 {
     terrain = GetComponent <Terrain>();
     if (_treeManager == null)
     {
         _treeManager = FindObjectOfType <GPUInstancerTreeManager>();
     }
 }
        protected override void OnEnable()
        {
            base.OnEnable();

            wikiHash = "#The_Tree_Manager";

            _treeManager = (target as GPUInstancerTreeManager);
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            wikiHash = "#The_Tree_Manager";

            prop_initializeWithCoroutine = serializedObject.FindProperty("initializeWithCoroutine");

            _treeManager = (target as GPUInstancerTreeManager);
        }
示例#4
0
        private void MapMagicTerrainAddTreeManager(Terrain terrain)
        {
            if (terrain.GetComponent <GPUInstancerTreeManager>() == null && treePrototypes != null && treePrototypes.Count > 0)
            {
                GPUInstancerTreeManager newTreeManager = terrain.gameObject.AddComponent <GPUInstancerTreeManager>();
                newTreeManager.isFrustumCulling   = isFrustumCulling;
                newTreeManager.isOcclusionCulling = isOcclusionCulling;
                newTreeManager.minCullingDistance = minCullingDistance;
                newTreeManager.autoSelectCamera   = autoSelectCamera;
                newTreeManager.cameraData.SetCamera(cameraData.mainCamera);
                newTreeManager.cameraData.renderOnlySelectedCamera = cameraData.renderOnlySelectedCamera;
                newTreeManager.cameraData.hiZOcclusionGenerator    = null;
                newTreeManager.InitializeCameraData();
                // for mapmagic tree optimization
                if (terrain.terrainData.treePrototypes.Length != treePrototypes.Count)
                {
                    int terrainTreeIndex = 0;
                    List <GPUInstancerPrototype> newPrototypeList = new List <GPUInstancerPrototype>();
                    for (int i = 0; i < treePrototypes.Count; i++)
                    {
                        if (terrainTreeIndex >= terrain.terrainData.treePrototypes.Length)
                        {
                            break;
                        }

                        GPUInstancerTreePrototype tp = (GPUInstancerTreePrototype)treePrototypes[i];
                        if (!terrain.terrainData.treePrototypes[terrainTreeIndex].prefab == tp.prefabObject)
                        {
                            newPrototypeList.Add(tp);
                            terrainTreeIndex++;
                        }
                    }
                    newTreeManager.prototypeList = newPrototypeList;
                }
                else
                {
                    newTreeManager.prototypeList = treePrototypes;
                }
                newTreeManager.SetupManagerWithTerrain(terrain);

                newTreeManager.terrainSettings.maxTreeDistance = terrainSettings.maxTreeDistance;

                if (terrain.gameObject.activeSelf)
                {
                    newTreeManager.InitializeRuntimeDataAndBuffers();
                }
            }
        }
示例#5
0
 /// <summary>
 /// Use this method to remove terrains from Tree Manager at runtime
 /// </summary>
 /// <param name="manager">The GPUI Tree Manager to remove the terrain</param>
 /// <param name="terrain">Terrain to remove</param>
 public static void RemoveTerrainFromManager(GPUInstancerTreeManager manager, Terrain terrain)
 {
     manager.RemoveTerrain(terrain);
 }
示例#6
0
 /// <summary>
 /// Use this method to add new terrains to Tree Manager at runtime
 /// </summary>
 /// <param name="manager">The GPUI Tree Manager to add the new terrain</param>
 /// <param name="terrain">New terrain to render the trees</param>
 public static void AddTerrainToManager(GPUInstancerTreeManager manager, Terrain terrain)
 {
     manager.AddTerrain(terrain);
 }