public static IEnumerator TweenColorRoutine(Sprite sprite, uint from, uint to, int duration, Easing.Equation equation) { int time = 0; sprite.color = from; //float fromA = ((byte) (from >> 24)) / 255f; float fromR = ((byte)(from >> 16)) / 255f; float fromG = ((byte)(from >> 8)) / 255f; float fromB = ((byte)(from >> 0)) / 255f; //float toA = ((byte) (to >> 24)) / 255f; float toR = ((byte)(to >> 16)) / 255f; float toG = ((byte)(to >> 8)) / 255f; float toB = ((byte)(to >> 0)) / 255f; float redFromDir = fromR > toR ? fromR : 0; float greenFromDir = fromG > toG ? fromG : 0; float blueFromDir = fromB > toB ? fromB : 0; float redToDir = fromR > toR ? 0 : fromR; float greenToDir = fromG > toG ? 0 : fromG; float blueToDir = fromB > toB ? 0 : fromB; while (time < duration) { float r = redToDir + Easing.Ease(equation, time, redFromDir, toR - fromR, duration); float g = greenToDir + Easing.Ease(equation, time, greenFromDir, toG - fromG, duration); float b = blueToDir + Easing.Ease(equation, time, blueFromDir, toB - fromB, duration); sprite.SetColor(r, g, b); time += Time.deltaTime; yield return(null); } sprite.color = to; }