{"id":13661718,"url":"https://github.com/Moolt/Unity-Null-Reference-Detection","last_synced_at":"2025-04-25T03:30:58.211Z","repository":{"id":210782686,"uuid":"157888362","full_name":"Moolt/Unity-Null-Reference-Detection","owner":"Moolt","description":"A lightweight plug-in that will find any unassigned component properties at design-time to avoid runtime null-reference exceptions.","archived":false,"fork":false,"pushed_at":"2023-12-04T21:59:58.000Z","size":489,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-10T16:46:04.332Z","etag":null,"topics":["asset","bug","component","debug","exception","find","free","null","reference","script","unassigned","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/Moolt.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":"2018-11-16T15:47:08.000Z","updated_at":"2024-08-22T14:11:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b824476-4b0b-4e6e-a950-982eb2692c45","html_url":"https://github.com/Moolt/Unity-Null-Reference-Detection","commit_stats":null,"previous_names":["moolt/unity-null-reference-detection"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnity-Null-Reference-Detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnity-Null-Reference-Detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnity-Null-Reference-Detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moolt%2FUnity-Null-Reference-Detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moolt","download_url":"https://codeload.github.com/Moolt/Unity-Null-Reference-Detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250747712,"owners_count":21480697,"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":["asset","bug","component","debug","exception","find","free","null","reference","script","unassigned","unity"],"created_at":"2024-08-02T05:01:40.327Z","updated_at":"2025-04-25T03:30:58.205Z","avatar_url":"https://github.com/Moolt.png","language":"C#","readme":"# Finding null references in Unity\n\n![alt text](https://raw.githubusercontent.com/Moolt/Unity-Null-Reference-Detection/master/Documentation/screenshot.png \"screenshot\")\n\nThis handy Unity plug-in helps you to find `null references` in your scene objects to avoid runtime exceptions. It's lightweight and both easy to install and to use.\n\n## Setup\n\nIf you want to get a quick overview you should check out the [demo project](https://github.com/Moolt/Unity-Null-Reference-Detection/archive/master.zip). \nYou can also download the [package](https://github.com/Moolt/Unity-Null-Reference-Detection/raw/master/null-reference-detection.unitypackage) containing only the essential scripts.\n\nAfter downloading and importing the package, you will find a new entry under `Tools \u003e Find Null References`.\n\n## How to use\n\nIn the screenshot above there's a cube with a script containing three references. Here's the example code:\n\n```csharp\nusing NullReferenceDetection;\nusing UnityEngine;\n\npublic class CubeScript : MonoBehaviour {\n\n    [SerializeField]\n    //Serialized, private fields are visible in the inspector\n    private SphereScript sphere;\n\n    [ValueRequired]\n    //Will be shown as red text if null\n    public CapsuleScript capsule;\n\n    [ValueOptional]\n    //Won't be shown even if null\n    public CylinderScript cylinder;\n}\n```\n\nAll fields that appear in the `Unity Inspector` will also be checked for `null` by the plug-in. That includes `public` fields and `serialized private` fields.\n\nIn addition you can use two custom attributes to further specify how your fields should be handled:\n  * `[ValueRequired]` will print a red error message if null\n  * `[ValueOptional]`won't show in the console even if null\n\n__Using these custom attributes is purely optional__.\n\nIf you now execute the plug-in via `Tools \u003e Find Null References` the console will show two error messages, like in the screenshot above. The `capsule` reference is marked as `required`, therefore it's show as red. `sphere` is shown with the default severity and `cylinder` is not shown at all as the `[ValueOptional]` attribute allows the field to be a `null` reference.\n\n## Project Settings\n\nYou can open the preferences window by navigating to `Edit -\u003e Project Settings -\u003e Null Reference Detection` where you can define which occurences of null references should be printed to the console. You can also change their text color.\n\nIf you want to automatically check for null references, you can do so by activating checks on entering play mode or on compilation. You can also prevent Unity from entering play mode if any null references were found.\n\n![alt text](https://raw.githubusercontent.com/Moolt/Unity-Null-Reference-Detection/master/Documentation/settings_screen.png \"preferences\")\n\nAdditionally in the preferences window you can define a list of GameObjects for which null references will be ignored, this is like the [ValueOptional] tag but affects the entire GameObject (and it's children, if the checkbox is ticked).\n\n![alt text](https://raw.githubusercontent.com/Moolt/Unity-Null-Reference-Detection/master/Documentation/settings_screen_ignore.png \"ignore list\")\n\nFinaly, by default the plug-in only scans GameObjects which are in the scene. If you have additional prefabs which are only instanciated at run-time, but you would like them to also be checked by the plug-in you can add the path to the prefab here.\n\n![alt text](https://raw.githubusercontent.com/Moolt/Unity-Null-Reference-Detection/master/Documentation/settings_screen_prefabs.png \"prefabs\")\n\n\n## Extension\n\nBy inheriting from the abstract `BaseAttribute` class you can implement your own attributes. They will also show up in the preferences window where you assign a color of your choice to your custom attribute.\n\n## Good to know\n\nClicking on an error message will highlight the target object in the `Hierarchy`, or if the target object is in a prefab it will highlight the folder in the `Project` panel.\n\nThe save files for the preferences are plain text files, aiding in ease of use so that you can easily see what was added or removed when staging files or working on a merge request etc.\n\n## The plug-in does not...\n *  check list items for null references.\n *  check for properties of default unity components (such as transform, box collider etc.)\n *  consider objects in other scenes but the currently opened scene.\n *  consider inactive objects.\n *  automatically update the entry of a prefab if the filename or path changes\n\n","funding_links":[],"categories":["C\\#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMoolt%2FUnity-Null-Reference-Detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMoolt%2FUnity-Null-Reference-Detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMoolt%2FUnity-Null-Reference-Detection/lists"}