vrchat-community / UdonSharp

A compiler for compiling C# to Udon assembly
https://udonsharp.docs.vrchat.com
MIT License
462 stars 50 forks source link

Implement IUdonEventReceiver interface on UdonSharpBehaviour #113

Open synergiance opened 1 year ago

synergiance commented 1 year ago

Feature Description: This one's pretty simple, I want UdonSharpBehaviour to implement the interface IUdonEventReceiver to make it work with the new image downloader class.

Additional context: When trying to pass this into VRCImageDownloader.DownloadImage() I get a compile error. I tried adding IUdonEventReceiver to the list of interfaces to the UdonSharpBehaviour class myself and it required a bunch of internal vrchat jargon we didn't need, but was necessary for the interface to work. As it stands right now, unless using hacky methods, we cannot pass the current behaviour into the DownloadImage() method. As such this may be an upstream problem I'm willing to file a canny for. Either that or I'm just doing it wrong.

Phasedragon commented 1 year ago

you can cast UdonSharpBehaviour to IUdonEventReceiver directly, with (IUdonEventReceiver)this

synergiance commented 1 year ago

It's a great workaround, thanks!

That being said, I'd expect to be able to use an UdonSharpBehaviour anywhere an UdonBehaviour is used directly since an UdonSharpBehaviour essentially is an UdonBehaviour. This would be good to note on the documentation. It would also be good to note on the documentation that Material and UdonBehaviour parameters are not optional, unlike what is described with the Udon Graph.