https://github.com/lusties/QuickRef.git?path=Packages/QuickRef
Here's an example of how to use the QuickRef package in Unity:
usingLustie.QuickRef;publicclassExampleBehaviour:MonoBehaviour{//this will automatically reference these Unity Object in Inspector.[GetComponent,SerializeField]privateAudioSourceself_audioSource;[GetComponentInChildren]publicLightchild_light;[GetComponentInParent]publicCameraparent_camera;}If you want to hide a field from the Inspector, use the [NoDisplay] attribute in order:
[SerializeField]// this for serialize private field[FindObjectOfType]// find object of type[NoDisplay]// hide in normal inspectorprivateCameranoDisplayedCamera;| Attribute | Description |
|---|---|
[GetComponent] | Automatically references the component on the same GameObject. |
[GetComponentInChildren] | Automatically references the component in the children of the GameObject. |
[GetComponentInParent] | Automatically references the component in the parent of the GameObject. |
[FindObjectOfType] | Finds an object of the specified type in the scene. |
[NoDisplay] | Hides the field from being displayed in the Inspector. |