- Home /
Find Location via script query
Hi guys
I've been stuck on this for about 2 weeks.. I'm using Unity 4.6 open beta. I'm making a type of interactive word search game. What I need to do is find the x and y coordinates of a word in my text canvas and place a button directly over it. Right now the part of my script that I'm struggling with looks like this:
var cBody : UI.Text;
function OnGUI()
{
if(cBody.text.Contains("word"))
{
if(GUI.Button(Rect (Screen.width-155,36,150,30), "word", GUIStyle.none))
{
print("word button clicked");
}
}
}
The if statement to find if a specific word is there works, it finds the word and only displays the button if it finds the word in the canvas text. What I'm trying to do is find the location of that word so that the button it creates is directly over that word. The text of the canvas will change so I can't just position the button manually..
Anyone know how I can do this or have a better way to accomplish this task? Any help will be greatly appreciated!
PS I'm using JavaScript