Add post-compile and pre-destroy events to MjScene.
PiperOrigin-RevId: 498516529 Change-Id: I52dbf135e3260ca2999069bcb9f9b9ad648595d2
This commit is contained in:
committed by
Copybara-Service
parent
95b9a0f215
commit
f78ebeab96
@@ -78,9 +78,11 @@ public class MjScene : MonoBehaviour {
|
||||
|
||||
private List<MjComponent> _orderedComponents;
|
||||
|
||||
public EventHandler<MjStepArgs> postInitEvent;
|
||||
public EventHandler preUpdateEvent;
|
||||
public EventHandler<MjStepArgs> ctrlCallback;
|
||||
public EventHandler postUpdateEvent;
|
||||
public EventHandler<MjStepArgs> 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;
|
||||
|
||||
Reference in New Issue
Block a user