Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine.EventSystems;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Pool;

namespace UnityEngine.InputSystem.UI
{
Expand Down Expand Up @@ -78,24 +79,63 @@ public ExtendedPointerEventData(EventSystem eventSystem)

public override string ToString()
{
var stringBuilder = new StringBuilder();
stringBuilder.Append(base.ToString());
stringBuilder.AppendLine("button: " + button); // Defined in PointerEventData but PointerEventData.ToString() does not include it.
stringBuilder.AppendLine("clickTime: " + clickTime); // Same here.
stringBuilder.AppendLine("clickCount: " + clickCount); // Same here.
stringBuilder.AppendLine("device: " + device);
stringBuilder.AppendLine("pointerType: " + pointerType);
stringBuilder.AppendLine("touchId: " + touchId);
stringBuilder.AppendLine("pressPosition: " + pressPosition);
stringBuilder.AppendLine("trackedDevicePosition: " + trackedDevicePosition);
stringBuilder.AppendLine("trackedDeviceOrientation: " + trackedDeviceOrientation);
stringBuilder.AppendLine("pressure" + pressure);
stringBuilder.AppendLine("radius: " + radius);
stringBuilder.AppendLine("azimuthAngle: " + azimuthAngle);
stringBuilder.AppendLine("altitudeAngle: " + altitudeAngle);
stringBuilder.AppendLine("twist: " + twist);
stringBuilder.AppendLine("displayIndex: " + displayIndex);
return stringBuilder.ToString();
var stringBuilder = GenericPool<StringBuilder>.Get();
try
{
stringBuilder.Clear();
stringBuilder.Append(base.ToString());
stringBuilder.Append("button: "); // Defined in PointerEventData but PointerEventData.ToString() does not include it.
stringBuilder.Append(button);
stringBuilder.AppendLine();
stringBuilder.Append("clickTime: "); // Same here.
stringBuilder.Append(clickTime);
stringBuilder.AppendLine();
stringBuilder.Append("clickCount: "); // Same here.
stringBuilder.Append(clickCount);
stringBuilder.AppendLine();
stringBuilder.Append("device: ");
stringBuilder.Append(device);
stringBuilder.AppendLine();
stringBuilder.Append("pointerType: ");
stringBuilder.Append(pointerType);
stringBuilder.AppendLine();
stringBuilder.Append("touchId: ");
stringBuilder.Append(touchId);
stringBuilder.AppendLine();
stringBuilder.Append("pressPosition: ");
stringBuilder.Append(pressPosition);
stringBuilder.AppendLine();
stringBuilder.Append("trackedDevicePosition: ");
stringBuilder.Append(trackedDevicePosition);
stringBuilder.AppendLine();
stringBuilder.Append("trackedDeviceOrientation: ");
stringBuilder.Append(trackedDeviceOrientation);
stringBuilder.AppendLine();
stringBuilder.Append("pressure: ");
stringBuilder.Append(pressure);
stringBuilder.AppendLine();
stringBuilder.Append("radius: ");
stringBuilder.Append(radius);
stringBuilder.AppendLine();
stringBuilder.Append("azimuthAngle: ");
stringBuilder.Append(azimuthAngle);
stringBuilder.AppendLine();
stringBuilder.Append("altitudeAngle: ");
stringBuilder.Append(altitudeAngle);
stringBuilder.AppendLine();
stringBuilder.Append("twist: ");
stringBuilder.Append(twist);
stringBuilder.AppendLine();
stringBuilder.Append("displayIndex: ");
stringBuilder.Append(displayIndex);
stringBuilder.AppendLine();
return stringBuilder.ToString();
}
finally
{
stringBuilder.Clear();
GenericPool<StringBuilder>.Release(stringBuilder);
}
}

internal static int MakePointerIdForTouch(int deviceId, int touchId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#if PACKAGE_DOCS_GENERATION || UNITY_INPUT_SYSTEM_ENABLE_UI
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Pool;
using UnityEngine.Serialization;
using UnityEngine.UI;
////FIXME: The UI is currently not reacting to pointers until they are moved after the UI module has been enabled. What needs to
Expand All @@ -27,8 +29,6 @@
////TODO: add ability to query which device was last used with any of the actions
////REVIEW: also give access to the last/current UI event?

////TODO: ToString() method a la PointerInputModule

namespace UnityEngine.InputSystem.UI
{
/// <summary>
Expand Down Expand Up @@ -2432,6 +2432,40 @@ public override int ConvertUIToolkitPointerId(PointerEventData sourcePointerData
: base.ConvertUIToolkitPointerId(sourcePointerData);
}

public override string ToString()
{
var sb = GenericPool<StringBuilder>.Get();
try
{
sb.Clear();
sb.Append("<b>Pointer Input Module of type: </b>");
sb.Append(GetType());
sb.AppendLine();
sb.AppendLine();

if (m_PointerStates.length == 0)
sb.AppendLine("No active pointers.");

for (var i = 0; i < m_PointerStates.length; ++i)
{
var eventData = m_PointerStates[i].eventData;
if (eventData == null)
continue;
sb.Append("<b>Pointer:</b> ");
sb.Append(m_PointerIds[i]);
sb.AppendLine();
sb.AppendLine(eventData.ToString());
}

return sb.ToString();
}
finally
{
sb.Clear();
GenericPool<StringBuilder>.Release(sb);
}
}

#if UNITY_INPUT_SYSTEM_INPUT_MODULE_SCROLL_DELTA
const float kSmallestScrollDeltaPerTick = 0.00001f;
public override Vector2 ConvertPointerEventScrollDeltaToTicks(Vector2 scrollDelta)
Expand Down
Loading