CyanEmu icon indicating copy to clipboard operation
CyanEmu copied to clipboard

CyanEmu Udon emulation does not respect private methods

Open RedSpeeds opened this issue 3 years ago • 4 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.

RedSpeeds avatar Oct 10 '21 15:10 RedSpeeds

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

CyanLaser avatar Oct 10 '21 15:10 CyanLaser

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

RedSpeeds avatar Oct 11 '21 07:10 RedSpeeds

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

CyanLaser avatar Oct 11 '21 13:10 CyanLaser

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

RedSpeeds avatar Oct 15 '21 20:10 RedSpeeds