#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI using System.Text; using UnityEngine.EventSystems; using UnityEngine.InputSystem.Controls; namespace UnityEngine.InputSystem.UI { /// /// An extension to PointerEventData which makes additional data about the input event available. /// /// /// Instances of this class are sent instead of by /// for all pointer-type input. /// /// The property will generally correspond to the /// of . An exception to this are touches as each may generate several pointers /// (one for each active finger). /// public class ExtendedPointerEventData : PointerEventData { public ExtendedPointerEventData(EventSystem eventSystem) : base(eventSystem) { } /// /// The that generated the pointer input. /// /// /// /// /// public InputDevice device { get; set; } /// /// For type pointer input, this is the touch ID as reported by the /// device. /// /// /// For pointer input that is not coming from touch, this will be 0 (which is not considered a valid touch ID /// by the input system). /// /// Note that for touch input, will be a combination of the /// device ID of and the touch ID to generate a unique pointer ID even if there /// are multiple touchscreens. /// /// public int touchId { get; set; } /// /// Type of pointer that generated the input. /// public UIPointerType pointerType { get; set; } /// /// For type pointer input, this is the world-space position of /// the . /// /// public Vector3 trackedDevicePosition { get; set; } /// /// For type pointer input, this is the world-space orientation of /// the . /// /// public Quaternion trackedDeviceOrientation { get; set; } public override string ToString() { var stringBuilder = new StringBuilder(); stringBuilder.Append(base.ToString()); stringBuilder.AppendLine("device: " + device); stringBuilder.AppendLine("pointerType: " + pointerType); stringBuilder.AppendLine("touchId: " + touchId); stringBuilder.AppendLine("trackedDevicePosition: " + trackedDevicePosition); stringBuilder.AppendLine("trackedDeviceOrientation: " + trackedDeviceOrientation); return stringBuilder.ToString(); } internal static int MakePointerIdForTouch(int deviceId, int touchId) { unchecked { return (deviceId << 24) + touchId; } } ////TODO: adder pressure and tile support (probably add after 1.0; probably should have separate actions) /* /// /// If supported by the input device, this is the pressure level of the pointer contact. This is generally /// only supported by devices as well as by s on phones. If not /// supported, this will be 1. /// /// public float pressure { get; set; } /// /// If the pointer input is coming from a , this is pen's . /// public Vector2 tilt { get; set; } */ } /// /// General type of pointer that generated a pointer event. /// public enum UIPointerType { None, /// /// A or or other general . /// MouseOrPen, /// /// A . /// Touch, /// /// A . /// Tracked, } /// /// Determine how the UI behaves in the presence of multiple pointer devices. /// /// /// While running, an application may, for example, have both a and a device /// and both may end up getting bound to the actions of and thus both may route /// input into the UI. When this happens, the pointer behavior decides how the UI input module resolves the ambiguity. /// public enum UIPointerBehavior { /// /// Any input that isn't or input is /// treated as a single unified pointer. /// /// This is the default behavior based on the expectation that mice and pens will generally drive a single on-screen /// cursor whereas touch and tracked devices have an inherent ability to generate multiple pointers. /// /// Note that when input from touch or tracked devices is received, the combined pointer for mice and pens (if it exists) /// will be removed. If it was over UI objects, IPointerExitHandlers will be invoked. /// SingleMouseOrPenButMultiTouchAndTrack, /// /// All input is unified to a single pointer. This means that all input from all pointing devices (, /// , , and ) is routed into a single pointer /// instance. There is only one position on screen which can be controlled from any of these devices. /// SingleUnifiedPointer, /// /// Any pointing device, whether it's , , , /// or input, is treated as its own independent pointer and arbitrary many /// such pointers can be active at any one time. /// AllPointersAsIs, } } #endif