Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Instantiate512Cubes : MonoBehaviour
- {
- public GameObject cubePrefab;
- GameObject[] cube = new GameObject[512];
- public float maxScale;
- // Start is called before the first frame update
- void Start()
- {
- for (int i = 0; i < 512; i++)
- {
- GameObject instanceCube = (GameObject)Instantiate(cubePrefab);
- instanceCube.transform.position = this.transform.position; //centering in object
- instanceCube.transform.parent = this.transform;
- instanceCube.name = "SampleCube" + i;
- this.transform.eulerAngles = new Vector3(0, -0.703125f * i, 0);
- instanceCube.transform.position = Vector3.forward * 100;
- cube[i] = instanceCube;
- }
- }
- // Update is called once per frame
- void Update()
- {
- for (int i = 0; i < 512; i++)
- {
- if (cube != null)
- {
- cube[i].transform.localScale = new Vector3(10, (Audio.samples[i] * maxScale) + 2, 10);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement