Files
Dec2017-Script-Dump/UnityEngine.UI/EventSystems/TouchInputModule.cs
T
2026-06-04 11:42:34 +02:00

271 lines
8.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.Serialization;
namespace UnityEngine.EventSystems
{
// Token: 0x0200002E RID: 46
[Obsolete("TouchInputModule is no longer required as Touch input is now handled in StandaloneInputModule.")]
[AddComponentMenu("Event/Touch Input Module")]
public class TouchInputModule : PointerInputModule
{
// Token: 0x0600012E RID: 302 RVA: 0x00005ABF File Offset: 0x00003EBF
protected TouchInputModule()
{
}
// Token: 0x1700004F RID: 79
// (get) Token: 0x0600012F RID: 303 RVA: 0x00005AC8 File Offset: 0x00003EC8
// (set) Token: 0x06000130 RID: 304 RVA: 0x00005AE3 File Offset: 0x00003EE3
[Obsolete("allowActivationOnStandalone has been deprecated. Use forceModuleActive instead (UnityUpgradable) -> forceModuleActive")]
public bool allowActivationOnStandalone
{
get
{
return this.m_ForceModuleActive;
}
set
{
this.m_ForceModuleActive = value;
}
}
// Token: 0x17000050 RID: 80
// (get) Token: 0x06000131 RID: 305 RVA: 0x00005AF0 File Offset: 0x00003EF0
// (set) Token: 0x06000132 RID: 306 RVA: 0x00005B0B File Offset: 0x00003F0B
public bool forceModuleActive
{
get
{
return this.m_ForceModuleActive;
}
set
{
this.m_ForceModuleActive = value;
}
}
// Token: 0x06000133 RID: 307 RVA: 0x00005B15 File Offset: 0x00003F15
public override void UpdateModule()
{
this.m_LastMousePosition = this.m_MousePosition;
this.m_MousePosition = base.input.mousePosition;
}
// Token: 0x06000134 RID: 308 RVA: 0x00005B38 File Offset: 0x00003F38
public override bool IsModuleSupported()
{
return this.forceModuleActive || base.input.touchSupported;
}
// Token: 0x06000135 RID: 309 RVA: 0x00005B68 File Offset: 0x00003F68
public override bool ShouldActivateModule()
{
bool flag;
if (!base.ShouldActivateModule())
{
flag = false;
}
else if (this.m_ForceModuleActive)
{
flag = true;
}
else if (this.UseFakeInput())
{
bool flag2 = base.input.GetMouseButtonDown(0);
flag2 |= (this.m_MousePosition - this.m_LastMousePosition).sqrMagnitude > 0f;
flag = flag2;
}
else
{
flag = base.input.touchCount > 0;
}
return flag;
}
// Token: 0x06000136 RID: 310 RVA: 0x00005C00 File Offset: 0x00004000
private bool UseFakeInput()
{
return !base.input.touchSupported;
}
// Token: 0x06000137 RID: 311 RVA: 0x00005C23 File Offset: 0x00004023
public override void Process()
{
if (this.UseFakeInput())
{
this.FakeTouches();
}
else
{
this.ProcessTouchEvents();
}
}
// Token: 0x06000138 RID: 312 RVA: 0x00005C44 File Offset: 0x00004044
private void FakeTouches()
{
PointerInputModule.MouseState mousePointerEventData = this.GetMousePointerEventData(0);
PointerInputModule.MouseButtonEventData eventData = mousePointerEventData.GetButtonState(PointerEventData.InputButton.Left).eventData;
if (eventData.PressedThisFrame())
{
eventData.buttonData.delta = Vector2.zero;
}
this.ProcessTouchPress(eventData.buttonData, eventData.PressedThisFrame(), eventData.ReleasedThisFrame());
if (base.input.GetMouseButton(0))
{
this.ProcessMove(eventData.buttonData);
this.ProcessDrag(eventData.buttonData);
}
}
// Token: 0x06000139 RID: 313 RVA: 0x00005CC8 File Offset: 0x000040C8
private void ProcessTouchEvents()
{
for (int i = 0; i < base.input.touchCount; i++)
{
Touch touch = base.input.GetTouch(i);
if (touch.type != TouchType.Indirect)
{
bool flag;
bool flag2;
PointerEventData touchPointerEventData = base.GetTouchPointerEventData(touch, out flag, out flag2);
this.ProcessTouchPress(touchPointerEventData, flag, flag2);
if (!flag2)
{
this.ProcessMove(touchPointerEventData);
this.ProcessDrag(touchPointerEventData);
}
else
{
base.RemovePointerData(touchPointerEventData);
}
}
}
}
// Token: 0x0600013A RID: 314 RVA: 0x00005D50 File Offset: 0x00004150
protected void ProcessTouchPress(PointerEventData pointerEvent, bool pressed, bool released)
{
GameObject gameObject = pointerEvent.pointerCurrentRaycast.gameObject;
if (pressed)
{
pointerEvent.eligibleForClick = true;
pointerEvent.delta = Vector2.zero;
pointerEvent.dragging = false;
pointerEvent.useDragThreshold = true;
pointerEvent.pressPosition = pointerEvent.position;
pointerEvent.pointerPressRaycast = pointerEvent.pointerCurrentRaycast;
base.DeselectIfSelectionChanged(gameObject, pointerEvent);
if (pointerEvent.pointerEnter != gameObject)
{
base.HandlePointerExitAndEnter(pointerEvent, gameObject);
pointerEvent.pointerEnter = gameObject;
}
GameObject gameObject2 = ExecuteEvents.ExecuteHierarchy<IPointerDownHandler>(gameObject, pointerEvent, ExecuteEvents.pointerDownHandler);
if (gameObject2 == null)
{
gameObject2 = ExecuteEvents.GetEventHandler<IPointerClickHandler>(gameObject);
}
float unscaledTime = Time.unscaledTime;
if (gameObject2 == pointerEvent.lastPress)
{
float num = unscaledTime - pointerEvent.clickTime;
if (num < 0.3f)
{
pointerEvent.clickCount++;
}
else
{
pointerEvent.clickCount = 1;
}
pointerEvent.clickTime = unscaledTime;
}
else
{
pointerEvent.clickCount = 1;
}
pointerEvent.pointerPress = gameObject2;
pointerEvent.rawPointerPress = gameObject;
pointerEvent.clickTime = unscaledTime;
pointerEvent.pointerDrag = ExecuteEvents.GetEventHandler<IDragHandler>(gameObject);
if (pointerEvent.pointerDrag != null)
{
ExecuteEvents.Execute<IInitializePotentialDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.initializePotentialDrag);
}
}
if (released)
{
ExecuteEvents.Execute<IPointerUpHandler>(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerUpHandler);
GameObject eventHandler = ExecuteEvents.GetEventHandler<IPointerClickHandler>(gameObject);
if (pointerEvent.pointerPress == eventHandler && pointerEvent.eligibleForClick)
{
ExecuteEvents.Execute<IPointerClickHandler>(pointerEvent.pointerPress, pointerEvent, ExecuteEvents.pointerClickHandler);
}
else if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
{
ExecuteEvents.ExecuteHierarchy<IDropHandler>(gameObject, pointerEvent, ExecuteEvents.dropHandler);
}
pointerEvent.eligibleForClick = false;
pointerEvent.pointerPress = null;
pointerEvent.rawPointerPress = null;
if (pointerEvent.pointerDrag != null && pointerEvent.dragging)
{
ExecuteEvents.Execute<IEndDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
}
pointerEvent.dragging = false;
pointerEvent.pointerDrag = null;
if (pointerEvent.pointerDrag != null)
{
ExecuteEvents.Execute<IEndDragHandler>(pointerEvent.pointerDrag, pointerEvent, ExecuteEvents.endDragHandler);
}
pointerEvent.pointerDrag = null;
ExecuteEvents.ExecuteHierarchy<IPointerExitHandler>(pointerEvent.pointerEnter, pointerEvent, ExecuteEvents.pointerExitHandler);
pointerEvent.pointerEnter = null;
}
}
// Token: 0x0600013B RID: 315 RVA: 0x00005FB0 File Offset: 0x000043B0
public override void DeactivateModule()
{
base.DeactivateModule();
base.ClearSelection();
}
// Token: 0x0600013C RID: 316 RVA: 0x00005FC0 File Offset: 0x000043C0
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine((!this.UseFakeInput()) ? "Input: Touch" : "Input: Faked");
if (this.UseFakeInput())
{
PointerEventData lastPointerEventData = base.GetLastPointerEventData(-1);
if (lastPointerEventData != null)
{
stringBuilder.AppendLine(lastPointerEventData.ToString());
}
}
else
{
foreach (KeyValuePair<int, PointerEventData> keyValuePair in this.m_PointerData)
{
stringBuilder.AppendLine(keyValuePair.ToString());
}
}
return stringBuilder.ToString();
}
// Token: 0x0400009E RID: 158
private Vector2 m_LastMousePosition;
// Token: 0x0400009F RID: 159
private Vector2 m_MousePosition;
// Token: 0x040000A0 RID: 160
[SerializeField]
[FormerlySerializedAs("m_AllowActivationOnStandalone")]
private bool m_ForceModuleActive;
}
}