Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wooshiidev/wooshiiattributes
A growing collection of flexible, powerful Unity attributes
https://github.com/wooshiidev/wooshiiattributes
editor unity unity3d
Last synced: about 4 hours ago
JSON representation
A growing collection of flexible, powerful Unity attributes
- Host: GitHub
- URL: https://github.com/wooshiidev/wooshiiattributes
- Owner: WooshiiDev
- License: mit
- Created: 2021-01-05T15:59:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T00:02:19.000Z (over 1 year ago)
- Last Synced: 2024-05-02T03:36:00.341Z (6 months ago)
- Topics: editor, unity, unity3d
- Language: C#
- Homepage:
- Size: 1.31 MB
- Stars: 32
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
WooshiiAttributes
A growing collection of flexible, powerful Unity attributes
About •
Installation •
Attributes
## About
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.
## Installation
For now you can either download using the zip or check releases for all Unity Packages.## Attributes
Properties •
Decorators •
Groups •
Globals •
Arrays •
Methods### Properties
#### Basics
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.```cs
[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
Readonly restricts field editing, and can be set to hide depending on the current state of the editor.
```cs
[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
Array Elements will add direct removal or addition buttons to each element of a collection in the inspector.
```cs
[ArrayElements] public float[] arrayElements;
```### Decorators
#### HeaderLine
Header Lines appear like normal headers, but keep the header capitalized and underlined to show a more clear, sharp visualisation between sections.
```cs
[HeaderLine ("ReadOnly")]
[ReadOnly (DisplayMode.BOTH)] public string readOnlyAll = "Can see me at all times. Can't edit me though.";
```### Paragraph
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.```cs
[Paragraph ("This be a string with a paragraph. Go ahead. Type stuff. Yes.", "#D2D2D2", "#1000FF")]
public string stringWithParagraph;
```#### Comment
Comments draw helpboxes to the inspector, allowing information to be provided about fields with an icon for the message type.
```cs
[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;
```### Groups
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.
```cs
[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
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.
#### HeaderGroup
Groups all fields under a header.
```cs
[HeaderGroup ("Header Group Stats")] public int otherHealth, otherSpeed, otherDamage;
```#### HeaderLineGroup
Groups all fields under a header but formatted like the `HeaderLine` attribute.
```cs
[HeaderLineGroupAttribute ("Header Line Group Stats")] public int health, speed, damage;
```#### ContainedGroup
Contains the fields within a box.
```cs
[ContainedGroup ("Contained Group Stats")] public int containedHealth, containedSpeed, containedDamage;
```#### FoldoutGroup
Group that has a foldout to hide or show the fields when required.
```cs
[FoldoutGroup ("Foldout Group Stats")] public int foldedHealth, foldedSpeed, foldedDamage;
```### Arrays
Array drawers unlike property drawers work on the array itself rather than the elements that are in the array.
#### Reorderable
Allows for reorderable lists and arrays in the inspector.
```cs
[Reorderable] public ExampleData[] childClassArray;
```### Methods
#### MethodButton
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.
```cs
[MethodButton ()]
public void ExampleMethod()
{
Debug.Log ("Example Method");
}
```