public static void ScaleGameObjectTo(GameObject go, object callbackTarget, Vector3 scale, float time, SA_EaseType easeType, Action OnCompleteAction) { SA_ValuesTween tw = go.AddComponent <SA_ValuesTween>(); tw.DestoryGameObjectOnComplete = false; tw.ScaleTo(go.transform.localScale, scale, time, easeType); tw.OnComplete.AddSafeListener(callbackTarget, OnCompleteAction); }
public static void RotateGameObjectTo(this GameObject go, object callbackTarget, Vector3 eulerRotation, float time, SA_EaseType easeType, Action OnCompleteAction) { SA_ValuesTween tw = go.AddComponent <SA_ValuesTween>(); tw.DestoryGameObjectOnComplete = false; tw.RotateTo(go.transform.rotation.eulerAngles, eulerRotation, time, easeType); tw.OnComplete.AddSafeListener(callbackTarget, OnCompleteAction); }
public static void MoveTo(this RectTransform transform, object callbackTarget, Vector2 position, float time, SA_EaseType easeType = SA_EaseType.linear, System.Action OnCompleteAction = null) { var tw = SA_ValuesTween.Create(); tw.VectorTo(transform.anchoredPosition, position, time, easeType); tw.DestoryGameObjectOnComplete = true; tw.OnVectorValueChanged.AddSafeListener(transform, (Vector3 pos) => { transform.anchoredPosition = pos; }); tw.OnComplete.AddSafeListener(callbackTarget, OnCompleteAction); }
//-------------------------------------- // Handlers //-------------------------------------- private void HandleOnInTweenComplete (){ _CurrentTween = null; }
private void Animate(float from, float to, SA_EaseType easeType) { _CurrentTween = SA_ValuesTween.Create(); _CurrentTween.OnValueChanged += HandleOnValueChanged; _CurrentTween.ValueTo(from, to, 0.5f, easeType); }
private void FadeOut() { _FaderTween = SA_ValuesTween.Create(); _FaderTween.OnValueChanged += HandleOnFadeValueChanged; _FaderTween.OnComplete += HandleFadeComplete; _FaderTween.ValueTo(0.5f, 0f, 0.5f, SA_EaseType.linear); }
//-------------------------------------- // Private Methods //-------------------------------------- private void FadeIn() { Fader.enabled = true; _FaderTween = SA_ValuesTween.Create(); _FaderTween.OnValueChanged += HandleOnFadeValueChanged; _FaderTween.ValueTo(0, 0.5f, 0.5f, SA_EaseType.linear); }
void HandleOnOutTweenComplete (){ _CurrentTween = null; }
void HandleOnInTweenComplete (){ _CurrentTween = null; Invoke("NotificationDelayComplete", 2f); }