Changes to Effect Class

Author: 
el_bearduno
el_bearduno's picture
Assignee: 
Status: 
Priority: 
Milestone: 
Alpha 1.0

Effect

  • Adding effect loop ability

 

Create new class

 

EffectController

enum PlayType { ON_CREATE, LOOP, ON_DESTROY }

public class EffectController
{
    Effect effect;
    PlayType playType;
    float loopTime;

    void OnAwake() 
    {
        if (playType == PlayType.ON_CREATE)
        {
            effect.Play();
        }
        if (playType == PlayType.LOOP)
        {
            StartCoroutine(PlayLoopingEffect(0, this));
        }
    }

    void OnDestroy() 
    {
        if (playType == PlayType.ON_DESTROY)
        {
            effect.Play();
        }

        //Find all PlayLoopingEffect threads and kill them.
    }

    IEnumerator PlayLoopingEffect(delay, EffectController effectController)
    {
        if (effectController != null) //If the effectController is destroyed. 
        {
            yield return new WaitForSeconds(delay);

            effect.Play();
            StartCoroutine(PlayLoopingEffect(loopTime, effectController));
        }
    }
}

 

Add new comment

Basic Editor

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain Text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.