Fix panel draggers on display change

This commit is contained in:
Sinai 2022-01-22 21:44:22 +11:00
parent 91bb58b020
commit 589abe6193
3 changed files with 20 additions and 1 deletions

View File

@ -1,9 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityExplorer.Config;
using UniverseLib;
using UniverseLib.Input;
namespace UnityExplorer.UI
@ -57,6 +59,21 @@ namespace UnityExplorer.UI
}
canvasCamera.targetDisplay = display;
}
RuntimeProvider.Instance.StartCoroutine(FixPanels());
}
private static IEnumerator FixPanels()
{
yield return null;
yield return null;
foreach (var panel in UIManager.UIPanels.Values)
{
panel.EnsureValidSize();
panel.EnsureValidPosition();
panel.Dragger.OnEndResize();
}
}
}
}

View File

@ -146,6 +146,8 @@ namespace UnityExplorer.UI.Panels
Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MinHeight);
}
public void EnsureValidPosition() => EnsureValidPosition(this.Rect);
public static void EnsureValidPosition(RectTransform panel)
{
var pos = panel.localPosition;

View File

@ -45,7 +45,7 @@ namespace UnityExplorer.UI
public static Canvas UICanvas { get; private set; }
internal static GameObject PanelHolder { get; private set; }
private static readonly Dictionary<Panels, UIPanel> UIPanels = new();
internal static readonly Dictionary<Panels, UIPanel> UIPanels = new();
public static RectTransform NavBarRect;
public static GameObject NavbarTabButtonHolder;