/// <summary> /// adds the IEnumerator to the CoroutineManager. Coroutines get ticked before Update is called each frame. /// </summary> /// <returns>The coroutine.</returns> /// <param name="enumerator">Enumerator.</param> public ICoroutine startCoroutine(IEnumerator enumerator) { // find or create a CoroutineImpl var coroutine = QuickCache <CoroutineImpl> .pop(); coroutine.prepareForReuse(); // setup the coroutine and add it coroutine.enumerator = enumerator; var shouldContinueCoroutine = tickCoroutine(coroutine); // guard against empty coroutines if (!shouldContinueCoroutine || coroutine.isDone) { coroutine.recycle(); QuickCache <CoroutineImpl> .push(coroutine); return(null); } if (_isInUpdate) { _shouldRunNextFrame.Add(coroutine); } else { _unblockedCoroutines.Add(coroutine); } return(coroutine); }
/// <summary> /// adds a Particle to the emitter /// </summary> void addParticle() { // take the next particle out of the particle pool we have created and initialize it var particle = QuickCache <Particle> .pop(); particle.initialize(_emitterConfig); _particles.Add(particle); }
public static ITween <Vector3> vector3PropertyTo(object self, string propertyName, Vector3 to, float duration) { var tweenTarget = new PropertyTarget <Vector3>(self, propertyName); var tween = TweenManager.cacheVector3Tweens ? QuickCache <Vector3Tween> .pop() : new Vector3Tween(); tween.initialize(tweenTarget, to, duration); return(tween); }
public static ITween <float> floatPropertyTo(object self, string propertyName, float to, float duration) { var tweenTarget = new PropertyTarget <float>(self, propertyName); var tween = TweenManager.cacheFloatTweens ? QuickCache <FloatTween> .pop() : new FloatTween(); tween.initialize(tweenTarget, to, duration); return(tween); }
public static ITween <Color> colorPropertyTo(object self, string propertyName, Color to, float duration) { var tweenTarget = new PropertyTarget <Color>(self, propertyName); var tween = TweenManager.cacheColorTweens ? QuickCache <ColorTween> .pop() : new ColorTween(); tween.initialize(tweenTarget, to, duration); return(tween); }
public static ITween <Quaternion> quaternionPropertyTo(object self, string propertyName, Quaternion to, float duration) { var tweenTarget = new PropertyTarget <Quaternion>(self, propertyName); var tween = TweenManager.cacheQuaternionTweens ? QuickCache <QuaternionTween> .pop() : new QuaternionTween(); tween.initialize(tweenTarget, to, duration); return(tween); }
/// <summary> /// schedules a one-time or repeating timer that will call the passed in Action /// </summary> /// <param name="timeInSeconds">Time in seconds.</param> /// <param name="repeats">If set to <c>true</c> repeats.</param> /// <param name="context">Context.</param> /// <param name="onTime">On time.</param> internal ITimer schedule(float timeInSeconds, bool repeats, object context, Action <ITimer> onTime) { var timer = QuickCache <Timer> .pop(); timer.initialize(timeInSeconds, repeats, context, onTime); _timers.Add(timer); return(timer); }
public static Vector2Tween create() { return(TweenManager.cacheVector2Tweens ? QuickCache <Vector2Tween> .pop() : new Vector2Tween()); }
public static FloatTween create() { return(TweenManager.cacheFloatTweens ? QuickCache <FloatTween> .pop() : new FloatTween()); }
public static RectangleTween create() { return(TweenManager.cacheRectTweens ? QuickCache <RectangleTween> .pop() : new RectangleTween()); }
public static ColorTween create() { return(TweenManager.cacheColorTweens ? QuickCache <ColorTween> .pop() : new ColorTween()); }
public static QuaternionTween create() { return(TweenManager.cacheQuaternionTweens ? QuickCache <QuaternionTween> .pop() : new QuaternionTween()); }
public static IntTween create() { return(TweenManager.cacheIntTweens ? QuickCache <IntTween> .pop() : new IntTween()); }