Scene Reference Attribute
Unity C# attribute for serializing component and interface references within the scene or prefab during OnValidate, rather than using Get Component* functions in Awake/Start/OnEnable at runtime.
by Kabreet Games
Price History +
Features 🔥
- Supports all MonoBehaviour and Component types (basically anything you can use with GetComponent), plus interfaces!
- Determinate results, so there's no worry of Unity forgetting all your serialised references (which has happened to me a few times on upgrading editor versions). All references will be reassigned automatically.
- Fast, this tool won't slow down your editor or generate excessive garbage.
- Fully serialised at edit time, so all references are already available at runtime
Attributes
- Self looks for the reference on the same game object as the attributed component using GetComponent(s)()
- Parent looks for the reference on the parent hierarchy of the attributed components game object using GetComponent(s)InParent() and ignore self
- SelfOrParent looks for the reference on the parent hierarchy of the attributed components game object using GetComponent(s)InParent()
- Child looks for the reference on the child hierarchy of the attributed components game object using GetComponent(s)InChildren() and Ignore self
- SelfOrChild looks for the reference on the child hierarchy of the attributed components game object using GetComponent(s)InChildren()
- Scene looks for the reference anywhere in the scene using FindAnyObjectByType and FindObjectsOfType
- Anywhere will only validate the reference isn't null, but relies on you to assign the reference yourself.