Automatically resolves SerializeField
references.
It collects the references on the Hierarchy and displays them in a drop-down.
[SerializeField, AutoReference] AutoReferenceExampleObject obj;
[SerializeField, AutoReference] AutoReferenceExampleObject[] obj;
[SerializeField, AutoReference] List<AutoReferenceExampleObject> obj;
[SerializeField, AutoReference] MyScript script;
- It has better performance than
GetComponent
. - You can check it in Hierarchy, so it is intuitive.
- It's easy to add
AutoReference
. - If a script goes missing, you can reconfigure it by simply selecting it.
- Class(MonoBehaviour)
- Class(MonoBehaviour)[] array
- List<Class(MonoBehaviour)> List
- It is only supported on Hierarchy.
- UnityEngine's api is NOT supported due to performance reasons.
- You can get up to child objects.
For some reasons, it will not work with 0, so enter 1.
Unity 2018.4 higher
URL : https://github.com/IShix-g/AutoReferenceAttribute.git?path=Assets/Plugins/AutoReferenceAttribute
Add the Url to Package Manager
Add the Url to Packages/manifest.json
.
SerializeFieldAutoReferenceAttribute/releases
For transform children only.
[SerializeField, AutoReference(childOnly:true)] AutoReferenceExampleObject objChildOnly;
By passing transform as a string, only the children of the selected transform will be targeted.
[SerializeField] Transform parentTransform;
[SerializeField, AutoReference(parent:"parentTransform")] List<AutoReferenceExampleObject> objList;