简体   繁体   中英

Open Webpage when sprite clicked

This is what i tried :

  Application.OpenURL("http://gameone.co/");

But this opens a million of http://gameone.co/ ... I want to this url open when clicked on a sprite named http. It has also tag of http. But i can delete tag or whatever i want cause it does nothing. And also my project is for Android Build. Can i use raycast on it if hit open url but just 1 time.

More Detail: i made a 2d game hwo just contain ongui function i have added facebook sdk, google ads sdk, i have installed all the android sdk from sdk manager, i have installed admob plugin vntis. but i havent used facebook sdk. and my pc is 64 bit.

OnGUI function is called many many times in a second. If you add Application.OpenURL("http://gameone.co/"); into that, the webpage will open as many times.

What you can do is to add GUI.Button to the OnGUI function.

void OnGUI() {
    if (GUI.Button(new Rect(10, 70, 50, 30), "Open webpage!")){
        Application.OpenURL("http://gameone.co/");
    }
}

Then the webpage will open only when the button is pressed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM