From 2f64cf36c5287167b72a395858e952626c196b1e Mon Sep 17 00:00:00 2001 From: Balint-H Date: Mon, 4 Mar 2024 13:49:00 +0000 Subject: [PATCH] Conditional compilation for Tendon visualization --- unity/Runtime/Components/Tendons/MjSpatialTendon.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unity/Runtime/Components/Tendons/MjSpatialTendon.cs b/unity/Runtime/Components/Tendons/MjSpatialTendon.cs index 6a11f659..cfff6c0b 100644 --- a/unity/Runtime/Components/Tendons/MjSpatialTendon.cs +++ b/unity/Runtime/Components/Tendons/MjSpatialTendon.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices.ComTypes; using System.Xml; @@ -111,6 +112,7 @@ public class MjSpatialTendon : MjBaseTendon { return mjcf; } + [Conditional("UNITY_EDITOR")] public unsafe void OnDrawGizmosSelected() { if (Application.isPlaying && MjScene.InstanceExists) { // Lifted from src/engine/engine_vis_visualize.c @@ -134,7 +136,7 @@ public class MjSpatialTendon : MjBaseTendon { // At the moment we use handles instead of Gizmos (to be able to set width). // This means rendering won't be performed outside editor; We could implement a "TendonRenderer" component // (added using a context tool) that uses a LineRenderer. Then we could have nice features such as updating - // tendon colors or width based on length or tension. That would also allow in-build rendering. + // tendon colors or width based on length or tension. That would also allow in-build rendering. Handles.color = Color.magenta; // Currently we ignore tendon material. Handles.DrawLine(startPos, endPos, (float)sz/0.003f); // Handle width in UI points. We map the default width to 1 pixel. }