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.
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; }
}
public GUIColorAttribute(float r, float g, float b, float a = 1F)
System.Single | r | The red channel. |
System.Single | g | The green channel. |
System.Single | b | The blue channel. |
System.Single | a | The alpha channel. |
public GUIColorAttribute(string getColor)
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"). |
public Color Color
public string GetColor