Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 589abe6

Browse files
committed
Fix panel draggers on display change
1 parent 91bb58b commit 589abe6

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/UI/DisplayManager.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text;
56
using UnityEngine;
67
using UnityExplorer.Config;
8+
using UniverseLib;
79
using UniverseLib.Input;
810

911
namespace UnityExplorer.UI
@@ -57,6 +59,21 @@ public static void SetDisplay(int display)
5759
}
5860
canvasCamera.targetDisplay = display;
5961
}
62+
63+
RuntimeProvider.Instance.StartCoroutine(FixPanels());
64+
}
65+
66+
private static IEnumerator FixPanels()
67+
{
68+
yield return null;
69+
yield return null;
70+
71+
foreach (var panel in UIManager.UIPanels.Values)
72+
{
73+
panel.EnsureValidSize();
74+
panel.EnsureValidPosition();
75+
panel.Dragger.OnEndResize();
76+
}
6077
}
6178
}
6279
}

src/UI/Panels/UIPanel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public void EnsureValidSize()
146146
Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, MinHeight);
147147
}
148148

149+
public void EnsureValidPosition() => EnsureValidPosition(this.Rect);
150+
149151
public static void EnsureValidPosition(RectTransform panel)
150152
{
151153
var pos = panel.localPosition;

src/UI/UIManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum VerticalAnchor
4545
public static Canvas UICanvas { get; private set; }
4646

4747
internal static GameObject PanelHolder { get; private set; }
48-
private static readonly Dictionary<Panels, UIPanel> UIPanels = new();
48+
internal static readonly Dictionary<Panels, UIPanel> UIPanels = new();
4949

5050
public static RectTransform NavBarRect;
5151
public static GameObject NavbarTabButtonHolder;

0 commit comments

Comments
 (0)