Is it possible to run code before Unity Initialises?

I’d like to run some code before Unity initialises the OpenGL/D3D device. Is that even possible? If Unity does not directly support this then is it perhaps possible through some plugin magic?

edit
Sorry, I should point out that this is for a standalone build, not Android, Web or iOS.

The short answers (I think):

  • On standalone builds, unless you have the source code; no.
  • On Android, yes by starting your own activity first and then kicking off the Unity activity later. I do this already to handle Google’s obb file downloading.
  • On iOS… hmm, not sure.