I have UI button’s that are meant to represent audio sources being selected.
Basically works like this; if button is clicked, selected audiosource = this.button.audiosource.
The problem is that since there are multiple buttons, for whatever reason, Udon Sharp is iterating through all the buttons choosing the last UI Button’s audio source as the ‘selected’ one. Even though the user is only selecting one at a time and a different one even.
Not sure what it is. Familiar with C#, and it works fine in stand-alone C#.
Would rather not create a bunch of script variants with slightly different names to do the same thing.
EDIT FOR MORE CONTEXT: The problem arose when I used private void InputUse(bool value, VRC.Udon.Common.UdonInputEventArgs args)
InputUse is a VRChat event that executes every time you press the input button on your controller/mouse, no matter the circumstance. Setting the UI Buttons to use this event will execute them every time you press the input button. Instead, you should be declaring a custom public event in your script, such as public void UseButton()
to execute your code, and setting the UI Button component in the Unity Editor to execute that custom method on the specific Udon Behaviour on the button’s OnClick() event.
More information:
https://docs.unity3d.com/Packages/[email protected]/manual/script-Button.html
I did try this but the event list gets nullified on runtime. I have no idea why.
Thinking of starting over because I went into this trying to port my vr-instrument from C# to udon sharp with the limitations in mind.
Still caused problems, though.
The event list for UI Buttons it whitelisted. You have to select the UdonBehaviour as the target object, then select the UdonBehaviour.SendCustomEvent(string) event option, and type in the event name.
Event name as in function?
The function I created is called ‘public void Change()’.
Yes, you just type in its name without the brackets, so it would be: Change