Mapping3D.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace RenderHeads.Media.AVProVideo.Demos
  5. {
  6. public class Mapping3D : MonoBehaviour
  7. {
  8. private void Update()
  9. {
  10. this._timer -= Time.deltaTime;
  11. if (this._timer <= 0f)
  12. {
  13. this._timer = 0.25f;
  14. this.SpawnCube();
  15. if (this._cubes.Count > 48)
  16. {
  17. this.RemoveCube();
  18. }
  19. }
  20. }
  21. private void SpawnCube()
  22. {
  23. Quaternion rotation = Quaternion.Euler(UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f), UnityEngine.Random.Range(-180f, 180f));
  24. float num = UnityEngine.Random.Range(0.1f, 0.6f);
  25. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this._cubePrefab, base.transform.position, rotation);
  26. Transform component = gameObject.GetComponent<Transform>();
  27. component.localScale = new Vector3(num, num, num);
  28. this._cubes.Add(gameObject);
  29. }
  30. private void RemoveCube()
  31. {
  32. GameObject obj = this._cubes[0];
  33. this._cubes.RemoveAt(0);
  34. UnityEngine.Object.Destroy(obj);
  35. }
  36. public GameObject _cubePrefab;
  37. private const int MaxCubes = 48;
  38. private const float SpawnTime = 0.25f;
  39. private float _timer = 0.25f;
  40. private List<GameObject> _cubes = new List<GameObject>(32);
  41. }
  42. }