A game about forced loneliness, made by TACStudios
at master 398 lines 14 kB view raw
1namespace UnityEngine.EventSystems 2{ 3 /// <summary> 4 /// Base class that all EventSystem events inherit from. 5 /// </summary> 6 public interface IEventSystemHandler 7 { 8 } 9 10 /// <summary> 11 /// Interface to implement if you wish to receive OnPointerMove callbacks. 12 /// </summary> 13 /// <remarks> 14 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 15 /// </remarks> 16 public interface IPointerMoveHandler : IEventSystemHandler 17 { 18 /// <summary> 19 /// Use this callback to detect pointer move events 20 /// </summary> 21 void OnPointerMove(PointerEventData eventData); 22 } 23 24 /// <summary> 25 /// Interface to implement if you wish to receive OnPointerEnter callbacks. 26 /// </summary> 27 /// <remarks> 28 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 29 /// </remarks> 30 public interface IPointerEnterHandler : IEventSystemHandler 31 { 32 /// <summary> 33 /// Use this callback to detect pointer enter events 34 /// </summary> 35 void OnPointerEnter(PointerEventData eventData); 36 } 37 38 /// <summary> 39 /// Interface to implement if you wish to receive OnPointerExit callbacks. 40 /// </summary> 41 /// <remarks> 42 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 43 /// </remarks> 44 public interface IPointerExitHandler : IEventSystemHandler 45 { 46 /// <summary> 47 /// Use this callback to detect pointer exit events 48 /// </summary> 49 void OnPointerExit(PointerEventData eventData); 50 } 51 52 /// <summary> 53 /// Interface to implement if you wish to receive OnPointerDown callbacks. 54 /// </summary> 55 /// <remarks> 56 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 57 /// </remarks> 58 public interface IPointerDownHandler : IEventSystemHandler 59 { 60 /// <summary> 61 /// Use this callback to detect pointer down events. 62 /// </summary> 63 void OnPointerDown(PointerEventData eventData); 64 } 65 66 /// <summary> 67 /// Interface to implement if you wish to receive OnPointerUp callbacks. 68 /// Note: In order to receive OnPointerUp callbacks, you must also implement the EventSystems.IPointerDownHandler|IPointerDownHandler interface 69 /// </summary> 70 /// <remarks> 71 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 72 /// </remarks> 73 public interface IPointerUpHandler : IEventSystemHandler 74 { 75 /// <summary> 76 /// Use this callback to detect pointer up events. 77 /// </summary> 78 void OnPointerUp(PointerEventData eventData); 79 } 80 81 /// <summary> 82 /// Interface to implement if you wish to receive OnPointerClick callbacks. 83 /// </summary> 84 /// <remarks> 85 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 86 /// </remarks> 87 /// <remarks> 88 /// Use the IPointerClickHandler Interface to handle click input using OnPointerClick callbacks. Ensure an Event System exists in the Scene to allow click detection. For click detection on non-UI GameObjects, ensure a EventSystems.PhysicsRaycaster is attached to the Camera. 89 /// </remarks> 90 /// <example> 91 /// <code> 92 /// <![CDATA[ 93 /// using UnityEngine; 94 /// using UnityEngine.EventSystems; 95 /// 96 /// public class Example : MonoBehaviour, IPointerClickHandler 97 /// { 98 /// //Detect if a click occurs 99 /// public void OnPointerClick(PointerEventData pointerEventData) 100 /// { 101 /// //Output to console the clicked GameObject's name and the following message. You can replace this with your own actions for when clicking the GameObject. 102 /// Debug.Log(name + " Game Object Clicked!"); 103 /// } 104 /// } 105 /// ]]> 106 ///</code> 107 /// </example> 108 public interface IPointerClickHandler : IEventSystemHandler 109 { 110 /// <summary> 111 /// Use this callback to detect clicks. 112 /// </summary> 113 void OnPointerClick(PointerEventData eventData); 114 } 115 116 /// <summary> 117 /// Interface to implement if you wish to receive OnBeginDrag callbacks. 118 /// Note: You need to implement IDragHandler in addition to IBeginDragHandler. 119 /// </summary> 120 /// <remarks> 121 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 122 /// </remarks> 123 public interface IBeginDragHandler : IEventSystemHandler 124 { 125 /// <summary> 126 /// Called by a BaseInputModule before a drag is started. 127 /// </summary> 128 void OnBeginDrag(PointerEventData eventData); 129 } 130 131 /// <summary> 132 /// Interface to implement if you wish to receive OnInitializePotentialDrag callbacks. 133 /// </summary> 134 /// <remarks> 135 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 136 /// </remarks> 137 public interface IInitializePotentialDragHandler : IEventSystemHandler 138 { 139 /// <summary> 140 /// Called by a BaseInputModule when a drag has been found but before it is valid to begin the drag. 141 /// </summary> 142 void OnInitializePotentialDrag(PointerEventData eventData); 143 } 144 145 /// <summary> 146 /// Interface to implement if you wish to receive OnDrag callbacks. 147 /// </summary> 148 /// <remarks> 149 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 150 /// </remarks> 151 /// <example> 152 /// <code> 153 /// <![CDATA[ 154 /// using UnityEngine; 155 /// using UnityEngine.EventSystems; 156 /// using UnityEngine.UI; 157 /// 158 /// [RequireComponent(typeof(Image))] 159 /// public class DragMe : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler 160 /// { 161 /// public bool dragOnSurfaces = true; 162 /// 163 /// private GameObject m_DraggingIcon; 164 /// private RectTransform m_DraggingPlane; 165 /// 166 /// public void OnBeginDrag(PointerEventData eventData) 167 /// { 168 /// var canvas = FindInParents<Canvas>(gameObject); 169 /// if (canvas == null) 170 /// return; 171 /// 172 /// // We have clicked something that can be dragged. 173 /// // What we want to do is create an icon for this. 174 /// m_DraggingIcon = new GameObject("icon"); 175 /// 176 /// m_DraggingIcon.transform.SetParent(canvas.transform, false); 177 /// m_DraggingIcon.transform.SetAsLastSibling(); 178 /// 179 /// var image = m_DraggingIcon.AddComponent<Image>(); 180 /// 181 /// image.sprite = GetComponent<Image>().sprite; 182 /// image.SetNativeSize(); 183 /// 184 /// if (dragOnSurfaces) 185 /// m_DraggingPlane = transform as RectTransform; 186 /// else 187 /// m_DraggingPlane = canvas.transform as RectTransform; 188 /// 189 /// SetDraggedPosition(eventData); 190 /// } 191 /// 192 /// public void OnDrag(PointerEventData data) 193 /// { 194 /// if (m_DraggingIcon != null) 195 /// SetDraggedPosition(data); 196 /// } 197 /// 198 /// private void SetDraggedPosition(PointerEventData data) 199 /// { 200 /// if (dragOnSurfaces && data.pointerEnter != null && data.pointerEnter.transform as RectTransform != null) 201 /// m_DraggingPlane = data.pointerEnter.transform as RectTransform; 202 /// 203 /// var rt = m_DraggingIcon.GetComponent<RectTransform>(); 204 /// Vector3 globalMousePos; 205 /// if (RectTransformUtility.ScreenPointToWorldPointInRectangle(m_DraggingPlane, data.position, data.pressEventCamera, out globalMousePos)) 206 /// { 207 /// rt.position = globalMousePos; 208 /// rt.rotation = m_DraggingPlane.rotation; 209 /// } 210 /// } 211 /// 212 /// public void OnEndDrag(PointerEventData eventData) 213 /// { 214 /// if (m_DraggingIcon != null) 215 /// Destroy(m_DraggingIcon); 216 /// } 217 /// 218 /// static public T FindInParents<T>(GameObject go) where T : Component 219 /// { 220 /// if (go == null) return null; 221 /// var comp = go.GetComponent<T>(); 222 /// 223 /// if (comp != null) 224 /// return comp; 225 /// 226 /// Transform t = go.transform.parent; 227 /// while (t != null && comp == null) 228 /// { 229 /// comp = t.gameObject.GetComponent<T>(); 230 /// t = t.parent; 231 /// } 232 /// return comp; 233 /// } 234 /// } 235 /// ]]> 236 ///</code> 237 /// </example> 238 public interface IDragHandler : IEventSystemHandler 239 { 240 /// <summary> 241 /// When dragging is occurring this will be called every time the cursor is moved. 242 /// </summary> 243 void OnDrag(PointerEventData eventData); 244 } 245 246 /// <summary> 247 /// Interface to implement if you wish to receive OnEndDrag callbacks. 248 /// Note: You need to implement IDragHandler in addition to IEndDragHandler. 249 /// </summary> 250 /// <remarks> 251 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 252 /// </remarks> 253 public interface IEndDragHandler : IEventSystemHandler 254 { 255 /// <summary> 256 /// Called by a BaseInputModule when a drag is ended. 257 /// </summary> 258 void OnEndDrag(PointerEventData eventData); 259 } 260 261 /// <summary> 262 /// Interface to implement if you wish to receive OnDrop callbacks. 263 /// </summary> 264 /// <example> 265 /// <code> 266 /// <![CDATA[ 267 /// using UnityEngine; 268 /// using UnityEngine.EventSystems; 269 /// 270 /// public class DropMe : MonoBehaviour, IDropHandler 271 /// { 272 /// public void OnDrop(PointerEventData data) 273 /// { 274 /// if (data.pointerDrag != null) 275 /// { 276 /// Debug.Log ("Dropped object was: " + data.pointerDrag); 277 /// } 278 /// } 279 /// } 280 /// ]]> 281 ///</code> 282 /// </example> 283 /// <remarks> 284 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 285 /// </remarks> 286 public interface IDropHandler : IEventSystemHandler 287 { 288 /// <summary> 289 /// Called by a BaseInputModule on a target that can accept a drop. 290 /// </summary> 291 void OnDrop(PointerEventData eventData); 292 } 293 294 /// <summary> 295 /// Interface to implement if you wish to receive OnScroll callbacks. 296 /// </summary> 297 /// <remarks> 298 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 299 /// </remarks> 300 public interface IScrollHandler : IEventSystemHandler 301 { 302 /// <summary> 303 /// Use this callback to detect scroll events. 304 /// </summary> 305 void OnScroll(PointerEventData eventData); 306 } 307 308 /// <summary> 309 /// Interface to implement if you wish to receive OnUpdateSelected callbacks. 310 /// </summary> 311 /// <remarks> 312 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 313 /// </remarks> 314 public interface IUpdateSelectedHandler : IEventSystemHandler 315 { 316 /// <summary> 317 /// Called by the EventSystem when the object associated with this EventTrigger is updated. 318 /// </summary> 319 /// <example> 320 /// <code> 321 /// <![CDATA[ 322 /// using UnityEngine; 323 /// using UnityEngine.EventSystems; 324 /// 325 /// public class UpdateSelectedExample : MonoBehaviour, IUpdateSelectedHandler 326 /// { 327 /// public void OnUpdateSelected(BaseEventData data) 328 /// { 329 /// Debug.Log("OnUpdateSelected called."); 330 /// } 331 /// } 332 /// ]]> 333 ///</code> 334 /// </example> 335 void OnUpdateSelected(BaseEventData eventData); 336 } 337 338 /// <summary> 339 /// Interface to implement if you wish to receive OnSelect callbacks. 340 /// </summary> 341 /// <remarks> 342 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 343 /// </remarks> 344 public interface ISelectHandler : IEventSystemHandler 345 { 346 void OnSelect(BaseEventData eventData); 347 } 348 349 /// <summary> 350 /// Interface to implement if you wish to receive OnDeselect callbacks. 351 /// </summary> 352 /// <remarks> 353 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 354 /// </remarks> 355 public interface IDeselectHandler : IEventSystemHandler 356 { 357 /// <summary> 358 /// Called by the EventSystem when a new object is being selected. 359 /// </summary> 360 void OnDeselect(BaseEventData eventData); 361 } 362 363 /// <summary> 364 /// Interface to implement if you wish to receive OnMove callbacks. 365 /// </summary> 366 /// <remarks> 367 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 368 /// </remarks> 369 public interface IMoveHandler : IEventSystemHandler 370 { 371 /// <summary> 372 /// Called by a BaseInputModule when a move event occurs. 373 /// </summary> 374 void OnMove(AxisEventData eventData); 375 } 376 377 /// <summary> 378 /// Interface to implement if you wish to receive OnSubmit callbacks. 379 /// </summary> 380 /// <remarks> 381 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 382 /// </remarks> 383 public interface ISubmitHandler : IEventSystemHandler 384 { 385 void OnSubmit(BaseEventData eventData); 386 } 387 388 /// <summary> 389 /// Interface to implement if you wish to receive OnCancel callbacks. 390 /// </summary> 391 /// <remarks> 392 /// Criteria for this event is implementation dependent. For example see StandAloneInputModule. 393 /// </remarks> 394 public interface ICancelHandler : IEventSystemHandler 395 { 396 void OnCancel(BaseEventData eventData); 397 } 398}