Version 3.3.1.2

Odin has a dedicated attribute overview with examples

GUIColorAttribute class

Namespace: Sirenix.OdinInspector
Assembly: Sirenix.OdinInspector.Attributes
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter | AttributeTargets.All, AllowMultiple = false, Inherited = true)]
[Conditional("UNITY_EDITOR")]
public class GUIColorAttribute : Attribute, _Attribute

GUIColor is used on any property and changes the GUI color used to draw the property.

Inheritance
  • System.Object
  • System.Attribute
  • GUIColorAttribute
Example

The following example shows how GUIColor is used on a properties to create a rainbow effect.

public class MyComponent : MonoBehaviour
{
	[GUIColor(1f, 0f, 0f)]
	public int A;

	[GUIColor(1f, 0.5f, 0f, 0.2f)]
	public int B;

	[GUIColor("GetColor")]
	public int C;

	private Color GetColor() { return this.A == 0 ? Color.red : Color.white; }
}

Constructors

GUIColorAttribute(Single, Single, Single, Single)
Sets the GUI color for the property.
public GUIColorAttribute(float r, float g, float b, float a = 1F)
Parameters
System.Single r

The red channel.

System.Single g

The green channel.

System.Single b

The blue channel.

System.Single a

The alpha channel.

GUIColorAttribute(String)
Sets the GUI color for the property.
public GUIColorAttribute(string getColor)
Parameters
System.String getColor

Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor").

Fields

Color
The GUI color of the property.
public Color Color
GetColor
Supports a variety of color formats, including named colors (e.g. "red", "orange", "green", "blue"), hex codes (e.g. "#FF0000" and "#FF0000FF"), and RGBA (e.g. "RGBA(1,1,1,1)") or RGB (e.g. "RGB(1,1,1)"), including Odin attribute expressions (e.g "@this.MyColor"). Here are the available named colors: black, blue, clear, cyan, gray, green, grey, magenta, orange, purple, red, transparent, transparentBlack, transparentWhite, white, yellow, lightblue, lightcyan, lightgray, lightgreen, lightgrey, lightmagenta, lightorange, lightpurple, lightred, lightyellow, darkblue, darkcyan, darkgray, darkgreen, darkgrey, darkmagenta, darkorange, darkpurple, darkred, darkyellow.
public string GetColor