Skip to content

Commit

Permalink
docs: unity general hand event catch
Browse files Browse the repository at this point in the history
  • Loading branch information
mwfarb committed Dec 5, 2024
1 parent a53af12 commit feccc9d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion content/unity/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,18 @@ public class ArenaTestButton : MonoBehaviour
/// </summary>
public static void MessageCallback(string topic, string message)
{
Debug.LogFormat("Message received on topic {0}: {1}", topic, message);
ArenaObjectJson m = JsonConvert.DeserializeObject<ArenaObjectJson>(message);
if (m.action == "clientEvent")
{
// parse some event data and log it
ArenaEventJson evt = JsonConvert.DeserializeObject<ArenaEventJson>(m.data.ToString());
Debug.LogFormat($"Received event '{m.type}' from {m.object_id}, target={evt.Target}");

// log any users who use the hand controller to pull the trigger
if ( m.type != "gripdown") {
Debug.LogFormat($"{m.object_id} pulled the trigger!");
}
}
}

/// <summary>
Expand Down

0 comments on commit feccc9d

Please sign in to comment.