private void PlayTween(TweenEvent tweenEvent) { //For UI tween event if (tweenEvent is UITweenEvent uiTweenEvent) { objectToTween.SetActive(true); //If this is a moving tween event if (uiTweenEvent.moving) { Tween <float> moveTween = objectToTween.TweenAnchoredPositionY(uiTweenEvent.moveTo, uiTweenEvent.duration); moveTween.SetFrom(uiTweenEvent.moveFrom); moveTween.SetOnComplete(() => OnEnd(uiTweenEvent.activeOnEnd)); } //This is a fading tween event if (uiTweenEvent.fading) { Tween <float> fadeTween = objectToTween.GetComponent <Graphic>() .TweenGraphicAlpha(uiTweenEvent.fadeTo, uiTweenEvent.duration); fadeTween.SetFrom(uiTweenEvent.fadeFrom); fadeTween.SetOnComplete(() => OnEnd(uiTweenEvent.activeOnEnd)); } } else { Logger.Error("Unsupported tween event type!"); } if (!Game.IsGameQuitting) { Logger.Debug("Played event {@Event}", tweenEvent.name); } }
/// <summary> /// Plays an event /// </summary> /// <param name="eventName"></param> public void PlayEvent(string eventName) { TweenEvent tweenEvent = eventsToPlay.FirstOrDefault(x => x.name == eventName); if (tweenEvent == null) { Logger.Error("There is no tween event called {EventName} on tween object {ObjectName}!", eventName, objectToTween.name); return; } PlayTween(tweenEvent); }