Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smidgens/unity-attributes
Inspector attributes for Unity
https://github.com/smidgens/unity-attributes
attributes not-affiliated-with-david-bowie smidgenomics unity unity-attributes unity-plugin
Last synced: 19 days ago
JSON representation
Inspector attributes for Unity
- Host: GitHub
- URL: https://github.com/smidgens/unity-attributes
- Owner: Smidgens
- License: mit
- Created: 2022-07-14T17:02:40.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T16:35:01.000Z (about 2 years ago)
- Last Synced: 2024-11-10T13:52:09.763Z (about 2 months ago)
- Topics: attributes, not-affiliated-with-david-bowie, smidgenomics, unity, unity-attributes, unity-plugin
- Language: C#
- Homepage:
- Size: 380 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# âšī¸ Features
* Collection of general use drawer and decorator attributes.
* Stripped in production: `[Conditional("UNITY_EDITOR")]`
* đ¤ Reasonably lightweight.
# đĻ Install
1. Open Package Manager
2. Paste GitHub URL:\
`https://github.com/Smidgens/unity-attributes.git#`
# đ Usage
### đĸ Decorators
đ BoxHeader
```cs
[BoxHeader("Example Header")]
[TextArea]
public string documentedField;
```đ BoxComment
```cs
[BoxComment("Some information about bla")]
[TextArea]
public string documentedField;
```đ BoxLink
```cs
[BoxLink("Documentation", "https://en.wikipedia.org/wiki/Slartibartfast")]
[TextArea]
public string documentedField;
```đŗ StaticAction
```cs
class StaticGreets
{
public static void SayHi()
{
Debug.Log("Hello, wurst!");
}public static void LogValue(int v)
{
Debug.Log("Your value is: " + v);
}
}[StaticAction("Say Hi", "SayHi", typeof(StaticGreets))]
[StaticAction("Log 10", "LogValue", typeof(StaticGreets), 10)]
public string staticActionField;```
### đ Property Drawers
đ Inline
```cs
[System.Serializable]
public struct T1
{
public string name;
public Texture2D icon;
}[Inline]
public Vector3 inlinedVector;[FieldSize("name", 40f)]
[Inline]
public T1 inlinedCustom;
```đ Expand
```cs
[Serializable]
public struct T1
{
public string name;
public Texture2D icon;
}[Serializable]
public struct T2
{
public int someValue;
public T1 nested;
}[Expand]
public T1 expanded1;[Expand]
public T2 expanded2;
```đ Tabs
```cs
[System.Serializable]
struct ToggleData
{
public bool v1,v2,v3;
}[Tabs]
public ToggleData options;```
```cs
[System.Flags]
enum Options
{
Item1 = 1,
Item2 = 2,
Item3 = 4,
}[Tabs]
public Options options;
```đ Switch
```cs
[Switch]
public bool switch1;[Switch("Off", "On")]
public bool switch2;[Switch("Disabled", "Enabled")]
public bool switch3;
```
```cs
[System.Flags]
enum Options
{
Item1 = 1,
Item2 = 2,
Item3 = 4,
}[Switch]
public Options options;
```đī¸ Slider
```cs
[Slider(1f,10f,1)]
public float sliderPrecision;[Slider(1f,10f,0.5f)]
public float sliderStep;[Slider(1,10)]
public int sliderInt;
```đī¸ Slider01
```cs
[Slider01]
public float slider01;
```đ¨ HexColor
```cs
[HexColor]
public string hexColor = "#f00";```
đ SearchType
```cs
[SearchType]
public string anyType;
// only show component types
[SearchType(baseTypes = new Type[]{ typeof(Component) })]
public string componentType;// only show static classes
[SearchType(onlyStatic = true)]
public string staticType;// only show system types
[SearchType(assemblies = new string[]{ "mscorlib" })]
public string systemType;
```đģ Dropdown__
```cs
[DropdownString("option1", "option2")]
public string _string;[DropdownFloat(0.5f, 1.2f, 2.4f)]
public float _float;[DropdownColor("red", "blue", "cyan")]
public Color _color;[DropdownBool("Off", "On")]
public bool _bool;[DropdownInt(0, 10)]
public int _int;[DropdownAsset("Assets/Demo/")]
public Texture2D _texture;
```đģ Layer
```cs
[Layer]
public int _layer;
```đģ SortLayer
```cs
[SortLayer]
public int _sortingLayer;
```đģ Tag
```cs
[Tag]
public string _tag;
```đģ BuildScene
```cs
[BuildScene]
public string scenePath;[BuildScene]
public int sceneIndex;
```đģ AnimatorParameter
```cs
public Animator myAnimator;
[AnimatorParameter("myAnimator")]
public string parameterName;[AnimatorParameter("myAnimator")]
public int parameterIndex;
```đģ RendererMaterial
```cs
public Renderer myRenderer;[AnimatorParameter("myRenderer")]
public int materialIndex
```đģ BlendShape
```cs
public SkinnedMeshRenderer myRenderer;[AnimatorParameter("myRenderer")]
public string blendShapeName[AnimatorParameter("myRenderer")]
public int blendShapeIndex
```### đĩ Modifiers
đŗ FieldAction
```cs
[System.Serializable]
internal class OwnerOfFunctions
{
public int myValue = 10;public void SetMyValue(int v)
{
myValue = v;
}public void CallMe()
{
Debug.Log("Yay!");
}public void CallMeAsWell()
{
Debug.Log("OMG YAY");
}
}class MyScript : MonoBehaviour
{
[FieldAction("Action 1", "CallMe")]
[FieldAction("Action 2", "CallMeAsWell")]
[FieldAction("Set value: 100", "SetMyValue", 100, onlyPlayMode = true)]
[FieldAction("Call Target", "ScriptMethod", callRoot = true)]
[Expand]
public OwnerOfFunctions fieldWithActions;private void ScriptMethod()
{
Debug.Log("Script method called!");
}
}```
đ Indent
```cs
[Indent(1)]
[DefaultDrawer]
public int iAmIndented;[Indent(2)]
[DefaultDrawer]
public int iAmMoreSo;```