Exemple #1
0
        public static void SendCustomNetworkEventHook(UdonBehaviour behaviour, NetworkEventTarget target, string eventName)
        {
            if (string.IsNullOrEmpty(eventName))
            {
                return;
            }

            if (eventName[0] == '_')
            {
                behaviour.LogError("Did not send custom network event \"" + eventName + "\". Events starting " +
                                   "with an underscore may not be run remotely. "
                                   + VRC.Tools.GetGameObjectPath(behaviour.gameObject));
                return;
            }

            if (target == NetworkEventTarget.All ||
                (target == NetworkEventTarget.Owner && Networking.IsOwner(behaviour.gameObject)))
            {
                behaviour.Log("Sending Network Event! eventName:" + eventName + ", obj:"
                              + VRC.Tools.GetGameObjectPath(behaviour.gameObject));
                behaviour.SendCustomEvent(eventName);
            }
            else
            {
                behaviour.LogWarning("Did not send custom network event " + eventName + " for object at "
                                     + VRC.Tools.GetGameObjectPath(behaviour.gameObject));
            }
        }