Version 3.3.1.2

ColorExtensions class

Namespace: Sirenix.Utilities
Assembly: Sirenix.Utilities
public static class ColorExtensions
Extension methods for the UnityEngine.Color type.
Inheritance
  • System.Object
  • ColorExtensions

Methods

Lerp(Color[], Single)
Lerps between multiple colors.
public static Color Lerp(this Color[] colors, float t)
Parameters
UnityEngine.Color[] colors

The colors.

System.Single t

The t.

Returns
UnityEngine.Color

MoveTowards(Color, Color, Single)
Moves the towards implementation for Color.
public static Color MoveTowards(this Color from, Color to, float maxDelta)
Parameters
UnityEngine.Color from

From color.

UnityEngine.Color to

To color.

System.Single maxDelta

The maximum delta.

Returns
UnityEngine.Color

NormalizeRGB(Color)
Normalizes the RGB values of the color ignoring the alpha value.
public static Color NormalizeRGB(this Color color)
Parameters
UnityEngine.Color color

The color.

Returns
UnityEngine.Color

PerceivedLuminosity(Color, Boolean)
Gets the perceived luminosity of a given UnityEngine.Color.
public static float PerceivedLuminosity(this Color color, bool includeAlpha = true)
Parameters
UnityEngine.Color color

The current UnityEngine.Color.

System.Boolean includeAlpha

Determines if the UnityEngine.Color.a value should impact the result.

Returns
System.Single

The System.Single value representing the luminosity.

Pow(Color, Single)
Pows the color with the specified factor.
public static Color Pow(this Color color, float factor)
Parameters
UnityEngine.Color color

The color.

System.Single factor

The factor.

Returns
UnityEngine.Color

ToCSharpColor(Color)
Converts a color to a string formatted to c#
public static string ToCSharpColor(this Color color)
Parameters
UnityEngine.Color color

The color.

Returns
System.String

new Color(r, g, b, a)

TryParseString(String, out Color)
Tries to parse a string to a Color. The following formats are supported: "new Color(0.4, 0, 0, 1)", "#FFEEBBFF", "#FFEECC", "FFEEBBFF", "FFEECC"
public static bool TryParseString(string colorStr, out Color color)
Parameters
System.String colorStr

The color string.

UnityEngine.Color color

The color.

Returns
System.Boolean

Returns true if the parse was a success.