forked from Shardstone/trail-into-darkness
added full characte creation support
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -12,6 +13,8 @@ namespace Jovian.InGameLogging.UI {
|
||||
IGameLogStore store;
|
||||
LogChannel? channelFilter;
|
||||
bool autoScroll = true;
|
||||
bool scrollingToBottom;
|
||||
Coroutine scrollCoroutine;
|
||||
|
||||
readonly List<LogEntryView> activeEntries = new();
|
||||
readonly Stack<LogEntryView> pool = new();
|
||||
@@ -76,11 +79,27 @@ namespace Jovian.InGameLogging.UI {
|
||||
activeEntries.Add(view);
|
||||
|
||||
if(autoScroll) {
|
||||
Canvas.ForceUpdateCanvases();
|
||||
scrollRect.verticalNormalizedPosition = 0f;
|
||||
RequestScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestScrollToBottom() {
|
||||
if(scrollCoroutine != null) {
|
||||
StopCoroutine(scrollCoroutine);
|
||||
}
|
||||
scrollCoroutine = StartCoroutine(ScrollToBottomRoutine());
|
||||
}
|
||||
|
||||
IEnumerator ScrollToBottomRoutine() {
|
||||
scrollingToBottom = true;
|
||||
yield return null;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(content);
|
||||
scrollRect.verticalNormalizedPosition = 0f;
|
||||
yield return null;
|
||||
scrollingToBottom = false;
|
||||
scrollCoroutine = null;
|
||||
}
|
||||
|
||||
void HandleCleared() {
|
||||
for(int i = activeEntries.Count - 1; i >= 0; i--) {
|
||||
ReturnToPool(activeEntries[i]);
|
||||
@@ -104,12 +123,14 @@ namespace Jovian.InGameLogging.UI {
|
||||
}
|
||||
|
||||
if(autoScroll) {
|
||||
Canvas.ForceUpdateCanvases();
|
||||
scrollRect.verticalNormalizedPosition = 0f;
|
||||
RequestScrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void HandleScrollChanged(Vector2 position) {
|
||||
if(scrollingToBottom) {
|
||||
return;
|
||||
}
|
||||
autoScroll = position.y <= 0.01f;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user