Hi Can anyone translate this code to javascript for me?
I’m trying to get the script so when a url is typed into a textfield it recognises it and makes it into a hyper linke. I’d really appreciate some help with this one.
using UnityEngine;
public class Example : MonoBehaviour
{
string url = "http://www.unity3d.com";
void OnGUI()
{
url = GUILayout.TextField(url, GUILayout.Width(200));
if (IsLink(url)) // Is it a link?
{
// Then show the submit button...
if (GUILayout.Button("Submit", GUILayout.Width(200)))
{
// do something with url...
}
}
}
bool IsLink(string text)
{
if (text.StartsWith("http://") || text.StartsWith("www"))
return true;
else
return false;
}
}