コード例 #1
0
        // Use this for initialization
        private void Awake()
        {
            // min buffersize check
            if (bufferSize < 1000)
                bufferSize = 1000;
            // initialize the array with the max size
            _matrix4x4Array = new Matrix4x4[bufferSize];
            // change the data of the array
            AddMatrix4x4ToArray(1000);

            // initialize the buffers with array
            GPUInstancerAPI.InitializeWithMatrix4x4Array(prefabManager, prefab.prefabPrototype, _matrix4x4Array);
            GPUInstancerAPI.SetInstanceCount(prefabManager, prefab.prefabPrototype, sphereCount);

            // Color variatons
            variationData = new Vector4[bufferSize];
            for (int i = 0; i < bufferSize; i++)
                variationData[i] = Random.ColorHSV();
            GPUInstancerAPI.DefineAndAddVariationFromArray(prefabManager, prefab.prefabPrototype, bufferName, variationData);

            // UI
            CheckButtonsAvailablity();
            // Start Update Positions coroutine
            StartCoroutine(UpdatePositions());

            StartCoroutine(UpdateScale());

            StartCoroutine(UpdateColors());
        }
コード例 #2
0
 public void RemoveSpheres()
 {
     RemoveMatrix4x4FromArray(1000);
     // UI
     CheckButtonsAvailablity();
     // set updated transform data
     GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array(prefabManager, prefab.prefabPrototype, _matrix4x4Array,
         sphereCount, sphereCount, 1000);
     GPUInstancerAPI.SetInstanceCount(prefabManager, prefab.prefabPrototype, sphereCount);
 }
コード例 #3
0
 public void ClearSpheres()
 {
     sphereCount = 0;
     // UI
     CheckButtonsAvailablity();
     // clear array
     _matrix4x4Array = new Matrix4x4[bufferSize];
     // set updated transform data
     GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array(prefabManager, prefab.prefabPrototype, _matrix4x4Array);
     GPUInstancerAPI.SetInstanceCount(prefabManager, prefab.prefabPrototype, sphereCount);
 }
コード例 #4
0
 public void AddSpheres()
 {
     int previousSphereCount = sphereCount;
     AddMatrix4x4ToArray(1000);
     // UI
     CheckButtonsAvailablity();
     // set updated transform data
     GPUInstancerAPI.UpdateVisibilityBufferWithMatrix4x4Array(prefabManager, prefab.prefabPrototype, _matrix4x4Array,
         previousSphereCount, previousSphereCount, 1000);
     GPUInstancerAPI.SetInstanceCount(prefabManager, prefab.prefabPrototype, sphereCount);
 }