From 2c094427b6e5b30348e0437e6a3dec9cdf27ed5a Mon Sep 17 00:00:00 2001 From: Merlin <36685500+MerlinVR@users.noreply.github.com> Date: Fri, 19 Feb 2021 15:38:12 -0800 Subject: [PATCH 1/2] Add midi event handling --- Assets/UdonSharp/Editor/UdonSharpResolverContext.cs | 5 +++-- Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs b/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs index a5ff54c1..fdea5b8c 100644 --- a/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs +++ b/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs @@ -150,7 +150,6 @@ public bool ReplaceInternalEventName(ref string eventName) { "_onPlayerLeft", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerLeftPlayer") } }, { "_onStationEntered", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onStationEnteredPlayer") } }, { "_onStationExited", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onStationExitedPlayer") } }, -#if UDON_BETA_SDK || true { "_onOwnershipRequest", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onOwnershipRequestRequester"), new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onOwnershipRequestNewOwner") } }, { "_onPlayerTriggerEnter", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerTriggerEnterPlayer") } }, { "_onPlayerTriggerExit", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerTriggerExitPlayer") } }, @@ -160,7 +159,9 @@ public bool ReplaceInternalEventName(ref string eventName) { "_onPlayerCollisionStay", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerCollisionStayPlayer") } }, { "_onPlayerParticleCollision", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerParticleCollisionPlayer") } }, { "_onVideoError", new System.Tuple[] { new System.Tuple(typeof(VRC.SDK3.Components.Video.VideoError), "onVideoErrorVideoError") } }, -#endif + { "_midiNoteOn", new System.Tuple[] { new System.Tuple(typeof(int), "midiNoteOnChannel"), new System.Tuple(typeof(int), "midiNoteOnNumber"), new System.Tuple(typeof(int), "midiNoteOnVelocity") } }, + { "_midiNoteOff", new System.Tuple[] { new System.Tuple(typeof(int), "midiNoteOffChannel"), new System.Tuple(typeof(int), "midiNoteOffNumber"), new System.Tuple(typeof(int), "midiNoteOffVelocity") } }, + { "_midiControlChange", new System.Tuple[] { new System.Tuple(typeof(int), "midiControlChangeChannel"), new System.Tuple(typeof(int), "midiControlChangeNumber"), new System.Tuple(typeof(int), "midiControlChangeValue") } }, }; public System.Tuple[] GetMethodCustomArgs(string methodName) diff --git a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs index 862edb5e..1a6cac80 100644 --- a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs +++ b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs @@ -135,6 +135,9 @@ public virtual void OnPlayerParticleCollision(VRC.SDKBase.VRCPlayerApi player) { #if UDON_BETA_SDK public virtual bool OnOwnershipRequest(VRC.SDKBase.VRCPlayerApi requestingPlayer, VRC.SDKBase.VRCPlayerApi requestedOwner) => true; #endif + public virtual void MidiNoteOn(int channel, int number, int velocity) { } + public virtual void MidiNoteOff(int channel, int number, int velocity) { } + public virtual void MidiControlChange(int channel, int number, int value) { } [Obsolete("The OnStationEntered() event is deprecated use the OnStationEntered(VRCPlayerApi player) event instead, this event will be removed in a future release.")] public virtual void OnStationEntered() { } From 1fecfafe929cdfb2ccf5ea013eb0ac69eea39c62 Mon Sep 17 00:00:00 2001 From: Merlin <36685500+MerlinVR@users.noreply.github.com> Date: Sat, 6 Mar 2021 16:09:30 -0800 Subject: [PATCH 2/2] Add input events and respawn event from open beta --- Assets/UdonSharp/Editor/UdonSharpResolverContext.cs | 9 +++++++++ Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs b/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs index fdea5b8c..9b968424 100644 --- a/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs +++ b/Assets/UdonSharp/Editor/UdonSharpResolverContext.cs @@ -158,10 +158,19 @@ public bool ReplaceInternalEventName(ref string eventName) { "_onPlayerCollisionExit", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerCollisionExitPlayer") } }, { "_onPlayerCollisionStay", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerCollisionStayPlayer") } }, { "_onPlayerParticleCollision", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerParticleCollisionPlayer") } }, + { "_onPlayerRespawn", new System.Tuple[] { new System.Tuple(typeof(VRC.SDKBase.VRCPlayerApi), "onPlayerRespawnPlayer") } }, { "_onVideoError", new System.Tuple[] { new System.Tuple(typeof(VRC.SDK3.Components.Video.VideoError), "onVideoErrorVideoError") } }, { "_midiNoteOn", new System.Tuple[] { new System.Tuple(typeof(int), "midiNoteOnChannel"), new System.Tuple(typeof(int), "midiNoteOnNumber"), new System.Tuple(typeof(int), "midiNoteOnVelocity") } }, { "_midiNoteOff", new System.Tuple[] { new System.Tuple(typeof(int), "midiNoteOffChannel"), new System.Tuple(typeof(int), "midiNoteOffNumber"), new System.Tuple(typeof(int), "midiNoteOffVelocity") } }, { "_midiControlChange", new System.Tuple[] { new System.Tuple(typeof(int), "midiControlChangeChannel"), new System.Tuple(typeof(int), "midiControlChangeNumber"), new System.Tuple(typeof(int), "midiControlChangeValue") } }, + { "_inputJump", new System.Tuple[] { new System.Tuple(typeof(bool), "inputJumpBoolValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputJumpArgs") } }, + { "_inputUse", new System.Tuple[] { new System.Tuple(typeof(bool), "inputUseBoolValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputUseArgs") } }, + { "_inputGrab", new System.Tuple[] { new System.Tuple(typeof(bool), "inputGrabBoolValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputGrabArgs") } }, + { "_inputDrop", new System.Tuple[] { new System.Tuple(typeof(bool), "inputDropBoolValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputDropArgs") } }, + { "_inputMoveHorizontal", new System.Tuple[] { new System.Tuple(typeof(float), "inputMoveHorizontalFloatValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputMoveHorizontalArgs") } }, + { "_inputMoveVertical", new System.Tuple[] { new System.Tuple(typeof(float), "inputMoveVerticalFloatValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputMoveVerticalArgs") } }, + { "_inputLookHorizontal", new System.Tuple[] { new System.Tuple(typeof(float), "inputLookHorizontalFloatValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputLookHorizontalArgs") } }, + { "_inputLookVertical", new System.Tuple[] { new System.Tuple(typeof(float), "inputLookVerticalFloatValue"), new System.Tuple(typeof(VRC.Udon.Common.UdonInputEventArgs), "inputLookVerticalArgs") } }, }; public System.Tuple[] GetMethodCustomArgs(string methodName) diff --git a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs index 1a6cac80..8dc0131a 100644 --- a/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs +++ b/Assets/UdonSharp/Scripts/UdonSharpBehaviour.cs @@ -132,13 +132,25 @@ public virtual void OnPlayerCollisionEnter(VRC.SDKBase.VRCPlayerApi player) { } public virtual void OnPlayerCollisionExit(VRC.SDKBase.VRCPlayerApi player) { } public virtual void OnPlayerCollisionStay(VRC.SDKBase.VRCPlayerApi player) { } public virtual void OnPlayerParticleCollision(VRC.SDKBase.VRCPlayerApi player) { } + public virtual void OnPlayerRespawn(VRC.SDKBase.VRCPlayerApi player) { } + #if UDON_BETA_SDK public virtual bool OnOwnershipRequest(VRC.SDKBase.VRCPlayerApi requestingPlayer, VRC.SDKBase.VRCPlayerApi requestedOwner) => true; #endif + public virtual void MidiNoteOn(int channel, int number, int velocity) { } public virtual void MidiNoteOff(int channel, int number, int velocity) { } public virtual void MidiControlChange(int channel, int number, int value) { } + public virtual void InputJump(bool value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputUse(bool value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputGrab(bool value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputDrop(bool value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputMoveHorizontal(float value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputMoveVertical(float value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputLookHorizontal(float value, VRC.Udon.Common.UdonInputEventArgs args) { } + public virtual void InputLookVertical(float value, VRC.Udon.Common.UdonInputEventArgs args) { } + [Obsolete("The OnStationEntered() event is deprecated use the OnStationEntered(VRCPlayerApi player) event instead, this event will be removed in a future release.")] public virtual void OnStationEntered() { }