1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace RenderHeads.Media.AVProVideo.Demos
- {
- public class Mapping3D : MonoBehaviour
- {
- private void Update()
- {
- this._timer -= Time.deltaTime;
- if (this._timer <= 0f)
- {
- this._timer = 0.25f;
- this.SpawnCube();
- if (this._cubes.Count > 48)
- {
- this.RemoveCube();
- }
- }
- }
- private void SpawnCube()
- {
- Quaternion rotation = Quaternion.Euler(UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f));
- float num = UnityEngine.Random.Range(0.1f, 0.6f);
- GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this._cubePrefab, base.transform.position, rotation);
- Transform component = gameObject.GetComponent<Transform>();
- component.localScale = new Vector3(num, num, num);
- this._cubes.Add(gameObject);
- }
- private void RemoveCube()
- {
- GameObject obj = this._cubes[0];
- this._cubes.RemoveAt(0);
- UnityEngine.Object.Destroy(obj);
- }
- public GameObject _cubePrefab;
- private const int MaxCubes = 48;
- private const float SpawnTime = 0.25f;
- private float _timer = 0.25f;
- private List<GameObject> _cubes = new List<GameObject>(32);
- }
- }
|