- Home /
How do I put a link to a website when I click with the mouse an object or word?
Thanks to "UnityWebPlayer" the game can be played from your browser. But I would like to put a link to a website when clicking on objects (Images, doors, words ...) Would it be possible to put a url when I click with the mouse?
Thanks
Answer by Eric5h5 · Nov 27, 2010 at 02:11 AM
Use Application.OpenURL. For the clicking part, that depends on what you're doing exactly, but using OnMouseDown is one pretty simple way.
Thanks, I'm interested in this code, but do not know how to put in the code "On$$anonymous$$ouseDown"
Answer by oliver-jones · Nov 27, 2010 at 01:21 AM
You can find that info on here: file:///Applications/Unity/Documentation/ScriptReference/WWW.html
But you do this:
// Get the latest webcam shot from outside "Friday's" in Times Square var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg"; function Start () { // Start a download of the given URL var www : WWW = new WWW (url);
// Wait for download to complete
yield www;
// assign texture
renderer.material.mainTexture = www.texture;
}
This is example taken from Unity, showing you to retrieve info from websites. But you can manipulate into URL
Thank you very much for answering
I see the picture but I do not know where to put the web address in the code.
Where the var url is, change that in the "http://" to your specific website
Answer by rafaelzuckerberg · Apr 02, 2016 at 04:57 AM
you can do so: create one function:
// function of the button public void exampleFunction(string link){ Application.OpenURL (link); }
or :
// function of the button public void exampleFunction(){ Application.OpenURL ("www.exemplo.com"); }
now pass as parameter in your button or choose not pass parameter
Answer by mafanbong8819 · May 05, 2017 at 01:50 PM
Here, is the example of how to click the button then link to url, the step is clearly listed in this video. I hope this video is helpful to those need it too.
Click here for video, video - button to link
Here is the code.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class linkClick : MonoBehaviour {
public void linkFunc()
{
Application.OpenURL ("http://www.google.com");
}
}
Your answer
Follow this Question
Related Questions
How can I attach objects like a picture? 2 Answers
3d Object attach to mouse 1 Answer
How to pick up an object using left mouse button 2 Answers