CyanLaser / CyanEmu

CyanEmu is a VRChat client emulator in Unity. Includes a player controller with interact system. Works with SDK2 and SDK3.
MIT License
359 stars 15 forks source link

CyanEmu Udon emulation does not respect private methods #51

Open RedSpeeds opened 2 years ago

RedSpeeds commented 2 years ago

Hey there while debugging i noticed a bug that cyanemu executes methods prefixed with an underscore when they are ran thru sendcustomnetwork event this is in my opinion unwanted behavior the excepted behavior would be for cyanemu to throw an error stating methods prefixed with an underscore cannot be executed over the network.

CyanLaser commented 2 years ago

This is an issue with the vrchat sdk itself and is not something CyanEmu can change without modifying the sdk.

https://vrchat.canny.io/vrchat-udon-closed-alpha-bugs/p/sdk-202106031457-sendcustomnetworkevent-executes-events-that-start-with-an-under

RedSpeeds commented 2 years ago

I see would i be possible to write a SDK edit similar to the one that was made for SDK2 triggers

CyanLaser commented 2 years ago

Open UdonBehaviour.cs, find the SendCustomNetworkEvent method, and remove the editor only code. CyanEmu will then handle ignoring networked events that start with an underscore.

By default, it will look like this:

public override void SendCustomNetworkEvent(NetworkEventTarget target, string eventName)
{
#if UNITY_EDITOR
    SendCustomEvent(eventName);
#else
    SendCustomNetworkEventHook?.Invoke(this, target, eventName);
#endif
}

Change it to look like this:

public override void SendCustomNetworkEvent(NetworkEventTarget target, string eventName)
{
    SendCustomNetworkEventHook?.Invoke(this, target, eventName);
}
RedSpeeds commented 2 years ago

Took me a while to find the time to write these changes but here you go :)