MonoInjection
Replaces Update with a high performance subscription model and allows multi-threaded scripts to "inject" code into the main Unity thread.
Install / Use
/learn @DameonL/MonoInjectionREADME
MonoInjection
Replaces Unity's magic Update method with a high performance, high control subscription model that allows any object (not just MonoBehaviours) to tie itself into the game loop, and allows multi-threaded scripts to "inject" code into the main Unity thread.
Why use this script?
This script fixes a variety of problems with the default Unity system:
-
Performance - Calls to the Update method from the Unity engine require crossing the C++/C# barrier, which has costs that are not associated with C#/C# calls. If you have a large amount of in-scene objects with Update calls, you will get a significant boost in performance from using this script.
-
Control - You have little control over whether Update is called on an object. With the MonoInjector, objects can selectively remove themselves from the game loop without side effects on other systems (like collisions). The entire MonoInjector can be disabled to instantly stop ALL subscribers from updating. With multiple MonoInjectors, you can group subscriptions to selectively enable and disable the behaviour of a large group of objects.
-
Flexibility - With Unity's default method, an object must be a MonoBehaviour to receive Update calls. This method allows any object to tie itself into the game loop.
Using the script is simple. Attach the MonoInjector component to an empty object in your scene. Any object that wants to subscribe to the Update loop needs to implement the IUpdate interface, and be registered with the MonoInjector using the Subscribe method. The Unsubscribe method will remove an object from the loop. For calls from multi-threaded scripts, the Inject method can schedule a delegate to be called once on the next frame (this creates a certain amount of unavoidable garbage). If your scripts need to use FixedUpdate or LateUpdate, set the Injection Mode of the MonoInjector to the relevant mode.
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
