Hi
I’ve created a GUI.textfield where a user can post a message but so far they can only type in text. is there a way for them to paste in a hyperlink so that the GUI recognizes it as one?
Cheers
Hi
I’ve created a GUI.textfield where a user can post a message but so far they can only type in text. is there a way for them to paste in a hyperlink so that the GUI recognizes it as one?
Cheers
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;
}
}
var url = "http://www.unity3d.com";
function 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...
}
}
}
function IsLink(string text) : boolean
{
if (text.StartsWith("http://") || text.StartsWith("www"))
return true;
else
return false;
}
}