Enable mouse spring perturbations when clicking on a geom in scene view

This commit is contained in:
Bálint Hodossy
2023-11-17 14:43:10 +00:00
parent 4d2a176a8a
commit 7062c6f677
2 changed files with 7 additions and 3 deletions
+6 -2
View File
@@ -23,7 +23,7 @@ namespace Mujoco {
// and left mouse drag will apply a force on the body. Holding shift down will change the applied
// force direction between World XZ plane and Y[camera-up].
[CustomEditor(typeof(MjBody))]
[CustomEditor(typeof(MjComponent), true)]
public class MjMouseSpring : Editor {
private bool _lastShiftKeyState = false;
@@ -102,7 +102,11 @@ namespace Mujoco {
return;
}
MjBody body = target as MjBody;
var targetObject = target as MjComponent;
MjBody body = targetObject.GetComponentInParent<MjBody>();
if(!body)
return;
Vector3 bodyPosition =
body != null ? body.transform.position : Vector3.zero;
var scene = MjScene.Instance;
@@ -22,7 +22,7 @@ namespace Mujoco {
[CustomEditor(typeof(MjShapeComponent), true)]
[CanEditMultipleObjects]
public class MjShapeComponentEditor : Editor {
public class MjShapeComponentEditor : MjMouseSpring {
public override void OnInspectorGUI() {