1
This commit is contained in:
@@ -9,7 +9,7 @@ using TMPro;
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
#if UNITY_EDITOR && UNITY_2021_1_OR_NEWER
|
||||
#if UNITY_EDITOR
|
||||
using Screen = UnityEngine.Device.Screen; // To support Device Simulator on Unity 2021.1+
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace IngameDebugConsole
|
||||
{
|
||||
public static DebugLogManager Instance { get; private set; }
|
||||
|
||||
#pragma warning disable 0649
|
||||
[Header( "Properties" )]
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
@@ -325,7 +324,6 @@ namespace IngameDebugConsole
|
||||
// Recycled list view to handle the log items efficiently
|
||||
[SerializeField]
|
||||
private DebugLogRecycledListView recycledListView;
|
||||
#pragma warning restore 0649
|
||||
|
||||
private bool isLogWindowVisible = true;
|
||||
public bool IsLogWindowVisible { get { return isLogWindowVisible; } }
|
||||
@@ -885,8 +883,6 @@ namespace IngameDebugConsole
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recycledListView.OnViewportWidthChanged();
|
||||
}
|
||||
|
||||
// If SnapToBottom is enabled, force the scrollbar to the bottom
|
||||
@@ -950,11 +946,8 @@ namespace IngameDebugConsole
|
||||
|
||||
if( screenDimensionsChanged )
|
||||
{
|
||||
// Update the recycled list view
|
||||
if( isLogWindowVisible )
|
||||
recycledListView.OnViewportHeightChanged();
|
||||
else
|
||||
popupManager.UpdatePosition( true );
|
||||
if (!isLogWindowVisible)
|
||||
popupManager.UpdatePosition(true);
|
||||
|
||||
#if UNITY_EDITOR || UNITY_ANDROID || UNITY_IOS
|
||||
CheckScreenCutout();
|
||||
@@ -1583,12 +1576,46 @@ namespace IngameDebugConsole
|
||||
commandInputFieldAutoCompletedNow = false;
|
||||
}
|
||||
|
||||
// Command input field has lost focus
|
||||
private void OnEndEditCommand( string command )
|
||||
{
|
||||
if( commandSuggestionsContainer.gameObject.activeSelf )
|
||||
commandSuggestionsContainer.gameObject.SetActive( false );
|
||||
}
|
||||
// Command input field has lost focus
|
||||
private void OnEndEditCommand(string command)
|
||||
{
|
||||
if (!commandSuggestionsContainer.gameObject.activeSelf)
|
||||
return;
|
||||
|
||||
// Check if any command suggestion is clicked
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
if (visibleCommandSuggestionInstances > 0 && Pointer.current != null && Pointer.current.press.wasPressedThisFrame)
|
||||
#else
|
||||
if (visibleCommandSuggestionInstances > 0 && Input.GetMouseButtonDown(0))
|
||||
#endif
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
||||
Vector2 pointerPosition = Pointer.current.position.ReadValue();
|
||||
#else
|
||||
Vector2 pointerPosition = Input.mousePosition;
|
||||
#endif
|
||||
|
||||
Canvas canvas = commandInputField.textComponent.canvas;
|
||||
Camera canvasCamera = (canvas.renderMode == RenderMode.ScreenSpaceOverlay || (canvas.renderMode == RenderMode.ScreenSpaceCamera && canvas.worldCamera == null)) ? null : (canvas.worldCamera != null) ? canvas.worldCamera : Camera.main;
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(commandSuggestionsContainer, pointerPosition, canvasCamera) && RectTransformUtility.ScreenPointToLocalPointInRectangle(commandSuggestionsContainer, pointerPosition, canvasCamera, out Vector2 localPoint))
|
||||
{
|
||||
/// <see cref="commandSuggestionInstances"/> have their Pivot Y set to 1 so we need localPoint to have the same pivot value.
|
||||
localPoint.y -= commandSuggestionsContainer.rect.height;
|
||||
|
||||
for (int i = 0; i < visibleCommandSuggestionInstances; i++)
|
||||
{
|
||||
if (localPoint.y >= commandSuggestionInstances[i].rectTransform.anchoredPosition.y - commandSuggestionInstances[i].rectTransform.sizeDelta.y * commandSuggestionInstances[i].rectTransform.pivot.y)
|
||||
{
|
||||
commandInputField.text = matchingCommandSuggestions[i].command + ((matchingCommandSuggestions[i].parameters.Length > 0) ? " " : null);
|
||||
StartCoroutine(ActivateCommandInputFieldCoroutine());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandSuggestionsContainer.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Debug window is being resized,
|
||||
// Set the sizeDelta property of the window accordingly while
|
||||
@@ -1643,9 +1670,6 @@ namespace IngameDebugConsole
|
||||
anchorMin.y = Mathf.Clamp01( localPoint.y / canvasSize.y );
|
||||
|
||||
logWindowTR.anchorMin = anchorMin;
|
||||
|
||||
// Update the recycled list view
|
||||
recycledListView.OnViewportHeightChanged();
|
||||
}
|
||||
|
||||
// Determine the filtered list of debug entries to show on screen
|
||||
@@ -1831,17 +1855,22 @@ namespace IngameDebugConsole
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL
|
||||
private IEnumerator ActivateCommandInputFieldCoroutine()
|
||||
{
|
||||
// Waiting 1 frame before activating commandInputField ensures that the toggleKey isn't captured by it
|
||||
yield return null;
|
||||
commandInputField.ActivateInputField();
|
||||
private IEnumerator ActivateCommandInputFieldCoroutine()
|
||||
{
|
||||
yield return null;
|
||||
|
||||
yield return null;
|
||||
commandInputField.MoveTextEnd( false );
|
||||
}
|
||||
#endif
|
||||
/// Don't select the text during this automated activation of <see cref="TMP_InputField"/> because it's distracting.
|
||||
bool onFocusSelectAll = commandInputField.onFocusSelectAll;
|
||||
commandInputField.onFocusSelectAll = false;
|
||||
|
||||
commandInputField.ActivateInputField();
|
||||
|
||||
/// Wait for <see cref="TMP_InputField.LateUpdate"/> because input field's activation is handled there.
|
||||
yield return null;
|
||||
|
||||
commandInputField.MoveTextEnd(false);
|
||||
commandInputField.onFocusSelectAll = onFocusSelectAll;
|
||||
}
|
||||
|
||||
// Pool an unused log item
|
||||
internal void PoolLogItem( DebugLogItem logItem )
|
||||
|
||||
Reference in New Issue
Block a user