From f78ebeab964da7f9280f5bb3bbc6eb4f479390b0 Mon Sep 17 00:00:00 2001 From: Tom Erez Date: Thu, 29 Dec 2022 22:42:31 -0800 Subject: [PATCH] Add post-compile and pre-destroy events to MjScene. PiperOrigin-RevId: 498516529 Change-Id: I52dbf135e3260ca2999069bcb9f9b9ad648595d2 --- unity/Runtime/Components/MjScene.cs | 4 ++++ 1 file changed, 4 insertions(+) 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;