MegaSpawnTest.cs 691 B

12345678910111213141516171819202122232425262728293031323334353637
  1. 
  2. using UnityEngine;
  3. #if !UNITY_METRO && !UNITY_WP8
  4. public class MegaSpawnTest : MonoBehaviour
  5. {
  6. public GameObject spawnobj;
  7. public Vector3 range = new Vector3(4.0f, 0.0f, 4.0f);
  8. public float time = 1.73170f;
  9. float t = 0.0f;
  10. void Update()
  11. {
  12. t += Time.deltaTime;
  13. if ( t > time )
  14. {
  15. t -= time;
  16. Vector3 pos = Vector3.zero;
  17. pos.x = Random.Range(-range.x, range.x);
  18. pos.y = Random.Range(-range.y, range.y);
  19. pos.z = Random.Range(-range.z, range.z);
  20. GameObject newobj = MegaCopyObject.DeepCopy(spawnobj);
  21. newobj.transform.position = pos;
  22. MegaMorph mor = newobj.GetComponent<MegaMorph>();
  23. if ( mor )
  24. {
  25. mor.animtime = 0.0f;
  26. }
  27. }
  28. }
  29. }
  30. #endif