Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 125c206

Browse files
committed
fix console performance
1 parent 9aa9a01 commit 125c206

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

ModLoader/ConsoleGUI.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,27 @@ public string Logs
4545
{
4646

4747
this._logs.text += value;
48-
float newHeight = this._consoleStyle.CalcHeight(this._logs, this._consoleRect.width);
49-
if (newHeight > this._consoleHeightRect.height)
48+
if (this._isVisible)
5049
{
51-
this._consoleHeightRect.height = newHeight;
52-
}
53-
54-
if (this._activeTab == 0 && this._scrollConsole.y > this._consoleRect.height * 0.6)
55-
{
56-
57-
this._scrollConsole.y = this._consoleHeightRect.height;
50+
this.setConsoleHeight();
5851
}
5952
}
6053
}
54+
55+
private void setConsoleHeight()
56+
{
57+
float newHeight = this._consoleStyle.CalcHeight(this._logs, this._consoleRect.width);
58+
if (newHeight > this._consoleHeightRect.height)
59+
{
60+
this._consoleHeightRect.height = newHeight;
61+
}
62+
63+
if (this._activeTab == 0 && this._scrollConsole.y > this._consoleRect.height * 0.6)
64+
{
65+
66+
this._scrollConsole.y = this._consoleHeightRect.height;
67+
}
68+
}
6169
/*
6270
private GUIContent _sceneGameObjects;
6371
public GameObject[] SceneGameObjects
@@ -167,6 +175,10 @@ private void Update()
167175
if (Input.GetKeyDown(KeyCode.F1))
168176
{
169177
this._isVisible = !this._isVisible;
178+
if (this._isVisible)
179+
{
180+
this.setConsoleHeight();
181+
}
170182
}
171183
}
172184

0 commit comments

Comments
 (0)