About • Installation • Attributes
WooshiiAttributes is a collection of attributes to flexibility and better visualisation in the Unity Inspector.
Not only does WooshiiAttribute add general attributes for headers, dropdowns or for providing extra information, but also allows attributes to manipulate how information is displayed; local and global groups, and also attributes to modify how arrays show rather than the elements themselves. See attributes for examples.
Features, systems and new attribute types will be added to this repository as development continues.
For now you can either download using the zip or check releases for all Unity Packages.
Properties • Decorators • Groups • Globals • Arrays • Methods
Vector3 and Vector2 fields can be clamped within a range. Integers and floats can also be clamped, but also have a slider attribute if preferred.
[IntClamp (0, 10, true)] public int clampedInteger;
[FloatClamp (0, 10, true)] public float clampedFloat;
[IntSlider (0, 10)] public int integerSlider;
[FloatSlider (0, 10)] public float floatSlider;
[Vector2Clamp (0, 10)] public Vector2 clampedVector2;
[Vector3Clamp (0, 10)] public Vector3 clampedVector3;
Readonly restricts field editing, and can be set to hide depending on the current state of the editor.
[ReadOnly (DisplayMode.BOTH)] public string readOnlyAll = "Can see me at all times. Can't edit me though.";
[ReadOnly (DisplayMode.EDITOR)] public string readOnlyEditor = "Can see me in the Editor when not playing only.";
[ReadOnly (DisplayMode.PLAYING)] public string readOnlyPlay = "Can see me when Playing only.";
Array Elements will add direct removal or addition buttons to each element of a collection in the inspector.
[ArrayElements] public float[] arrayElements;
Header Lines appear like normal headers, but keep the header capitalized and underlined to show a more clear, sharp visualisation between sections.
[HeaderLine ("ReadOnly")]
[ReadOnly (DisplayMode.BOTH)] public string readOnlyAll = "Can see me at all times. Can't edit me though.";
Paragraph's will display text contained in a box above a field. The background colour, text colour and text alignment can be set in the attribute too. Please note that the colours defined are hexadecimal.
[Paragraph ("This be a string with a paragraph. Go ahead. Type stuff. Yes.", "#D2D2D2", "#1000FF")]
public string stringWithParagraph;
Comments draw helpboxes to the inspector, allowing information to be provided about fields with an icon for the message type.
[Comment ("This is an integer.\nAmazing. Easy. Simple.", CommentAttribute.MessageType.INFO)]
public int intValue;
[Comment ("This is a string.\nCareful - can disguise itself with ToString()", CommentAttribute.MessageType.WARNING)]
public string stringValue;
[Comment ("Toggle value.\nTake caution when editing. Can be indecisive. Also likes to bite.", CommentAttribute.MessageType.ERROR)]
public bool boolValue;
Local Groups can be created using attributes that are named with BeginGroup
and EndGroup
respectively to begin and end a group. BeginGroup
has optional parameters to set capitalization, whether the title is underlined, and if the title is within the group box or not.
[BeginGroup ("Group of stuff", true, true, true)]
public int a;
public int b;
public int c;
public int d;
public int e;
public int f;
public int g;
public int h;
public int i;
public ExampleData[] j;
[EndGroup()]
public int k;
Globals are attributes that affect a group of members together no matter where they are in the script. Any field that uses a global attribute, will be displayed at the bottom of the script.
Globals need to be applied to each field manually however, which may be slower. If you're specifically using globals for groups, see Groups for local versions.
Groups all fields under a header.
[HeaderGroup ("Header Group Stats")] public int otherHealth, otherSpeed, otherDamage;
Groups all fields under a header but formatted like the HeaderLine
attribute.
[HeaderLineGroupAttribute ("Header Line Group Stats")] public int health, speed, damage;
Contains the fields within a box.
[ContainedGroup ("Contained Group Stats")] public int containedHealth, containedSpeed, containedDamage;
Group that has a foldout to hide or show the fields when required.
[FoldoutGroup ("Foldout Group Stats")] public int foldedHealth, foldedSpeed, foldedDamage;
Array drawers unlike property drawers work on the array itself rather than the elements that are in the array.
Allows for reorderable lists and arrays in the inspector.
[Reorderable] public ExampleData[] childClassArray;
Method buttons will display a button for each method given a MethodButton
. These can be private or public buttons too. The attribute has an optional string parameter allowing you to name the button that will appear in the inspector. By default it will take the method name.
[MethodButton ()]
public void ExampleMethod()
{
Debug.Log ("Example Method");
}