Changes to Effect Class
Post date:
2017-07-14 18:15
Project:
Assignee:
Labels:
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