PolygonLoopScript.cs 921 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace PolygonArsenal
  4. {
  5. public class PolygonLoopScript : MonoBehaviour
  6. {
  7. public GameObject chosenEffect;
  8. public float loopTimeLimit = 2.0f;
  9. void Start()
  10. {
  11. PlayEffect();
  12. }
  13. public void PlayEffect()
  14. {
  15. StartCoroutine("EffectLoop");
  16. }
  17. IEnumerator EffectLoop()
  18. {
  19. //GameObject effectPlayer = (GameObject)Instantiate(chosenEffect, transform.position, transform.rotation);
  20. GameObject effectPlayer = (GameObject)Instantiate(chosenEffect);
  21. effectPlayer.transform.position = transform.position;
  22. //effectPlayer.transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
  23. yield return new WaitForSeconds(loopTimeLimit);
  24. Destroy(effectPlayer);
  25. PlayEffect();
  26. }
  27. }
  28. }