/// <summary> /// Given a GUIStyle <paramref name="guiStyle" /> , flash all text that adopts this style back and forth between /// colours <paramref name="c1" /> and <paramref name="c2" /> with speed <paramref name="speed" /> . /// </summary> /// <param name="guiStyle">The gui Style.</param> /// <param name="c1">The c 1.</param> /// <param name="c2">The c 2.</param> /// <param name="speed">The speed.</param> /// <param name="addShift">The add Shift.</param> public static void Flash(this GUIStyle guiStyle, Color c1, Color c2, float speed, float addShift = 0f) { guiStyle.normal.textColor = LocalColorUtils.LinearInterpolate( c1, c2, 0.5f * Mathf.Cos(Time.time * speed + addShift) + 0.5f); }
/// <summary> /// Given a piece of text <paramref name="textToFlash" />, flash it back and forth between colours /// <paramref name="c1" /> and <paramref name="c2" /> with speed <paramref name="speed" />. /// </summary> /// <param name="textToFlash">The piece of text to flash.</param> /// <param name="c1">The first colour to flash the text's colour between.</param> /// <param name="c2">The second colour to flash the text's colour between.</param> /// <param name="speed">The speed.</param> /// <param name="addShift">The add Shift.</param> public static void Flash(this Text textToFlash, Color c1, Color c2, float speed, float addShift = 0f) { textToFlash.color = LocalColorUtils.LinearInterpolate(c1, c2, 0.5f * Mathf.Cos(Time.time * speed + addShift) + 0.5f); }