GUI.BeginScrollView - Scrolling only works when scrollVector is defined in main class.

Hello, i have multiple scrollviews in my app. Everything is working nicely as long as my scrollPosition vector is defined in my main class. The code is working perfectly, but as soon as i move the scrollPosition variable out of my main class into the class of the view which it belongs to (it is a normal C# class, not inheriting vom MonoBehaviour) it doesn’t work anymore.

Why is this? It is just a simple variable, how can it not be working when i only change where the variable is defined?

Is the scrollPosition Vector2 required to be inside a MonoBehaviour class?

ScrollPosition can be definitely placed everywhere, as long as you have access to it. There must be something wrong elsewhere. Either it’s a distraction error (meaning you’re setting viewClass.scrollPos = BeginScrollView([oldScrollPosVar]…), or something else is happening, and maybe scrollPos is getting reset each time.