diff --git a/unity/Runtime/Components/MjScene.cs b/unity/Runtime/Components/MjScene.cs index 4a4d04a9..77f4c654 100644 --- a/unity/Runtime/Components/MjScene.cs +++ b/unity/Runtime/Components/MjScene.cs @@ -78,9 +78,11 @@ public class MjScene : MonoBehaviour { private List _orderedComponents; + public EventHandler postInitEvent; public EventHandler preUpdateEvent; public EventHandler ctrlCallback; public EventHandler postUpdateEvent; + public EventHandler preDestroyEvent; protected unsafe void Start() { CreateScene(); @@ -167,6 +169,7 @@ public class MjScene : MonoBehaviour { // Compile the scene from the Mjcf. CompileScene(sceneMjcf, _orderedComponents); } + postInitEvent?.Invoke(this, new MjStepArgs(Model, Data)); return sceneMjcf; } @@ -305,6 +308,7 @@ public class MjScene : MonoBehaviour { // Destroys the Mujoco scene. public unsafe void DestroyScene() { + preDestroyEvent?.Invoke(this, new MjStepArgs(Model, Data)); if (Model != null) { MujocoLib.mj_deleteModel(Model); Model = null;