2
0

CustomWheelColliderEditor.cs 815 B

1234567891011121314151617181920212223242526272829
  1. using UnityEditor;
  2. using UnityEngine;
  3. [CustomEditor(typeof(CustomWheelCollider))]
  4. // ReSharper disable once CheckNamespace
  5. public class CustomWheelColliderEditor : Editor
  6. {
  7. private CustomWheelCollider c;
  8. public void OnSceneGUI()
  9. {
  10. c = target as CustomWheelCollider;
  11. if (c == null) return;
  12. Handles.color = Color.magenta;
  13. var transform = c.transform;
  14. var position = transform.position;
  15. Handles.DrawWireDisc(position
  16. , transform.right // normal
  17. , c.radius); // radius
  18. var directions = c.CalculateRayDirections();
  19. foreach (var d in directions)
  20. {
  21. var direction = transform.TransformDirection(d);
  22. Handles.DrawLine(position, position + direction * c.radius);
  23. }
  24. }
  25. }