{"id":19041745,"url":"https://github.com/joshcamas/unity-domain-reload-helper","last_synced_at":"2025-04-09T16:10:58.171Z","repository":{"id":38044203,"uuid":"226591533","full_name":"joshcamas/unity-domain-reload-helper","owner":"joshcamas","description":"A couple of attributes that help disabling Domain Reloading in Unity easier","archived":false,"fork":false,"pushed_at":"2024-07-08T16:24:25.000Z","size":516,"stargazers_count":212,"open_issues_count":4,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-09T16:10:50.149Z","etag":null,"topics":["unity","unity3d"],"latest_commit_sha":null,"homepage":null,"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/joshcamas.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":"2019-12-07T23:56:45.000Z","updated_at":"2025-03-14T02:54:10.000Z","dependencies_parsed_at":"2024-07-08T20:17:35.250Z","dependency_job_id":"9fb4c10e-e66a-4894-a33b-df12d7f913a2","html_url":"https://github.com/joshcamas/unity-domain-reload-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcamas%2Funity-domain-reload-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcamas%2Funity-domain-reload-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcamas%2Funity-domain-reload-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshcamas%2Funity-domain-reload-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshcamas","download_url":"https://codeload.github.com/joshcamas/unity-domain-reload-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065284,"owners_count":21041872,"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":["unity","unity3d"],"created_at":"2024-11-08T22:31:27.700Z","updated_at":"2025-04-09T16:10:58.150Z","avatar_url":"https://github.com/joshcamas.png","language":"C#","funding_links":[],"categories":["GamePlay"],"sub_categories":["HUD"],"readme":"# UnityDomainReloadHelper\n\nA couple of attributes that help when [Domain Reloading](https://docs.unity3d.com/2019.3/Documentation/Manual/DomainReloading.html) is disabled, which significantly decreases the time it takes for Unity to play a scene. By default Unity provides [RuntimeInitializeOnLoadMethod](https://docs.unity3d.com/Manual/DomainReloading.html) attribute to assist but it can be a little cumbersome. Here are a few helpful additions!\n\n## ClearOnReloadAttribute\nUse the `ClearOnReload` attribute on static fields that you wish to reset on playmode. You can either \"clear\" the field (set the value to default), set it to a specified value, or make it assign itself a new instance of its type using a default constructor.\n\n## ExecuteOnReloadAttribute\nUse the `ExecuteOnReload` attribute on static methods that you want to execute when entering play mode with domain reloading disabled.\n\n### Examples\n```csharp\npublic class CharacterManager : MonoBehaviour\n{\n  // Will set value to default (null).\n  [ClearOnReload]\n  static CharacterManager instance;\n  \n  // Will set variable to given value (10).\n  [ClearOnReload(valueToAssign=10)]\n  static int startsAsTen;\n  \n  // Will reset value, creating a new instance using default constructor.\n  [ClearOnReload(assignNewTypeInstance=true)]\n  static CharacterManager myNeverNullManager;\n  \n  // Will execute this method.\n  [ExecuteOnReload]\n  static void RunThis() \n  {\n    Debug.Log(\"Clean up here.\")\n  }\n\n  // Does not work on properties!\n  // [ClearOnReload] \n  static int number { get; set; }\n\n  // Does not work on events!\n  // [ClearOnReload] \n  static event Action onDoSomething;\n\n  // However, one can use ExecuteOnReload to do their own clean up.\n  [ExecuteOnReload]\n  static void CleanUpEvents() \n  {\n    foreach(Delegate d in onDoSomething.GetInvocationList())\n      onDoSomething -= d;\n   \n  }\n}\n```\n\n## FAQ\n\n- Why not support clearing properties and events?\n\n[TypeCache](https://docs.unity3d.com/ScriptReference/TypeCache.html) makes finding attributes fast; however, it only supports finding fields, methods, types, and derived types.\n\n## License\n\nThis project is released under the MIT license.\n\n## Acknowledgments\n\nThis [project](https://github.com/joshcamas/unity-domain-reload-helper) is written by [Josh Steinhauer](https://twitter.com/joshcamas) with contributions from [Yevhen Bondarenko](https://github.com/JGroxz) and [Shane Celis](https://twitter.com/shanecelis).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshcamas%2Funity-domain-reload-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshcamas%2Funity-domain-reload-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshcamas%2Funity-domain-reload-helper/lists"}