Make your Unity Editor pretier and easily customizable without extra work with editor scripting
🔧 Repository is currently in active development
A collection of Quality-of-Life attributes for Unity designed to improve workflow and inspector usability.
This package focuses on conditional inspector logic such as showing or hiding fields based on parameters.
- ShowIf: show or hide a variable based on another variable`s value
- ReadOnly: make a variable to be read only
- Button: add a button in the inspection for a specified function to be called on click
- Break: add a simple colored line to divide variables visible in the editor.
- Open Unity
- Go to Window → Package Manager
- Click the + button
- Select Add package from git URL
- Paste:
https://github.com/EnjoyW0rld/QOL-Unity-Attributes.git
You can download directly a .unitypackage file and simply drag and drop it into your project
Show if the attrbute has two constructors -
First constructor public ShowIfAttribute(string pValueToCompare, ComparisonType pComparer = ComparisonType.IsNotNull)
For the cases when it is needed to check if the target value is null or not, the comparison type can be omitted in most of the cases.
string pValueToCompare - pass a name with of the target variable you want to be compared
Second constructor public ShowIfAttribute(string pValueToCompare, ComparisonType pComparer, object pTargetValue)
This is a general constructor that includes all the cases possible in the current version of the ShowIf attribute.
object pTargetValue - value that variable will be compared with (for example 1, 2.5, true, false, etc.).
Choosing which comparison type to use is made through the enum list -
enum ComparisonType
{
Less,
Equal,
NotEqual,
Bigger,
IsNull,
IsNotNull
}
- ShowIf attribute can not compare the size of the array to the desired length
- Can not fully customize the comparison mechanism (for example, show variable if the comparable variable is >3 and <10)
Simply add the ReadOnly attribute to the variable, and you are good to go. Attribute should work with the most default and some Unity-specific variables.
The button attribute allows you to include in the script editor window buttons to call specified functions.
Add to a variable [Button(..)] attribute to make the editor draw a button. The class comes with two constructors, where main is -
public ButtonAttribute(string pTargetFunction, string pDisplayName, bool pDoDrawUnder = false)
- Where pTargetFunction is the name of the function to be called (the function needs to be without parameters).
- pDisplay name is the text to be written on the button itself; this parameter can be omitted if you don`t need custom text on the button.
- pDoDrawUnder is a bool determining if the button will be drawn on top (by default) of the variable this attribute is attached to or under.
The break attribute simply creates a line of desired width in the editor to split your variables and make the editor more readable.
Currentrly it is possible to set up only colour and the width of the divider, in future more settings will be added.
Found a bug or have a feature request? Open an issue or submit a pull request! Contributions are welcome.
This project is licensed under the MIT License. See the LICENSE file for details.
