0
\$\begingroup\$

I have a public method

public void patreononclick(){
   Application.OpenURL("http://www.patreon.com/HubakaGs");
}

This is supposed to open my Patreon page when a button is tapped.

But when I tap the button in the built application, nothing happens.

I have assigned the function to the On Click() section of the Button (Script).

I am building the game for Android and I use Unity 2017.1.0p4 Personal.

How can I make the button function properly?

Update:

I changed the function to

public void patreononclick(){
    Debug.Log ("the game should open patreon");
    Application.OpenURL("http://www.patreon.com/HubakaGs");
}

But when the button is clicked, there is no message in the console.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Have you properly set the internet access permission? \$\endgroup\$
    – user35344
    Commented Aug 24, 2017 at 10:39
  • \$\begingroup\$ How do i do that? \$\endgroup\$
    – Hubaka Gs
    Commented Aug 24, 2017 at 10:44
  • \$\begingroup\$ Set "Internet Access" in the "Android PlayerSettings" window to "Require", see here. \$\endgroup\$
    – user35344
    Commented Aug 24, 2017 at 10:50
  • \$\begingroup\$ @Tyyppi_77 i did it and it still not working :( \$\endgroup\$
    – Hubaka Gs
    Commented Aug 24, 2017 at 12:01

2 Answers 2

1
\$\begingroup\$

After hours of pulling hair, I finally noticed that this

enter image description here

was set to off, so I set it to Editor And Runtime, and it worked perfectly. I can even open the link from the editor trough a browser.

\$\endgroup\$
1
  • \$\begingroup\$ I changed it to Editor and Runtime, still doesn't work. \$\endgroup\$
    – Mr Bitman
    Commented May 17, 2020 at 3:57
1
\$\begingroup\$

Here are four things to check when your UI button click event is not firing…

  1. Make sure your canvas has a Graphics Raycaster attached.
  2. Your Image component's Raycast Target must be enabled.
  3. Make sure there are no overlapping UI elements.
  4. Make sure to have a gameobject with the EventSystem component in the scene.
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .