public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration, Easing.Equation easing, int delay = 0, ITweener tweener = null) { CoroutineManager.StartCoroutine( TweenColorAlphaRoutine(hasColor, from, to, duration, easing, delay, tweener), null); }
static IEnumerator TweenColorAlphaRoutine(IHasColor hasColor, float from, float to, int duration, Easing.Equation easing, int delay = 0, ITweener tweener = null) { if (delay > 0) { yield return(new WaitForMilliSeconds(delay)); } float durationF = duration * 0.001f; float time = 0; hasColor.Alpha = from; var childs = hasColor.children; for (int i = 0; i < childs.Count; i++) { if (childs[i] is IHasColor) { ((IHasColor)childs[i]).Alpha = from; } } while (time < durationF) { hasColor.Alpha = Easing.Ease(easing, time, from, to, durationF); for (int i = 0; i < childs.Count; i++) { if (childs[i] is IHasColor) { ((IHasColor)childs[i]).Alpha = Easing.Ease(easing, time, from, to, durationF); } } time += Time.deltaTime * 0.001f; yield return(null); } hasColor.Alpha = to; for (int i = 0; i < childs.Count; i++) { if (childs[i] is IHasColor) { ((IHasColor)childs[i]).Alpha = to; } } if (tweener != null) { tweener.OnTweenEnd(hasColor); } }
public IColoredShape CreateColoredShapeMixin(IHasShape shape, IHasColor color) { var options = new ProxyGenerationOptions(); options.AddMixinInstance(shape); options.AddMixinInstance(color); var generator = new ProxyGenerator(); var proxy = generator.CreateClassProxy(typeof(object), new[] { typeof(IColoredShape) }, options) as IColoredShape; return proxy; }
public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration, ITweener tweener) { TweenColorAlpha(hasColor, from, to, duration, Easing.Equation.Linear, 0, tweener); }
public static void TweenColorAlpha(IHasColor hasColor, float from, float to, int duration, OnFinished onFinished) { TweenColorAlpha(hasColor, from, to, duration, Easing.Equation.Linear, 0, onFinished); }