暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LayoutData.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using UnityEngine;
  2. namespace UnityEditor.U2D.Path.GUIFramework
  3. {
  4. /// <summary>
  5. /// Represents the layout of a GUI element in a custom editor.
  6. /// </summary>
  7. public struct LayoutData
  8. {
  9. /// <summary>
  10. /// The layout's index.
  11. /// </summary>
  12. public int index;
  13. /// <summary>
  14. /// The distance from the layout to the camera.
  15. /// </summary>
  16. public float distance;
  17. /// <summary>
  18. /// The layout's world-space position.
  19. /// </summary>
  20. public Vector3 position;
  21. /// <summary>
  22. /// The layout's world-space forward vector.
  23. /// </summary>
  24. public Vector3 forward;
  25. /// <summary>
  26. /// The layout's world-space up vector.
  27. /// </summary>
  28. public Vector3 up;
  29. /// <summary>
  30. /// The layout's world-space right vector.
  31. /// </summary>
  32. public Vector3 right;
  33. /// <summary>
  34. /// The layout's user data.
  35. /// </summary>
  36. public object userData;
  37. /// <summary>
  38. /// Zero definition of LayoutData.
  39. /// </summary>
  40. public static readonly LayoutData zero = new LayoutData() { index = 0, distance = float.MaxValue, position = Vector3.zero, forward = Vector3.forward, up = Vector3.up, right = Vector3.right };
  41. /// <summary>
  42. /// Gets the layout that is closest to the camera,
  43. /// </summary>
  44. /// <param name="currentData">The current layout.</param>
  45. /// <param name="newData">The new layout to compare with.</param>
  46. /// <returns>Returns the closest layout to the camera. If `currentData` is closest to the camera, returns `currentData`. Otherwise, if `newData` is closest to the camera, returns `newData`.</returns>
  47. public static LayoutData Nearest(LayoutData currentData, LayoutData newData)
  48. {
  49. if (newData.distance <= currentData.distance)
  50. return newData;
  51. return currentData;
  52. }
  53. }
  54. }