Fix an issue with the requests adding up each time you send a message
This commit is contained in:
@@ -18,6 +18,7 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
public GameObject sampleObject;
|
public GameObject sampleObject;
|
||||||
private string statusMessage;
|
private string statusMessage;
|
||||||
private Coroutine statusRoutine;
|
private Coroutine statusRoutine;
|
||||||
|
private Coroutine refreshLoopRoutine;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -25,12 +26,7 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
sendButton.onClick.AddListener(async () => await HandleMessageSubmit());
|
sendButton.onClick.AddListener(async () => await HandleMessageSubmit());
|
||||||
messageInputField.textComponent.textWrappingMode = TextWrappingModes.Normal;
|
messageInputField.textComponent.textWrappingMode = TextWrappingModes.Normal;
|
||||||
messageInputField.onSubmit.AddListener(async (_) => await HandleMessageSubmit());
|
messageInputField.onSubmit.AddListener(async (_) => await HandleMessageSubmit());
|
||||||
StartCoroutine(Loop());
|
refreshLoopRoutine = StartCoroutine(Loop());
|
||||||
}
|
|
||||||
|
|
||||||
void OnSceneUnloaded()
|
|
||||||
{
|
|
||||||
StopAllCoroutines();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator Loop() {
|
IEnumerator Loop() {
|
||||||
@@ -77,8 +73,8 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
ShowStatus("Authentication error.");
|
ShowStatus("Authentication error.");
|
||||||
break;
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
StopCoroutine(Loop());
|
StopCoroutine(refreshLoopRoutine);
|
||||||
StartCoroutine(Loop());
|
refreshLoopRoutine = StartCoroutine(Loop());
|
||||||
content.transform.localPosition = new Vector2(0f, 0f);
|
content.transform.localPosition = new Vector2(0f, 0f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user