Initialization of MjScene in Unity #392
Unanswered
Balint-H
asked this question in
Asking for Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sometimes scripts and behaviours need to initialize with information from the
MjScene
. SinceMjScene
itself initialises onStart
this can be tricky, since the instance may not have already been created. I've been using workarounds as discussed in #360. Is there a better way than these available?Why is
MjScene
is initialised onStart
instead ofAwake
? That could make this simpler potentially. Alternatively, if initialising onStart
is important, an event called when the scene is created, that behaviour's could subscribe to would be handy.Lastly, on a couple occasions I ran into issues with scripts whose clean-up (
OnDisable
,OnDestroy
) code depended on either the state or existence of the mujoco scene (i.e. if it was destroyed already or not). In these cases what is the right way to check if its still instantiated? CheckingMjScene.Instance == null
unfortunately creates a new scene if it was already destroyed due to the singleton pattern.public static bool InstanceExists { get => _instance != null; }
or something similar would be helpful in those cases.Beta Was this translation helpful? Give feedback.
All reactions