Version 3.1.11.0

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

Specify the name of a local field, member or property that returns a Color.

Fields

Color
The GUI color of the property.
public Color Color
GetColor
The name of a local field, member or property that returns a Color. Both static and instance methods are supported.
public string GetColor