fix typo mistake in previous version

This commit is contained in:
Sinai 2021-03-23 16:15:16 +11:00
parent d919497e43
commit 31c2debb78
2 changed files with 21 additions and 8 deletions

View File

@ -135,13 +135,11 @@ namespace UnityExplorer.Core.Config
ret.y = float.Parse(split[1], _enCulture);
ret.z = float.Parse(split[2], _enCulture);
ret.w = float.Parse(split[3], _enCulture);
return ret;
}
catch
{
Window_Anchors = DEFAULT_WINDOW_ANCHORS;
return new Vector4(0.25f, 0.1f, 0.78f, 0.95f);
return DefaultWindowAnchors();
}
}
@ -153,7 +151,7 @@ namespace UnityExplorer.Core.Config
return string.Format(_enCulture, "{0},{1},{2},{3}", new object[]
{
rect.anchorMin.x,
rect.anchorMax.y,
rect.anchorMin.y,
rect.anchorMax.x,
rect.anchorMax.y
});
@ -163,5 +161,11 @@ namespace UnityExplorer.Core.Config
return DEFAULT_WINDOW_ANCHORS;
}
}
internal static Vector4 DefaultWindowAnchors()
{
Instance.Window_Anchors = DEFAULT_WINDOW_ANCHORS;
return new Vector4(0.25f, 0.1f, 0.78f, 0.95f);
}
}
}

View File

@ -151,11 +151,14 @@ namespace UnityExplorer.UI.Main
MainPanel = UIFactory.CreatePanel(UIManager.CanvasRoot, "MainMenu", out GameObject content);
RectTransform panelRect = MainPanel.GetComponent<RectTransform>();
//panelRect.anchorMin = new Vector2(0.25f, 0.1f);
//panelRect.anchorMax = new Vector2(0.78f, 0.95f);
var anchors = ExplorerConfig.Instance.GetWindowAnchorsVector();
panelRect.anchorMin = new Vector2(anchors.x, anchors.y);
panelRect.anchorMax = new Vector2(anchors.z, anchors.w);
SetPanelAnchors(panelRect, anchors);
if (panelRect.rect.width < 400 || panelRect.rect.height < 400)
{
anchors = ExplorerConfig.DefaultWindowAnchors();
SetPanelAnchors(panelRect, anchors);
}
MainPanel.AddComponent<Mask>();
@ -168,6 +171,12 @@ namespace UnityExplorer.UI.Main
new DebugConsole(content);
}
private void SetPanelAnchors(RectTransform panelRect, Vector4 anchors)
{
panelRect.anchorMin = new Vector2(anchors.x, anchors.y);
panelRect.anchorMax = new Vector2(anchors.z, anchors.w);
}
private void ConstructTitleBar(GameObject content)
{
// Core title bar holder