예제 #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());
        }