UI update 02
This commit is contained in:
@@ -44,6 +44,7 @@ public class UI_Player : MonoBehaviour
|
||||
|
||||
private readonly List<GameObject> spawnedInfoEntries = new List<GameObject>();
|
||||
private Color defaultInfoColor = Color.black;
|
||||
private Coroutine forceRefreshUiRoutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -54,12 +55,20 @@ public class UI_Player : MonoBehaviour
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
BindQuitButton();
|
||||
DisableBlockingBackgroundRaycasts();
|
||||
RefreshRksUi();
|
||||
RestartForceRefreshUiRoutine();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
PlayerRksService.OnRksChanged -= HandleRksChanged;
|
||||
if (forceRefreshUiRoutine != null)
|
||||
{
|
||||
StopCoroutine(forceRefreshUiRoutine);
|
||||
forceRefreshUiRoutine = null;
|
||||
}
|
||||
if (quitButton != null)
|
||||
{
|
||||
quitButton.onClick.RemoveListener(ClosePanel);
|
||||
@@ -77,11 +86,78 @@ public class UI_Player : MonoBehaviour
|
||||
quitButton.onClick.AddListener(ClosePanel);
|
||||
}
|
||||
|
||||
private void DisableBlockingBackgroundRaycasts()
|
||||
{
|
||||
Image[] images = GetComponentsInChildren<Image>(true);
|
||||
for (int i = 0; i < images.Length; i++)
|
||||
{
|
||||
Image image = images[i];
|
||||
if (image == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string name = image.gameObject.name;
|
||||
if (string.Equals(name, "btmImg (1)", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(name, "btmImg (2)", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(name, "btmImg", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
image.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosePanel()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void RestartForceRefreshUiRoutine()
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (forceRefreshUiRoutine != null)
|
||||
{
|
||||
StopCoroutine(forceRefreshUiRoutine);
|
||||
}
|
||||
|
||||
forceRefreshUiRoutine = StartCoroutine(ForceRefreshUiDeferred());
|
||||
}
|
||||
|
||||
private IEnumerator ForceRefreshUiDeferred()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
yield return null;
|
||||
ForceRefreshUiLayoutNow();
|
||||
}
|
||||
|
||||
forceRefreshUiRoutine = null;
|
||||
}
|
||||
|
||||
private void ForceRefreshUiLayoutNow()
|
||||
{
|
||||
Canvas.ForceUpdateCanvases();
|
||||
|
||||
Transform current = transform;
|
||||
int safety = 0;
|
||||
while (current != null && safety++ < 12)
|
||||
{
|
||||
RectTransform rect = current as RectTransform;
|
||||
if (rect != null)
|
||||
{
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
||||
}
|
||||
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
Canvas.ForceUpdateCanvases();
|
||||
}
|
||||
|
||||
private IEnumerator InitializeAsync()
|
||||
{
|
||||
StoreOwnershipLedger.EnsureInstance().InitializeIfNeeded();
|
||||
|
||||
Reference in New Issue
Block a user