-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatEventHandler.cs
35 lines (32 loc) · 1.06 KB
/
ChatEventHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Example Handler
using UdonSharp;
using UnityEngine;
using UnityEngine.UI;
using VRC.SDKBase;
using VRC.Udon;
using VRC.Udon.Common.Interfaces;
/// <Summary>An example handler for events.</Summary>
public class ChatEventHandler : UdonSharpBehaviour
{
public UdonLogger logger;
private int playerID;
private string newEvent;
public void Handle()
{
// As it stands, hard-code your events in this function.
// This is pretty basic. Once maps and lists exist in Udon, this can be improved.
string[] e = newEvent.Split(',');
Debug.Log("Got an event named " + e[0] + " with payload " + newEvent);
switch (e[0])
{
case "ChatMessage":
string message = characterName + ": " + e[1];
message = message.Replace("|", ",");
logger.Notice(message);
break;
default:
logger.Notice("Got an event named " + e[0] + " but didn't know what to do with it.");
break;
}
}
}