Table of Contents

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

thisColor Color

The first color.

otherColor Color

The second color.

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

color1 Color

The first color.

color2 Color

The second color.

ratio float

The blend ratio (0 to 1).

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 Color

The 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 string

The 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 Color

The 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 Color

The original color.

alpha float

The 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

thisColor Color

The first color.

otherColor Color

The second color.

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 Color

The color to convert.

Returns

string

A hexadecimal string representation of the color.