Class
- Namespace
- CoreFramework
Provides extension methods for the UnityEngine.Color struct. These methods offer additional functionality for manipulating and converting colors.
public static class ColorExtensions
- Inheritance
-
object
Methods
Add(Color, Color)
Adds the RGBA components of two colors and clamps the result between 0 and 1.
public static Color Add(this Color thisColor, Color otherColor)
Parameters
Returns
- Color
A new color that is the sum of the two colors, clamped between 0 and 1.
Blend(Color, Color, float)
Blends two colors with a specified ratio.
public static Color Blend(this Color color1, Color color2, float ratio)
Parameters
Returns
- Color
The blended color.
Clamp01(Color)
Clamps the RGBA components of the color between 0 and 1.
private static Color Clamp01(this Color color)
Parameters
color
ColorThe original color.
Returns
- Color
A new color with each component clamped between 0 and 1.
FromHex(string)
Converts a hexadecimal string to a Color.
public static Color FromHex(this string hex)
Parameters
hex
stringThe hexadecimal string to convert.
Returns
- Color
The Color represented by the hexadecimal string.
Invert(Color)
Inverts the color.
public static Color Invert(this Color color)
Parameters
color
ColorThe color to invert.
Returns
- Color
The inverted color.
SetAlpha(Color, float)
Sets the alpha component of the color.
public static Color SetAlpha(this Color color, float alpha)
Parameters
color
ColorThe original color.
alpha
floatThe new alpha value.
Returns
- Color
A new color with the specified alpha value.
Subtract(Color, Color)
Subtracts the RGBA components of one color from another and clamps the result between 0 and 1.
public static Color Subtract(this Color thisColor, Color otherColor)
Parameters
Returns
- Color
A new color that is the difference of the two colors, clamped between 0 and 1.
ToHex(Color)
Converts a Color to a hexadecimal string.
public static string ToHex(this Color color)
Parameters
color
ColorThe color to convert.
Returns
- string
A hexadecimal string representation of the color.