{"id":23752368,"url":"https://github.com/incantium/auto-reference","last_synced_at":"2026-02-11T22:33:39.159Z","repository":{"id":266717691,"uuid":"896639401","full_name":"Incantium/Auto-Reference","owner":"Incantium","description":"Never use GetComponent in Awake or Start anymore. This attribute automatically references it for you.","archived":false,"fork":false,"pushed_at":"2025-01-10T18:22:06.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-20T21:52:25.123Z","etag":null,"topics":["attribute","csharp","developer-tool","package","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Incantium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-30T22:38:20.000Z","updated_at":"2025-01-28T20:17:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"ddc2a3b8-f1ff-4659-8080-f9f0e929034a","html_url":"https://github.com/Incantium/Auto-Reference","commit_stats":null,"previous_names":["incantium/auto-reference"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incantium%2FAuto-Reference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incantium%2FAuto-Reference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incantium%2FAuto-Reference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Incantium%2FAuto-Reference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Incantium","download_url":"https://codeload.github.com/Incantium/Auto-Reference/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921877,"owners_count":19718842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attribute","csharp","developer-tool","package","unity"],"created_at":"2024-12-31T17:28:44.927Z","updated_at":"2026-02-11T22:33:39.155Z","avatar_url":"https://github.com/Incantium.png","language":"C#","readme":"﻿# Auto Reference\n\n![Unity version](https://img.shields.io/badge/2022.3+-cccccc?logo=unity)\n![.NET version](https://img.shields.io/badge/Standard_2.1-5027d5?logo=dotnet)\n![C# version](https://custom-icon-badges.demolab.com/badge/9.0-67217a?logo=cshrp)\n\n## Overview\n\nAre you tired writing [`GetComponent`](https://docs.unity3d.com/ScriptReference/GameObject.GetComponent.html) in each \nscript to reference another script, even though this can never go wrong (when using \n[`[RequireComponent]`](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RequireComponent.html))? This \npackage named Auto Reference solves that problem by automatically referencing other script without any extra code.\n\n## Installation instructions\n\n- Open the [Package Manager](https://docs.unity3d.com/Manual/upm-ui.html) in a Unity project.\n- Click on the \"+\" button to add a new package.\n- Click on \"Install package from git URL...\".\n- Put in `https://github.com/Incantium/Auto-Reference.git`.\n- Click on \"Install\" or press enter.\n- Enjoy!\n\n## Limitations\n\n- Auto Reference is build for static references that do **not** change. For example, referencing a component on the same\n  (or closely related) game object is a valid way to use Auto Reference. This package does **not** automatically \n  reference a component when adding/removing during gameplay.\n- Auto Reference can only automatically reference classes that are serializable through the Unity Editor (see \n  [Component](https://docs.unity3d.com/ScriptReference/Component.html)).\n- Auto Reference works incorrectly when a prefab in a scene auto references a game object outside the prefab's scope. \n  This is a known bug.\n\n## Workflow\n\nOriginally, you may have code like this:\n\n```csharp\nusing UnityEngine;\n\n[RequireComponent(typeof(RigidBody))]\npublic class ExampleClass : MonoBehaviour\n{\n    private RigidBody rb;\n    \n    private void Start() \n    {\n        rb = GetComponent\u003cRigidBody\u003e();\n    }\n}\n```\n\nBut with Auto Reference, you can enhance it to this:\n\n```csharp\nusing Incantium.Attributes;\nusing UnityEngine;\n\n[RequireComponent(typeof(RigidBody))]\npublic class BetterExampleClass : MonoBehaviour\n{\n    [SerializeField]\n    [Auto Reference]\n    private RigidBody rb;\n}\n```\n\n## References\n\n| Class                                    | Description                                                             |\n|------------------------------------------|-------------------------------------------------------------------------|\n| [Auto Reference](API~/AutoReference.md)  | The Auto Reference attribute to automatically reference another script. |\n| [IReferenceable](API~/IReferenceable.md) | Interface for other classes able to be auto referenced.                 |\n| [Target](API~/Target.md)                 | The target location of the automatically referenced script.             |\n\n## Frequently Asked Questions\n\n### Which Unity versions are compatible with this package?\n\nThis package is heavily tested in `Unity 2022.3.44f1` and `Unity 6000.0.25f1`. It is expected that this package also \nworks in older and newer versions of the Unity Editor because it is not dependent on any other Unity packages.\n\n### Why does a warning appear when I use Auto Reference?\n\n![Warning not referenceable.png](Images~/Warning%20not%20referenceable.png)\n\nThis warning shows up when the field to be auto referenced is not referenceable through the Unity Editor (like all \nprimitive data structures such as integers, floats, and booleans). Only the classes inherited from \n[Component](https://docs.unity3d.com/ScriptReference/Component.html) are referenceable through the Unity Editor. The \nexception is the [IReferenceable](API~/IReferenceable.md) interface, which also makes it possible to be auto \nreferenced.\n\n### It is possible for custom classes to be auto referenced?\n\nYes. It is possible for classes that don't inherit from \n[Component](https://docs.unity3d.com/ScriptReference/Component.html) to be auto referenced, such as \n[serializable](https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute?view=net-9.0) classes. These \nclasses need to implement the [IReferenceable](API~/IReferenceable.md) interface to function properly with the\nAuto Reference attribute.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincantium%2Fauto-reference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincantium%2Fauto-reference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincantium%2Fauto-reference/lists"}