-1

I am trying to wrap my head around ScriptableObjects and their possibilities. My goal is to have a Mouse Manager that keeps track of the mouse position, objects it's hovering over, and other behaviors. I want this manager to be read by anything that wants to know whenever it wants to know it.

I know I could make a MonoBehavior script that has ScriptableObject Variables (like a Vector3) that it keeps updated, but that requires me to add the manager to each scene manually. And then I would need to include each variable as a reference into any other asset that needs to read it.

Is there a better way to do this? Have the manager as a ScriptableObject, each attribute also a ScriptableObject, and just reference the manager in whatever script needs access to it?

Justin Anthony
  • 416
  • 1
  • 3
  • 13
  • 1
    Sounds like you rather want to work with `static`s - maybe even a Singleton pattern (there are lots of example for this). Mostly it is combined with `DontDestroyOnLoad` – derHugo Aug 04 '20 at 06:53

1 Answers1

1

From unity docs:

The main use cases for ScriptableObjects are:

  • Saving and storing data during an Editor session
  • Saving data as an Asset in your Project to use at run time

I don't think that what you want to achieve is possible, since things like mouse position change at runtime. However I believe that creating a MonoBehavior script should work fine. Since it needs to be on every scene, you could make use of prefabs and DontDestroyOnLoad.

Sebastián
  • 88
  • 1
  • 5