Last Updated: 08/02/2024
Publisher: cherrydev
💡 About: Unity asset designed to speed up and improve your development process. Adds a large number of attributes with which you can make your inspector more beautiful and convenient.Overview Video: https://www.youtube.com/watch?v=FhUs-C4zX_s&t=14s&ab_channel=cherrydev(url)
- Directly from Unity Asset Store.
- Go to ‘Package Manager’ - + - ‘Add package from git URL’ and paste this
https://github.com/OlegVishnivetsky/awesome-attributes.git?path=/Assets/Plugins/AwesomeAttributes
- Download .zip from git hub page and extract forder.
- Go to ‘Package Manager’ - + - ‘Add package from disk’ and select package.json file.
Also this package available on OpenUPM. You can install it using openupm-cli. Install via command-line interface
openupm add com.cherrydev.awesomeattributes
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)
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)
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);
Changes the field name in the inspector, useful for long names.
[Label("Short Name")]
[SerializeField] private float veryveryveryveryveryLong;
--------------------------------------------------
public LabelAttribute(string lable)
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)
Attribute class for readonly fields, they are visible in the inspector but cannot be edited.
[SerializeField] private float maxHealth;
[Readonly]
[SerializeField] private float currentHealth;
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)
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)
Hides the field label
[WithoutLabel]
[SerializeField] private Vector2 iDontNeedLabel;
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)
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)
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;
Allows you to select a tag from a dropdown in the Inspector.
[TagSelector]
[SerializeField] private string playerTag;
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;
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;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;Gradient attribute that allows you editing Gradient fields directly in the Inspector.
[Gradient]
[SerializeField] private Gradient gradient;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.
