Find MjScene at OnEnable: ensure MuJoCo compilation happens only once at startup.

PiperOrigin-RevId: 498655077
Change-Id: Ibed8f36a880426063b7729fc66b15c67adcc9a65
This commit is contained in:
Tom Erez
2022-12-30 18:37:17 -08:00
committed by Copybara-Service
parent f78ebeab96
commit eb8389fead
3 changed files with 3 additions and 3 deletions
@@ -49,8 +49,7 @@ namespace Mujoco {
DofAddress = model->jnt_dofadr[MujocoId];
}
protected override void Start() {
base.Start();
protected void Start() {
MjBaseBody grandparentBody, parentBody;
GetConnectedBodies(out grandparentBody, out parentBody);
GrandParentBody = grandparentBody;
+1 -1
View File
@@ -77,7 +77,7 @@ public abstract class MjComponent : MonoBehaviour {
private bool _sceneExcludesMe = false;
protected unsafe virtual void Start() {
protected unsafe virtual void OnEnable() {
if (MjScene.Instance == null) {
throw new Exception("MuJoCo Scene not found");
}
+1
View File
@@ -85,6 +85,7 @@ public class MjScene : MonoBehaviour {
public EventHandler<MjStepArgs> preDestroyEvent;
protected unsafe void Start() {
SceneRecreationAtLateUpdateRequested = false;
CreateScene();
}