private void MapMagicTerrainAddPrefabManager(Terrain terrain) { if (terrain.GetComponent <GPUInstancerPrefabManager>() == null && prefabPrototypes != null && prefabPrototypes.Count > 0) { GPUInstancerPrefab[] prefabList = terrain.gameObject.GetComponentsInChildren <GPUInstancerPrefab>(true); if (prefabList.Length > 0) { GPUInstancerPrefabManager newPrefabManager = terrain.gameObject.AddComponent <GPUInstancerPrefabManager>(); newPrefabManager.isFrustumCulling = isFrustumCulling; newPrefabManager.isOcclusionCulling = isOcclusionCulling; newPrefabManager.minCullingDistance = minCullingDistance; newPrefabManager.autoSelectCamera = autoSelectCamera; newPrefabManager.cameraData.SetCamera(cameraData.mainCamera); newPrefabManager.cameraData.renderOnlySelectedCamera = cameraData.renderOnlySelectedCamera; newPrefabManager.cameraData.hiZOcclusionGenerator = null; newPrefabManager.InitializeCameraData(); newPrefabManager.enableMROnManagerDisable = false; newPrefabManager.prototypeList = prefabPrototypes; newPrefabManager.RegisterPrefabInstanceList(prefabList); if (terrain.gameObject.activeSelf) { newPrefabManager.InitializeRuntimeDataAndBuffers(); } } } }
/// <summary> /// <para>Registers a list of prefab instances with GPU Instancer. You must use <see cref="InitializeGPUInstancer"/> after registering these prefabs for final initialization.</para> /// <para>The prefabs of the instances in this list must be previously defined in the given manager (either at runtime or editor time).</para> /// </summary> /// <param name="manager">The manager that defines the prototypes you want to GPU instance.</param> /// <param name="prefabInstanceList">The list of prefabs instances to GPU instance.</param> public static void RegisterPrefabInstanceList(GPUInstancerPrefabManager manager, IEnumerable <GPUInstancerPrefab> prefabInstanceList) { manager.RegisterPrefabInstanceList(prefabInstanceList); }