Skip to content

Commit

Permalink
Add missing method
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Jun 29, 2020
1 parent f794acc commit 2f41df1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions DrawTools.cs
@@ -1,3 +1,4 @@
using System.Reflection;
using UnityEngine;

public static class DrawTools
Expand Down Expand Up @@ -444,4 +445,29 @@ public static void DrawCylinder(Vector3 start, Vector3 end, Color color, float r
DrawLine(end - forward, end + forward, color);
GLEnd();
}

private static FieldInfo jointMode;

public static void DrawJoint(PartJoint joint)
{
if (joint == null)
return;

if (joint.Host == null || joint.Child == null || joint.Parent == null)
return;

Color col = joint.Host == joint.Child ? Color.blue : Color.red;

if (jointMode == null)
jointMode = typeof(PartJoint).GetField("mode", BindingFlags.NonPublic | BindingFlags.Instance);

float node = ((AttachModes)jointMode.GetValue(joint)) == AttachModes.STACK ? 1 : 0.6f;

GLStart();
GL.Color(col * node);

DrawLine(joint.Child.transform.position, joint.Parent.transform.position, col * node);

GLEnd();
}
}

0 comments on commit 2f41df1

Please sign in to comment.