|
11 | 11 | using UnityExplorer.Core.Input;
|
12 | 12 | using UnityExplorer.UI.Panels;
|
13 | 13 | using UnityExplorer.UI.Widgets.AutoComplete;
|
| 14 | +using System.Reflection; |
14 | 15 |
|
15 | 16 | namespace UnityExplorer.UI.CSConsole
|
16 | 17 | {
|
@@ -328,15 +329,28 @@ private static void SetCaretPosition(int caretPosition)
|
328 | 329 | RuntimeProvider.Instance.StartCoroutine(SetAutocompleteCaretCoro(caretPosition));
|
329 | 330 | }
|
330 | 331 |
|
| 332 | + internal static PropertyInfo SelectionGuardProperty => selectionGuardPropInfo ?? GetSelectionGuardPropInfo(); |
| 333 | + |
| 334 | + private static PropertyInfo GetSelectionGuardPropInfo() |
| 335 | + { |
| 336 | + selectionGuardPropInfo = typeof(EventSystem).GetProperty("m_SelectionGuard"); |
| 337 | + if (selectionGuardPropInfo == null) |
| 338 | + selectionGuardPropInfo = typeof(EventSystem).GetProperty("m_selectionGuard"); |
| 339 | + return selectionGuardPropInfo; |
| 340 | + } |
| 341 | + |
| 342 | + private static PropertyInfo selectionGuardPropInfo; |
| 343 | + |
331 | 344 | private static IEnumerator SetAutocompleteCaretCoro(int caretPosition)
|
332 | 345 | {
|
333 | 346 | var color = Input.Component.selectionColor;
|
334 | 347 | color.a = 0f;
|
335 | 348 | Input.Component.selectionColor = color;
|
336 |
| - EventSystem.current.SetSelectedGameObject(null, null); |
| 349 | + try { EventSystem.current.SetSelectedGameObject(null, null); } catch { } |
337 | 350 | yield return null;
|
338 | 351 |
|
339 |
| - EventSystem.current.SetSelectedGameObject(Input.UIRoot, null); |
| 352 | + try { SelectionGuardProperty.SetValue(EventSystem.current, false, null); } catch { } |
| 353 | + try { EventSystem.current.SetSelectedGameObject(Input.UIRoot, null); } catch { } |
340 | 354 | Input.Component.Select();
|
341 | 355 | yield return null;
|
342 | 356 |
|
|
0 commit comments