Skip to content

Commit efc9c4d

Browse files
author
Unity Technologies
committed
Unity 6000.2.0a1 C# reference source code
1 parent 0a1cdae commit efc9c4d

File tree

79 files changed

+1438
-413
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1438
-413
lines changed

Editor/Mono/ConsoleWindow.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ internal static void UpdateLogStyleFixedHeights()
155155
string m_ConsoleSearchNoResultMsg = "";
156156

157157
ListViewState m_ListView;
158+
bool m_SyncAutoScroll;
158159
string m_ActiveText = "";
159160
StringBuilder m_CopyString;
160161
bool m_DevBuild;
@@ -489,7 +490,7 @@ void UpdateListView()
489490
// We reset the scroll list to auto scrolling whenever the log entry count is modified
490491
m_ListView.rowHeight = newRowHeight;
491492
m_ListView.row = -1;
492-
m_ListView.scrollPos.y = LogEntries.GetCount() * newRowHeight;
493+
SetScrollPosYFromRow(LogEntries.GetCount());
493494
}
494495

495496
bool HasSpaceForExtraButtons()
@@ -535,13 +536,15 @@ internal void OnGUI()
535536

536537
int currCount = LogEntries.GetCount();
537538
bool showSearchNoResultMessage = currCount == 0 && !String.IsNullOrEmpty(m_SearchText);
538-
539+
m_SyncAutoScroll = false;
539540
if (m_ListView.totalRows != currCount)
540541
{
541542
// scroll bar was at the bottom?
542-
if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
543+
var expectedScrollPosY = GetScrollPosY(m_ListView.totalRows);
544+
if (m_ListView.scrollPos.y >= expectedScrollPosY)
543545
{
544-
m_ListView.scrollPos.y = currCount * RowHeight - ms_LVHeight;
546+
m_ListView.scrollPos.y = GetScrollPosY(currCount);
547+
m_SyncAutoScroll = true;
545548
}
546549
}
547550

@@ -555,7 +558,7 @@ internal void OnGUI()
555558
m_ListView.row = -1;
556559

557560
// scroll to bottom
558-
m_ListView.scrollPos.y = LogEntries.GetCount() * RowHeight;
561+
SetScrollPosYFromRow(LogEntries.GetCount());
559562
}
560563

561564
if (HasSpaceForExtraButtons())
@@ -622,7 +625,7 @@ internal void OnGUI()
622625
// Make sure that scrollPos.y is always up to date after restoring last entry
623626
if (m_RestoreLatestSelection)
624627
{
625-
m_ListView.scrollPos.y = scrollPosY;
628+
SetScrollPosY(scrollPosY);
626629
}
627630

628631
if (e.type == EventType.MouseDown && e.button == 0 && el.position.Contains(e.mousePosition))
@@ -635,6 +638,7 @@ internal void OnGUI()
635638
EditorGUIUtility.PingObject(entry.instanceID);
636639
if (e.clickCount == 2)
637640
openSelectedItem = true;
641+
m_SyncAutoScroll = false;
638642
}
639643
else if (e.type == EventType.Repaint)
640644
{
@@ -712,8 +716,11 @@ const bool
712716

713717
if (selectedRow != -1)
714718
{
715-
if (m_ListView.scrollPos.y >= m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight)
716-
m_ListView.scrollPos.y = m_ListView.rowHeight * m_ListView.totalRows - ms_LVHeight - 1;
719+
var expectedScrollPosY = GetScrollPosY(m_ListView.totalRows);
720+
if (m_ListView.scrollPos.y >= expectedScrollPosY)
721+
{
722+
SetScrollPosY(expectedScrollPosY - 1);
723+
}
717724
}
718725

719726
// Make sure the selected entry is up to date
@@ -806,6 +813,28 @@ const bool
806813

807814
if (!ms_ConsoleWindow)
808815
ms_ConsoleWindow = this;
816+
817+
if (m_SyncAutoScroll)
818+
{
819+
// Enforce autoscroll according to any potentially new rows having been added during OnGUI
820+
SetScrollPosYFromRow(m_ListView.totalRows);
821+
}
822+
}
823+
824+
private void SetScrollPosY(float posY)
825+
{
826+
m_ListView.scrollPos.y = posY;
827+
m_SyncAutoScroll = false;
828+
}
829+
830+
private void SetScrollPosYFromRow(int rowIndex)
831+
{
832+
SetScrollPosY(GetScrollPosY(rowIndex));
833+
}
834+
835+
private float GetScrollPosY(int rowIndex)
836+
{
837+
return rowIndex * m_ListView.rowHeight - ms_LVHeight;
809838
}
810839

811840
private void SearchField(Event e)
@@ -1265,7 +1294,7 @@ void RestoreLastActiveEntry()
12651294
ShowConsoleRow(rowIndex);
12661295
m_ListView.selectedItems = new bool[rowIndex + 1];
12671296
m_ListView.selectedItems[rowIndex] = true;
1268-
m_ListView.scrollPos.y = rowIndex * m_ListView.rowHeight;
1297+
SetScrollPosYFromRow(rowIndex);
12691298
}
12701299
else
12711300
{

Editor/Mono/EditorGUI.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,9 @@ internal static bool MightBePrintableKey(Event evt)
886886
return false;
887887
if (evt.keyCode >= KeyCode.JoystickButton0 && evt.keyCode <= KeyCode.Joystick8Button19)
888888
return false;
889-
if (evt.keyCode >= KeyCode.F1 && evt.keyCode <= KeyCode.F15)
889+
if (evt.keyCode >= KeyCode.F1 && evt.keyCode <= KeyCode.F15 ||
890+
// KeyCode.F15 (296) and KeyCode.F16 (670) are not contiguous
891+
evt.keyCode >= KeyCode.F16 && evt.keyCode <= KeyCode.F24)
890892
return false;
891893
switch (evt.keyCode)
892894
{

0 commit comments

Comments
 (0)