暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using UnityEngine;
  2. using UnityEditor;
  3. namespace UnityEditor.U2D.Path.GUIFramework
  4. {
  5. /// <summary>
  6. /// Represents transform data for a slider.
  7. /// </summary>
  8. /// <remarks>
  9. /// Unity uses this data to position and orient the slider in the custom editor.
  10. /// </remarks>
  11. public struct SliderData
  12. {
  13. /// <summary>
  14. /// The slider's position.
  15. /// </summary>
  16. public Vector3 position;
  17. /// <summary>
  18. /// The slider's forward vector.
  19. /// </summary>
  20. public Vector3 forward;
  21. /// <summary>
  22. /// The slider's up vector.
  23. /// </summary>
  24. public Vector3 up;
  25. /// <summary>
  26. /// The slider's right vector.
  27. /// </summary>
  28. public Vector3 right;
  29. /// <summary>
  30. /// zero definition for SliderData
  31. /// </summary>
  32. public static readonly SliderData zero = new SliderData() { position = Vector3.zero, forward = Vector3.forward, up = Vector3.up, right = Vector3.right };
  33. }
  34. /// <summary>
  35. /// Interface for GUIStates
  36. /// </summary>
  37. public interface IGUIState
  38. {
  39. /// <summary>
  40. /// The mouse position.
  41. /// </summary>
  42. Vector2 mousePosition { get; }
  43. /// <summary>
  44. /// The mouse button pressed.
  45. /// </summary>
  46. int mouseButton { get; }
  47. /// <summary>
  48. /// The number of mouse clicks.
  49. /// </summary>
  50. int clickCount { get; set; }
  51. /// <summary>
  52. /// Indicates whether the shift key is pressed.
  53. /// </summary>
  54. bool isShiftDown { get; }
  55. /// <summary>
  56. /// Indicates whether the alt key is pressed.
  57. /// </summary>
  58. bool isAltDown { get; }
  59. /// <summary>
  60. /// Indicates whether the action key is pressed.
  61. /// </summary>
  62. bool isActionKeyDown { get; }
  63. /// <summary>
  64. /// The KeyCode of the currently pressed key.
  65. /// </summary>
  66. KeyCode keyCode { get; }
  67. /// <summary>
  68. /// The type of the event.
  69. /// </summary>
  70. EventType eventType { get; }
  71. /// <summary>
  72. /// The name of the event's command.
  73. /// </summary>
  74. string commandName { get; }
  75. /// <summary>
  76. /// The closest control to the event.
  77. /// </summary>
  78. int nearestControl { get; set; }
  79. /// <summary>
  80. /// Hot Control
  81. /// </summary>
  82. int hotControl { get; set; }
  83. /// <summary>
  84. /// Indicates whether the GUI has changed.
  85. /// </summary>
  86. bool changed { get; set; }
  87. /// <summary>
  88. /// <summary>
  89. /// Gets the ID of a nested control by a hint and focus type.
  90. /// </summary>
  91. /// <param name="hint">The hint this function uses to identify the control ID.</param>
  92. /// <param name="focusType">The focus Type</param>
  93. /// <returns>Returns the ID of the control that matches the hint and focus type.</returns>
  94. int GetControlID(int hint, FocusType focusType);
  95. /// <summary>
  96. /// Adds a control to the GUIState.
  97. /// </summary>
  98. /// <param name="controlID">The ID of the control to add.</param>
  99. /// <param name="distance">The distance from the camera to the control.</param>
  100. void AddControl(int controlID, float distance);
  101. /// <summary>
  102. /// Checks whether a slider value has changed.
  103. /// </summary>
  104. /// <param name="id">The ID of the slider to check.</param>
  105. /// <param name="sliderData">The slider's data.</param>
  106. /// <param name="newPosition">The new position of the slider.</param>
  107. /// <returns>Returns `true` if the slider has changed. Otherwise, returns `false`.</returns>
  108. bool Slider(int id, SliderData sliderData, out Vector3 newPosition);
  109. /// <summary>
  110. /// Uses the event.
  111. /// </summary>
  112. void UseEvent();
  113. /// <summary>
  114. /// Repaints the GUI.
  115. /// </summary>
  116. void Repaint();
  117. /// <summary>
  118. /// Checks if the current camera is valid.
  119. /// </summary>
  120. /// <returns>Returns `true` if the current camera is not null. Otherwise, returns `false`.</returns>
  121. bool HasCurrentCamera();
  122. /// <summary>
  123. /// Gets the size of the handle.
  124. /// </summary>
  125. /// <param name="position">The position of the handle.</param>
  126. /// <returns>Returns the size of the handle.</returns>
  127. float GetHandleSize(Vector3 position);
  128. /// <summary>
  129. /// Measures the GUI-space distance between two points of a segment.
  130. /// </summary>
  131. /// <param name="p1">The first point.</param>
  132. /// <param name="p2">The second point.</param>
  133. /// <returns>Returns the GUI-space distance between p1 and p2.</returns>
  134. float DistanceToSegment(Vector3 p1, Vector3 p2);
  135. /// <summary>
  136. /// Measures the distance to a circle.
  137. /// </summary>
  138. /// <param name="center">The center of the circle</param>
  139. /// <param name="radius">The radius of the circle</param>
  140. /// <returns>Returns the distance to a circle with the specified center and radius.</returns>
  141. float DistanceToCircle(Vector3 center, float radius);
  142. /// <summary>
  143. /// Transforms a GUI-space position into world space.
  144. /// </summary>
  145. /// <param name="guiPosition">The GUI Position.</param>
  146. /// <param name="planeNormal">The plane normal.</param>
  147. /// <param name="planePos">The plane position.</param>
  148. /// <returns>Returns the world-space position of `guiPosition`.</returns>
  149. Vector3 GUIToWorld(Vector2 guiPosition, Vector3 planeNormal, Vector3 planePos);
  150. }
  151. }