Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 private void Start()
 {
     if (prefabManager != null && prefabManager.gameObject.activeSelf && prefabManager.enabled)
     {
         GPUInstancerAPI.RegisterPrefabInstanceList(prefabManager, asteroidInstances);
         GPUInstancerAPI.InitializeGPUInstancer(prefabManager);
     }
 }