using UnityEngine; using UnityEditor; namespace UnityEditor.U2D.Path.GUIFramework { /// /// Represents transform data for a slider. /// /// /// Unity uses this data to position and orient the slider in the custom editor. /// public struct SliderData { /// /// The slider's position. /// public Vector3 position; /// /// The slider's forward vector. /// public Vector3 forward; /// /// The slider's up vector. /// public Vector3 up; /// /// The slider's right vector. /// public Vector3 right; /// /// zero definition for SliderData /// public static readonly SliderData zero = new SliderData() { position = Vector3.zero, forward = Vector3.forward, up = Vector3.up, right = Vector3.right }; } /// /// Interface for GUIStates /// public interface IGUIState { /// /// The mouse position. /// Vector2 mousePosition { get; } /// /// The mouse button pressed. /// int mouseButton { get; } /// /// The number of mouse clicks. /// int clickCount { get; set; } /// /// Indicates whether the shift key is pressed. /// bool isShiftDown { get; } /// /// Indicates whether the alt key is pressed. /// bool isAltDown { get; } /// /// Indicates whether the action key is pressed. /// bool isActionKeyDown { get; } /// /// The KeyCode of the currently pressed key. /// KeyCode keyCode { get; } /// /// The type of the event. /// EventType eventType { get; } /// /// The name of the event's command. /// string commandName { get; } /// /// The closest control to the event. /// int nearestControl { get; set; } /// /// Hot Control /// int hotControl { get; set; } /// /// Indicates whether the GUI has changed. /// bool changed { get; set; } /// /// /// Gets the ID of a nested control by a hint and focus type. /// /// The hint this function uses to identify the control ID. /// The focus Type /// Returns the ID of the control that matches the hint and focus type. int GetControlID(int hint, FocusType focusType); /// /// Adds a control to the GUIState. /// /// The ID of the control to add. /// The distance from the camera to the control. void AddControl(int controlID, float distance); /// /// Checks whether a slider value has changed. /// /// The ID of the slider to check. /// The slider's data. /// The new position of the slider. /// Returns `true` if the slider has changed. Otherwise, returns `false`. bool Slider(int id, SliderData sliderData, out Vector3 newPosition); /// /// Uses the event. /// void UseEvent(); /// /// Repaints the GUI. /// void Repaint(); /// /// Checks if the current camera is valid. /// /// Returns `true` if the current camera is not null. Otherwise, returns `false`. bool HasCurrentCamera(); /// /// Gets the size of the handle. /// /// The position of the handle. /// Returns the size of the handle. float GetHandleSize(Vector3 position); /// /// Measures the GUI-space distance between two points of a segment. /// /// The first point. /// The second point. /// Returns the GUI-space distance between p1 and p2. float DistanceToSegment(Vector3 p1, Vector3 p2); /// /// Measures the distance to a circle. /// /// The center of the circle /// The radius of the circle /// Returns the distance to a circle with the specified center and radius. float DistanceToCircle(Vector3 center, float radius); /// /// Transforms a GUI-space position into world space. /// /// The GUI Position. /// The plane normal. /// The plane position. /// Returns the world-space position of `guiPosition`. Vector3 GUIToWorld(Vector2 guiPosition, Vector3 planeNormal, Vector3 planePos); } }