void Start() { goList = new List <GPUInstancerPrefab>(); // Define the buffer to the Prefab Manager. if (prefabManager != null && prefabManager.isActiveAndEnabled) { GPUInstancerAPI.DefinePrototypeVariationBuffer <Vector4>(prefabManager, prefab.prefabPrototype, bufferName); } // Generate instances inside a radius. for (int i = 0; i < instances; i++) { GPUInstancerPrefab prefabInstance = Instantiate(prefab); prefabInstance.transform.localPosition = Random.insideUnitSphere * 20; prefabInstance.transform.SetParent(transform); goList.Add(prefabInstance); // Register the variation buffer for this instance. prefabInstance.AddVariation(bufferName, (Vector4)Random.ColorHSV()); } // Register the generated instances to the manager and initialize the manager. if (prefabManager != null && prefabManager.isActiveAndEnabled) { GPUInstancerAPI.RegisterPrefabInstanceList(prefabManager, goList); GPUInstancerAPI.InitializeGPUInstancer(prefabManager); } }
public void ReInitializeManagers() { for (int i = 0; i < terrainCounter; i++) { GPUInstancerDetailManager detailManager = terrainArray[i].GetComponent <GPUInstancerDetailManager>(); GPUInstancerAPI.InitializeGPUInstancer(detailManager); } }
private void Start() { if (prefabManager != null && prefabManager.gameObject.activeSelf && prefabManager.enabled) { GPUInstancerAPI.RegisterPrefabInstanceList(prefabManager, asteroidInstances); GPUInstancerAPI.InitializeGPUInstancer(prefabManager); } }
private void AddInstancer(Terrain terrain) { GPUInstancerDetailManager detailManager = terrain.gameObject.AddComponent <GPUInstancerDetailManager>(); GPUInstancerAPI.SetupManagerWithTerrain(detailManager, terrain); detailManager.terrainSettings.windVector = _windVector; // Can change prototype properties here if (detailManager.prototypeList.Count > 0) { GPUInstancerDetailPrototype detailPrototype = (GPUInstancerDetailPrototype)detailManager.prototypeList[0]; detailPrototype.detailHealthyColor = _healthyColor; detailPrototype.detailDryColor = _dryColor; detailPrototype.noiseSpread = _noiseSpread; detailPrototype.ambientOcclusion = _ambientOcclusion; detailPrototype.gradientPower = _gradientPower; detailPrototype.windIdleSway = _windIdleSway; detailPrototype.windWavesOn = _windWavesOn; detailPrototype.windWaveTint = _windWaveTint; detailPrototype.windWaveSize = _windWaveSize; detailPrototype.windWaveSway = _windWaveSway; detailPrototype.windWaveTintColor = _windWaveTintColor; detailPrototype.isBillboard = _isBillboard; detailPrototype.useCrossQuads = _useCrossQuads; detailPrototype.quadCount = _crossQuadCount; detailPrototype.billboardDistance = _crossQuadBillboardDistance; detailPrototype.detailScale = _scale; detailPrototype.isShadowCasting = _isShadowCasting; detailPrototype.isFrustumCulling = _isFrustumCulling; detailPrototype.frustumOffset = _frustumOffset; detailPrototype.maxDistance = _maxDistance; } GPUInstancerAPI.InitializeGPUInstancer(detailManager); }