I’m trying to get Button working and have several questions.
- How can I achieve Unity UI button’s click get detected from ts side?
- How to enable/disable gameobject on button click?
- How to open url if button clicked?
I can get click on 3D object, but no luck with UI Button. There are images of code and editor
Original Post on Discord
by user 267660755443122181
Achieved 2) with this code. But I couldn’t understand your way of setting active property
by user 267660755443122181
marcel
(marwi)
4
For example like this if you want to do it without code
marcel
(marwi)
5
This would work if you write it like so:
onClick() {
if(this.myObj) this.myObj.visible = false;
}
That’s because your field is potentially undefined (that’s the ?
in myObj?
which is shorthand for myObj : Object3D | undefined;
oooh, I thougth it was this.myObj.active = false
by user 267660755443122181
Where I can read about built in OpenURL? Searched in docs, but no results
by user 267660755443122181
marcel
(marwi)
8
It might not be documented there right now. But you can just add it to an object and enable “Clickable” to open the url on click on the object