Is there a way to set a GUI.matrix that will be used by all OnGui() functions?

Hello,

I’m making my own gui library using mvc pattern, since each object I’m making (a button for example) has its own data/logic and its own OnGui function, I was wondering if there’s a way to set a scale matrix on a script so that each OnGui function use that matrix or do I need to set this scale matrix on the beginning of each OnGui function?
I’ve tried setting this scale matrix on a script and I made it execute as the first script by setting its priority on Project Settings-> Script execution order,
the scale matrix is successfully applied however it works only for objects being drawn in the same script, objects being drawn from other OnGui use the default matrix,
to make them use that matrix I need to reapply it in the beginning of the OnGui.
any better workaround?

Unity prepares the environment for each callback it’s going to invoke. So the answer is: Yes, you need to set it in each OnGUI function seperately.

The static nature of a lot of things in Unity might make you think it’s a statemachine. Well, it actually is, but it’s not completely under your control. Unity uses those variables to provide state information for the current execution of a callback. The Event class, which is the most important thing in OnGUI, works the same way. Camera.current is another example