Down button to make going to latest message easier

This commit is contained in:
2025-08-20 17:57:13 -07:00
parent 46ebca303e
commit cc5fef110f
8 changed files with 630 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ public class ChatroomMenu : MonoBehaviour
private Coroutine statusRoutine;
private Coroutine refreshLoopRoutine;
private bool shouldScrollToBottom = true;
public Button downButton;
void Start()
{
@@ -34,6 +35,7 @@ public class ChatroomMenu : MonoBehaviour
}
backButton.onClick.AddListener(async () => await SceneManager.LoadSceneAsync("MainMenu"));
sendButton.onClick.AddListener(async () => await HandleMessageSubmit());
downButton.onClick.AddListener(() => StartCoroutine(ScrollToBottom()));
messageInputField.textComponent.textWrappingMode = TextWrappingModes.Normal;
messageInputField.onSubmit.AddListener(async (_) => await HandleMessageSubmit());
refreshLoopRoutine = StartCoroutine(Loop());
@@ -122,6 +124,13 @@ public class ChatroomMenu : MonoBehaviour
statusRoutine = StartCoroutine(StatusRoutine());
}
void Update()
{
var max = content.GetComponent<RectTransform>().sizeDelta.y;
var current = content.transform.localPosition.y;
downButton.gameObject.SetActive(Mathf.Abs(max - current) > 0.1f * max);
}
IEnumerator StatusRoutine()
{
statusText.gameObject.SetActive(true);