{"id":13661249,"url":"https://github.com/yasirkula/UnityOrderedUpdate","last_synced_at":"2025-04-24T23:32:15.237Z","repository":{"id":88523371,"uuid":"95697029","full_name":"yasirkula/UnityOrderedUpdate","owner":"yasirkula","description":"Receive Update callback(s) from anywhere and in any order in Unity!","archived":true,"fork":false,"pushed_at":"2017-06-28T18:46:08.000Z","size":25,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-16T09:24:03.321Z","etag":null,"topics":[],"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/yasirkula.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}},"created_at":"2017-06-28T17:59:31.000Z","updated_at":"2025-03-14T07:51:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1b77fea-d413-4bf4-a383-e0ee3616e4e2","html_url":"https://github.com/yasirkula/UnityOrderedUpdate","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/yasirkula%2FUnityOrderedUpdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityOrderedUpdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityOrderedUpdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yasirkula%2FUnityOrderedUpdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yasirkula","download_url":"https://codeload.github.com/yasirkula/UnityOrderedUpdate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250727791,"owners_count":21477372,"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":[],"created_at":"2024-08-02T05:01:31.558Z","updated_at":"2025-04-24T23:32:14.965Z","avatar_url":"https://github.com/yasirkula.png","language":"C#","readme":"# Unity3D Ordered Update\nThis script helps you receive **Update** callbacks from any of your scripts or objects, in any order. Here are some common use-cases:\n\n- Receiving Update callback in *static* or *non-MonoBehaviour* objects\n- Calling a **PreUpdate** function \"**before**\" all the Update calls (similar to how LateUpdate is called \"*after*\" all the Update calls)\n- Calling a function before/after all the *Update*, *LateUpdate* and/or *FixedUpdate* calls\n- Making sure that object A's Update method is called before object B's Update method\n- Receiving Update calls even if the object is inactive\n\nSimply import **OrderedUpdate.unitypackage** into your project and you are good to go! Just make sure that the execution orders of **OrderedUpdatePreCallback** and **OrderedUpdatePostCallback** are correct in **Edit-Project Settings-Script Execution Order**:\n\n![ScriptExecutionOrder](ScriptExecutionOrderImg.png)\n\n## How To\n- To receive an Update callback in any of your objects, it is sufficient to register to `OrderedUpdate.OnUpdate` event. But don't forget to unregister from the event when the object is destroyed, just in case (so, using anonymous functions is not recommended unless you know what you are doing).\n- To receive a callback before all the Update calls, you can register to `OrderedUpdate.OnPreUpdate` event. For example:\n\n```csharp\nvoid Awake() {\n\tOrderedUpdate.OnPreUpdate += OnPreUpdate;\n}\n\nprivate void OnPreUpdate() {\n\t// called every frame, before other Update calls\n}\n\nvoid OnDestroy() {\n\tOrderedUpdate.OnPreUpdate -= OnPreUpdate;\n}\n```\n\n- To receive a callback before/after all the Update, LateUpdate and/or FixedUpdate calls, use one of the following functions with a custom order:\n\n```csharp\nOrderedUpdate.AddUpdateReceiver( OrderedUpdate.UpdateCallback receiver, int order );\nOrderedUpdate.AddFixedUpdateReceiver( OrderedUpdate.UpdateCallback receiver, int order );\nOrderedUpdate.AddLateUpdateReceiver( OrderedUpdate.UpdateCallback receiver, int order );\n```\n\n- To call an A function (located in any of your scripts) before a B function (again, located in any of your scripts) every frame, just make sure that function A's order is smaller than function B's order while calling *AddUpdateReceiver/AddFixedUpdateReceiver/AddLateUpdateReceiver*.\n\n- An Update callback registered to OrderedUpdate continues to execute even if the container object becomes inactive later in the game. If you don't want to call the function if the object is inactive, simply register your function to OrderedUpdate in **OnEnable** and unregister it in **OnDisable**.\n\n## Method Signatures\n```csharp\npublic delegate void UpdateCallback();\n\npublic static event UpdateCallback OnPreUpdate;\npublic static event UpdateCallback OnUpdate;\npublic static event UpdateCallback OnFixedUpdate;\npublic static event UpdateCallback OnLateUpdate;\n\npublic static void OrderedUpdate.AddUpdateReceiver( UpdateCallback receiver, int order = 0 );\npublic static void OrderedUpdate.AddFixedUpdateReceiver( UpdateCallback receiver, int order = 0 );\npublic static void OrderedUpdate.AddLateUpdateReceiver( UpdateCallback receiver, int order = 0 );\n\npublic static void OrderedUpdate.RemoveUpdateReceiver( UpdateCallback receiver, int order = 0 );\npublic static void OrderedUpdate.RemoveFixedUpdateReceiver( UpdateCallback receiver, int order = 0 );\npublic static void OrderedUpdate.RemoveLateUpdateReceiver( UpdateCallback receiver, int order = 0 );\n```\n","funding_links":[],"categories":["C\\#","C#","Script Utility"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasirkula%2FUnityOrderedUpdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasirkula%2FUnityOrderedUpdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasirkula%2FUnityOrderedUpdate/lists"}