static public NDTweenWorker To(GameObject target, float timeInSeconds, Vector2 position, Vector2 scale, Vector3 rotation, float alpha, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true) { return(NDUITween.CreateTweenWorker( true, target, position, scale, rotation, alpha, timeInSeconds, easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay )); }
//position, scale, rotation, alpha static public NDTweenWorker To(GameObject target, float timeInSeconds, Vector2 position, NDTweenOptions opts) { RectTransform rTransform = target.GetComponent <RectTransform>(); return(NDUITween.To(target, timeInSeconds, position, rTransform.localScale, rTransform.localRotation.eulerAngles, NDUITween.GetCurrentAlpha(target), opts.easing, opts.delay, opts.destroyOnComplete, opts.clearCurrentTweens, opts.autoPlay)); }
static public NDTweenWorker AlphaTo(GameObject target, float timeInSeconds, float alpha, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true) { RectTransform rTransform = target.GetComponent <RectTransform>(); return(NDUITween.To(target, timeInSeconds, rTransform.anchoredPosition, rTransform.localScale, rTransform.localRotation.eulerAngles, alpha, easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay)); }
static public NDTweenWorker To(GameObject target, float timeInSeconds, Vector2 position, Vector2 scale, Vector3 rotation, float alpha, NDTweenOptions opts) { return(NDUITween.To(target, timeInSeconds, position, scale, rotation, alpha, opts.easing, opts.delay, opts.destroyOnComplete, opts.clearCurrentTweens, opts.autoPlay)); }
static public NDTweenWorker RotateFrom(GameObject target, float timeInSeconds, Vector3 rotation, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true) { RectTransform rTransform = target.GetComponent <RectTransform>(); return(NDUITween.From(target, timeInSeconds, rTransform.anchoredPosition, rTransform.localScale, rotation, NDUITween.GetCurrentAlpha(target), easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay)); }
static public NDTweenWorker RotateFrom(GameObject target, float timeInSeconds, Vector3 rotation, NDTweenOptions opts) { RectTransform rTransform = target.GetComponent <RectTransform>(); return(NDUITween.From(target, timeInSeconds, rTransform.anchoredPosition, rTransform.localScale, rotation, NDUITween.GetCurrentAlpha(target), opts.easing, opts.delay, opts.destroyOnComplete, opts.clearCurrentTweens, opts.autoPlay)); }
static public NDTweenWorker From(GameObject target, float timeInSeconds, Vector2 position, Vector2 scale, Vector3 rotation, Func <float, float> easing = null, float delay = 0f, bool destroyOnComplete = true, bool clearCurrentTweens = true, bool autoPlay = true) { return(NDUITween.From(target, timeInSeconds, position, scale, rotation, NDUITween.GetCurrentAlpha(target), easing, delay, destroyOnComplete, clearCurrentTweens, autoPlay)); }
/* * Fire the tween again, will reset object to it's start position before doing the same motion */ public NDTweenWorker Retrigger(float extraDelay = 0f) { // check for any other NDTweenWorker components NDTweenWorker[] workers = targetGameObject.GetComponents <NDTweenWorker>(); bool needsToBeAddedAgain = true; // loop through to see if this one exists on targetGameObject for (int i = 0; i < workers.Length; i++) { if (workers[i] == this) { needsToBeAddedAgain = false; } } // reset targetGameObject properties SetTargetPosition(isTo ? startPosition : endPosition); SetTargetScale(isTo ? startScale : endScale); SetTargetRotation(isTo ? startRotation : endRotation); if (isUI) { targetGameObject.GetComponent <CanvasRenderer>().SetAlpha(isTo ? startAlpha : endAlpha); } else if (hasRenderer) { targetGameObject.GetComponent <Renderer>().material.SetColor(colorTarget, isTo ? startColor : endColor); } //if not present, fire through NDTween as initially fired if (needsToBeAddedAgain) { if (isUI) { if (isTo) { return(NDUITween.To(targetGameObject, tweenTimeInSeconds, endPosition, endScale, endRotation, endAlpha, easingEquation, delay, destroyOnComplete, clearCurrentTweens)); } else { return(NDUITween.From(targetGameObject, tweenTimeInSeconds, startPosition, startScale, startRotation, startAlpha, easingEquation, delay, destroyOnComplete, clearCurrentTweens)); } } else { if (isTo) { return(NDTween.To(targetGameObject, tweenTimeInSeconds, endPosition, endScale, endRotation, endColor, colorTarget, easingEquation, delay, destroyOnComplete, clearCurrentTweens)); } else { return(NDTween.From(targetGameObject, tweenTimeInSeconds, startPosition, startScale, startRotation, startColor, colorTarget, easingEquation, delay, destroyOnComplete, clearCurrentTweens)); } } } else { //otherwise call StartTween StartTween(); return(this); } }