CyanLaser / CyanEmu

CyanEmu is a VRChat client emulator in Unity. Includes a player controller with interact system. Works with SDK2 and SDK3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CyanEmu Udon emulation does not respect private methods

RedSpeeds opened this issue · comments

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.

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

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

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);
}

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