Is there a way to execute a script before OnEnable of the ScriptableObjects are called? I tried RuntimeInitializeLoadType.BeforeSplashScreen and RuntimeInitializeLoadType.BeforeSceneLoad, but they are called after OnEnable.
-
Awake() is called before OnEnable(). Why not simply using it?kefren– kefren2019-08-11 14:09:23 +00:00Commented Aug 11, 2019 at 14:09
-
1I have the sneaking suspicion that you have the xy problem here. Is running code before OnEnable on a ScriptableObject your end goal, or are you using it to try to solve a different problem?Joe– Joe2019-08-11 14:14:19 +00:00Commented Aug 11, 2019 at 14:14
-
I want to be able to update my binary data (game progress) format, but I need to do that before the OnEnable method is called.Ruslan Plastun– Ruslan Plastun2019-08-11 15:33:04 +00:00Commented Aug 11, 2019 at 15:33
Add a comment
|
1 Answer
Yes, you can use Awake(), which is called on scripts before OnEnable.
Note that these messages work slightly differently on ScriptableObjects than on MonoBehaviours - there's a good thread over at Unity's forums discussing ScriptableObject events.