From 498fa4ff8514c7b0033ec57d6f4ede482cd49971 Mon Sep 17 00:00:00 2001 From: excitedneon Date: Thu, 11 May 2017 23:15:05 +0300 Subject: [PATCH] Fix the scrolling bug --- Assets/Scenes/TestMap.unity | 7 ++----- Assets/Scripts/Console/DebugConsole.cs | 12 +++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Assets/Scenes/TestMap.unity b/Assets/Scenes/TestMap.unity index ea6f225..fdb2865 100644 --- a/Assets/Scenes/TestMap.unity +++ b/Assets/Scenes/TestMap.unity @@ -1987,8 +1987,7 @@ MonoBehaviour: TextField: {fileID: 1815899005} Visible: 1 RowLength: 80 - MaxLinesUntilCleanup: 30 - LineCountSavedFromCleanup: 15 + LinesRendered: 15 --- !u!4 &1463006272 Transform: m_ObjectHideFlags: 0 @@ -2320,9 +2319,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 'Use the "help" command for a list of commands. - -' + m_Text: --- !u!222 &1815899006 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Console/DebugConsole.cs b/Assets/Scripts/Console/DebugConsole.cs index 6b7aa42..04a7daa 100644 --- a/Assets/Scripts/Console/DebugConsole.cs +++ b/Assets/Scripts/Console/DebugConsole.cs @@ -51,7 +51,7 @@ namespace Cyber.Console { private List Commands = new List(); private int LastCommandIndex = 0; private string LastUnexecutedCommand = ""; - private int ScrollOffset = 1; + private int ScrollOffset = 0; /// /// Creates a new , and sets the 's singleton. @@ -144,10 +144,10 @@ namespace Cyber.Console { private void UpdateTextField() { string NewLog = ""; int LineAmt = Mathf.Min(LinesRendered, Lines.Count); - for (int i = 0; i < LineAmt; i++) { + for (int i = LineAmt; i > 0; i--) { int Index = Lines.Count - (i + ScrollOffset); if (Index >= 0 && Index < Lines.Count) { - NewLog += Lines[i] + "\n"; + NewLog += Lines[Index] + "\n"; } } TextField.text = NewLog; @@ -188,6 +188,8 @@ namespace Cyber.Console { Application.Quit(); }); + Println("Use the \"help\" command for a list of commands."); + // Set an accurate row length (if the panel is set) if (Panel != null && Panel.GetComponent() != null) { CharacterInfo CharInfo; @@ -227,11 +229,11 @@ namespace Cyber.Console { InputField.text = LastUnexecutedCommand; } } - if (Input.GetAxis("Mouse ScrollWheel") > 0 && ScrollOffset + 1 <= Lines.Count) { + if (Input.GetAxis("Mouse ScrollWheel") > 0 && ScrollOffset + 1 < Lines.Count) { ScrollOffset++; UpdateTextField(); } - if (Input.GetAxis("Mouse ScrollWheel") < 0 && ScrollOffset - 1 > 1) { + if (Input.GetAxis("Mouse ScrollWheel") < 0 && ScrollOffset - 1 >= 0) { ScrollOffset--; UpdateTextField(); }