409544041 / BetterAttributes

Unity Attributes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better Attributes

openupm

image

This package provides following features:

Select Dropdown

This package contains base class for drawer with better dropdown.
Better dropdown contains:

  1. Search
  2. Fast navigation
  3. Grouping

Select Implementation

Provides possibility to select interface implementation in Unity Inspector.

Usage:

[SelectImplementation] [SerializeReference]
private ISomeInterface someInterface;

[SelectImplementation] [SerializeReference]
private SomeAbstractClass someAbstractClass;

[SelectImplementation(typeof(SomeAbstractClass)] [SerializeReference]
private List<SomeAbstractClass> someAbstractClasses;

[SelectImplementation(typeof(ISomeInterface))] [SerializeReference]
private List<ISomeInterface> someInterfaces;

Select Enum

Provides possibility to select enum value with better dropdown.
Also supports flag enums.

Usage:

[SelectEnum] [SerializeField]
private KeyCode keyCode;

Preview

Provides possibility to see object preview by clicking into the field in Unity Inspector.
Supports preview for scene objects and prefabs object as well as textures and sprites.

Usage:

[Preview] [SerializeField]
private Sprite sprite;

[Preview] [SerializeField]
private SomeMonobehaviour someMonobehaviour;

Read Only Field

Provides possibility to disable modification of fields in Unity Inspector but keep it displayed.

Usage:

[ReadOnlyField] [SerializeField] 
private SomeClass someClass;

[ReadOnlyField] [SerializeField] 
private float someFloat;

[ReadOnlyField] [TextArea(5, 10)] [SerializeField] 
private string someString;

Icon Header

Provides possibility to Draw fullsized texture about field in Unity Inspector. To get texture guid open TextureImport window and right open context menu -> Conver To IconHeaderAttribute.

Usage:

[IconHeader("TEXTURE_GUID")] [SerializeField]
private string oldName;

Draw Inspector

Provides possibility to Draw fullsized Inspector below field with type inheretex from UnityEngine.Object.

Usage:

[DrawInspector] [SerializeField]
private SomeScriptable scriptable;

Rename Field

Provides possibility to rename label in Unity Inspector.

Usage:

[RenameField("New Name")] [SerializeField]
private string oldName;

Gizmo / Gizmo Local

Provides possibility to set value for Vector3/Vector2/Quaternion/Bounds from scene view by dragging handles.
[GizmoLocal] works only into MonoBehaviour Unity Inspector.

Usage:

[Gizmo]
[SerializeField] private Bounds bounds;
        
[Gizmo]
[SerializeField] private Vector3 vector3;
        
[Gizmo]
[SerializeField] private Quaternion quaternion;

[GizmoLocal]
[SerializeField] private Bounds boundsLocal;
        
[GizmoLocal]
[SerializeField] private Vector3 vector3Local;
        
[GizmoLocal]
[SerializeField] private Quaternion quaternionLocal;

Editor Buttons

Provides possibility to display button for method in Unity Inspector.

Usages:

///Default usage of attribute.
[EditorButton]
private void SomeMethod()
{
//Some code.
}

///This button will call method with predefined parameters. 
///When invokeParams not specified will call with null.
[EditorButton(invokeParams: 10f)]
private void SomeMethod(float floatValue)
{
//Some code.
}

///This button will call method with predefined parameters. 
///When invokeParams not specified will call with null.
[EditorButton(invokeParams: new object[] { 10f, 10 })]
private void SomeMethod(float floatValue, int intValue)
{
//Some code.
}

/// This button will be in the same row with button for SomeMethod2.
/// But will be in the second position.
/// When captureGroup not specified each button placed in separate row.
/// When priority not specified buttons in one row sorted by order in code.
[EditorButton(captureGroup: 1, priority: 2)]
private void SomeMethod1()
{
//Some code.
}

[EditorButton(captureGroup: 1, priority: 1)]
private void SomeMethod2()
{
//Some code.
}

/// This button will have name "Some Cool Button".
/// When displayName not specified or null/empty/whitespace button 
/// will have name same as method.
[EditorButton(displayName: "Some Cool Button")]
private void SomeMethod()
{
//Some code
}

You can check constructors for EditorButtonAttribute there more specific options.

Install

How to istall

About

Unity Attributes

License:MIT License


Languages

Language:C# 100.0%