Helpers.cs 992 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. public class Helpers
  3. {
  4. public static void DrawPlane(Vector3 position , Vector3 normal) {
  5. Vector3 v3;
  6. if (normal.normalized != Vector3.forward)
  7. v3 = Vector3.Cross(normal, Vector3.forward).normalized * normal.magnitude;
  8. else
  9. v3 = Vector3.Cross(normal, Vector3.up).normalized * normal.magnitude;;
  10. var corner0 = position + v3;
  11. var corner2 = position - v3;
  12. var q = Quaternion.AngleAxis(90.0f, normal);
  13. v3 = q * v3;
  14. var corner1 = position + v3;
  15. var corner3 = position - v3;
  16. Debug.DrawLine(corner0, corner2, Color.green);
  17. Debug.DrawLine(corner1, corner3, Color.green);
  18. Debug.DrawLine(corner0, corner1, Color.green);
  19. Debug.DrawLine(corner1, corner2, Color.green);
  20. Debug.DrawLine(corner2, corner3, Color.green);
  21. Debug.DrawLine(corner3, corner0, Color.green);
  22. Debug.DrawRay(position, normal, Color.red);
  23. }
  24. }