NeighTools / UnityDoorstop

Doorstop -- run C# before Unity does!
GNU Lesser General Public License v2.1
419 stars 62 forks source link

Would it be possible to use this to override the behaviour of the Unity editor (not for games built in Unity)? #55

Closed vinaysshenoy closed 1 month ago

vinaysshenoy commented 2 months ago

I am trying to build something that needs to load before the Unity editor starts importing assets on launching a project. The gist is that I want to intercept any file system API calls which the Unity editor makes and capture some information when it does. I could override the calls to the file system API via reflection, but the editor does not seem to way to hook into the editor launch pipeline.

Unity does have an [InitializeOnLoad] functionality, but that only starts executing after the asset database refresh completes, so it does not work for my use case. I am wondering if I could use this to run code before the editor starts importing the project.

ManlyMarco commented 2 months ago

I would guess that the pipeline runs mostly in native so you can't do much directly from managed code. You should be able to use the same technique as doorstop to hook into the filesystem functions though, but that's just general dll override stuff.