You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Description:
In order to test interaction in the Unity editor, one must use OnMouseDown instead of Interact to capture clicks. This also captures mouse clicks in VRChat, but not VR interaction, so it cannot actually be used in a VRChat world. If you use both OnMouseDown and Interact, you get double invocations for desktop VRChat users.
Because of this, I would like a way to only declare OnMouseDown when the script is compiled during Unity's "Run" mode, but not when the world is built to be published to VRChat (or tested in a local VRC instance for that matter).
The solution I propose is to simply define a compiler symbol that can be used like so:
Forgive me if this is already possible somehow; I tried using #if UNITY_EDITOR but it seems that either UdonSharp doesn't support conditional compilation yet, or the UNITY_EDITOR symbol is not defined at play-time inside Unity, because OnMouseDown was never called unless I removed the conditional compilation.
The text was updated successfully, but these errors were encountered:
U# supports the preprocessor directives #if, #elif, #else, and #endif by default as part of the Roslyn AST parsing. But at the moment it does not copy the define symbols such as UNITY_EDITOR from the project settings. This will be added eventually, but requires separate builds for in-game vs in-editor. Which means build pre-process steps that compile the game version of the scripts, and then clean up and build the editor scripts again after the upload is finished. It also requires storing distinct debugging information for each type of build.
In the mean time if you want to check if some code is running in the editor, you can check if Networking.localPlayer is null. For the Interact event specifically, you also have a button in the UdonBehaviour inspector that will show up when you have the Interact event defined that you can click while in play mode to trigger the interact event.
Feature Description:
In order to test interaction in the Unity editor, one must use
OnMouseDown
instead ofInteract
to capture clicks. This also captures mouse clicks in VRChat, but not VR interaction, so it cannot actually be used in a VRChat world. If you use bothOnMouseDown
andInteract
, you get double invocations for desktop VRChat users.Because of this, I would like a way to only declare
OnMouseDown
when the script is compiled during Unity's "Run" mode, but not when the world is built to be published to VRChat (or tested in a local VRC instance for that matter).The solution I propose is to simply define a compiler symbol that can be used like so:
Forgive me if this is already possible somehow; I tried using
#if UNITY_EDITOR
but it seems that either UdonSharp doesn't support conditional compilation yet, or theUNITY_EDITOR
symbol is not defined at play-time inside Unity, becauseOnMouseDown
was never called unless I removed the conditional compilation.The text was updated successfully, but these errors were encountered: