AwesomeAttributes
AwesomeAttributes enhances Unity's Inspector with a comprehensive set of custom attributes that improve workflow efficiency and visual organization. The package provides decorative and functional attributes like Title, GUIColor, and more to create cleaner, more readable inspector layouts without requiring custom editor scripts. Supports installation via Asset Store, GitHub, OpenUPM, or disk import for flexible integration into any project.
com.cherrydev.awesomeattributes Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/awesomeattributes.git?path=Assets/Plugins/AwesomeAttributes README Markdown
Copy this to your project's README.md
## Installation
Add **AwesomeAttributes** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/awesomeattributes.git?path=Assets%2FPlugins%2FAwesomeAttributes
```
[](https://www.pkglnk.dev/pkg/awesomeattributes)README
AWESOME ATTRIBUTES
Last Updated: 08/02/2024
Publisher: cherrydev
Overview Video: https://www.youtube.com/watch?v=FhUs-C4zX_s&t=14s&ab_channel=cherrydev(url)📥 Installation
1️⃣ Unity asset store
- Directly from Unity Asset Store.
2️⃣ Using GitHub link
- Go to ‘Package Manager’ - + - ‘Add package from git URL’ and paste this
https://github.com/OlegVishnivetsky/awesome-attributes.git?path=/Assets/Plugins/AwesomeAttributes
3️⃣ Add from disk or using .unitypackage file from 'Release'
- Download .zip from git hub page and extract forder.
- Go to ‘Package Manager’ - + - ‘Add package from disk’ and select package.json file.
4️⃣ OpenUPM
Also this package available on OpenUPM. You can install it using openupm-cli. Install via command-line interface
openupm add com.cherrydev.awesomeattributes
📝 Documentation
1. Title
Draws a title and subtitle (optional). You can change the text alignment to Left/Center/Right. You can choose whether this text will be bold, have a separation line or not.
[Title("Health", "Player health")]
[SerializeField] private float maxHealth;
[SerializeField] private float currentHealth;
--------------------------------------------------
public TitleAttribute(string title, string subTitle = null, bool bold = true, bool withSeparationLine = true);
public TitleAttribute(string title, TitleTextAlignments textAlignments, string subTitle = null, bool bold = true, bool withSeparationLine = true)
2. GUI Color
Everything is simple here. The attribute changes gui color. You can use it by specifying color hex or rgba in the parameters.
[GUIColor("#ff00ff")]
[SerializeField] private float maxHealth;
[GUIColor(255, 0, 0, 0.2f)]
[SerializeField] private float currentHealth;
--------------------------------------------------
public GUIColorAttribute(int r, int g, int b, float a);
public GUIColorAttribute(string colorHex)
3. Separation Line
Draws a separation line with height, top spacing and bottom spacing.
[SeparationLine(10)]
[SerializeField] private float maxHealth;
[SerializeField] private float currentHealth;
[SeparationLine(1, 10, 10)]
[SerializeField] private float speed;
[SerializeField] public float maxSpeed = 4;
--------------------------------------------------
public SeparationLineAttribute(float height, float topSpacing = 1, float bottomSpacing = 1);
4. Label
Changes the field name in the inspector, useful for long names.
[Label("Short Name")]
[SerializeField] private float veryveryveryveryveryLong;
--------------------------------------------------
public LabelAttribute(string lable)
5. ShowIf
Shows the field in the inspector if the condition is true, otherwise hides it. May contain several conditions and enum. You can also specify a method that returns a bool.
[SerializeField] private bool showIfThisTrue;
[ShowIf("showIfThisTrue")]
[SerializeField] private int showMePlease;
[SerializeField] private ShowIfTestEnum showIfEnumTest;
[ShowIf(ShowIfTestEnum.Show, "showIfEnumTest")]
[SerializeField] private int showEnumTest;
--------------------------------------------------
public ShowIfAttribute(string condition)
public ShowIfAttribute(string conditionsOperator, params string[] conditions)
public ShowIfAttribute(object enumValue, string enumFieldName)
6. Readonly
Attribute class for readonly fields, they are visible in the inspector but cannot be edited.
[SerializeField] private float maxHealth;
[Readonly]
[SerializeField] private float currentHealth;
7. ReadonlyIf
Another conditional attribute. Makes the field readonly if the condition is true. May contain several conditions and enum.
[SerializeField] private bool turnOnReadonly;
[ReadonlyIf("turnOnReadonly")]
[SerializeField] private float currentHealth;
--------------------------------------------------
public ReadonlyIfAttribute(string condition)
public ReadonlyIfAttribute(string conditionsOperator, params string[] conditions)
public ReadonlyIfAttribute(object enumValue, string enumFieldName)
8. MinMaxSlider
Attribute that creates special slider the user can use to specify a range between a min and a max. Can be used on Vector2 and float fields.
[MinMaxSlider(0, 20)]
[SerializeField] private Vector2 minMaxValue;
--------------------------------------------------
public MinMaxSliderAttribute(float minValue, float maxValue)
9. WithoutLabel
Hides the field label
[WithoutLabel]
[SerializeField] private Vector2 iDontNeedLabel;
10. Button
Shows a button under the field to which the attribute is applied. The name of the method is specified as a parameter, and you can also specify the label and height. The Button attribute now supports methods with parameters. The inspector displays fields for each parameter based on its type (e.g., int, float, string, bool). These fields allow you to input values, which are passed to the method when the button is clicked.
[Button("DebugCurrentHealth", "Check Health")]
[SerializeField] private float currentHealth;
--------------------------------------------------
public ButtonAttribute(string methodName, string lable = null, float height = 18)
11. Required
Attribute that creates a warning box if the field is null.
[Required]
[SerializeField] private GameObject requiredObject;
--------------------------------------------------
public RequiredAttribute()
public RequiredAttribute(string message)
public RequiredAttribute(MessageType messageType)
public RequiredAttribute(string message, MessageType messageType)
12. OnlyChildGameObjects
Restricts a property to reference only child objects of the same type. Adds a button "Pick" that opens a window with all child objects of the same type as the field and allows you to assign only child objects.
[OnlyChildGameObjects]
[SerializeField] private Rigidbody2D onlyChildObjects;
13. TagSelector
Allows you to select a tag from a dropdown in the Inspector.
[TagSelector]
[SerializeField] private string playerTag;
14. Scene
Allows you to select a scene from the drop-down list in the Inspector for string or integer fields. The drop-down list shows the scenes that are in Build Settings/Scenes In Build
[Scene]
[SerializeField] private string sceneField;
15. PlayerPrefs
All fields marked with this attribute will be automatically loaded in the Awake() method and saved in either the OnDestroy() or OnDisable() methods. By default, values are saved in OnDisable(), but you can specify OnDestroy() as an alternative. To make this functionality work, you need to add the PlayerPrefsAttributeObserver prefab to the scene. The attribute requires a key and an optional save trigger type to specify when the value will be saved.
[PlayerPrefs("SaveMe")]
[SerializeField] private int saveMe;
16. ResourcesPath
Allows selecting assets from the Resources folder and stores the path for Resources.Load. Also restricts selection to assets within the Resources folder.
[ResourcesPath]
[SerializeField] private string path;
17. Gradient
Gradient attribute that allows you editing Gradient fields directly in the Inspector.
[Gradient]
[SerializeField] private Gradient gradient;
17. Preview
Preview attribute that can be used for sprite fields. Draws a foldout that can be toggled to see a preview of the sprite.
[Preview]
[SerializeField] private Sprite testSprite;
⭐⭐⭐⭐⭐ If you want to add your attribute. Then please follow the folder structure as in the asset and make a pull request. Feel free to edit any code to suit your needs. If you find any bugs or have any questions, you can write about it to me by email, github or in reviews in the Unity Asset Store. I will also be pleased if you visit my itchio page. 😄
Gmail: olegmroleg@gmail.com
Github: https://github.com/OlegVishnivetsky
Itch.io: https://oleg-vishnivetsky.itch.io/
This file will be updated over time. If you write suggestions again.
No comments yet. Be the first!