how can i create an interactive text in GUI.Window?
hello,
I'm trying to create a window with some text in. A word in the text must be interactive (if the player click on the specific word, a new function is call). But I don't really know how to do it.
Help please... Thanks.
here my code :
private Rect windowRect = new Rect(20, 200, 200, 200);
public void OnMouseOver()
{
spriteRenderer.material.color = selectedColor;
if (Input.GetMouseButtonDown(1))
{
isClicked = true;
}
}
private void OnGUI()
{
if (isClicked == true)
{
windowRect = GUI.Window(0, windowRect, WindowFunction, "Crable City");
}
}
private void WindowFunction (int windowId)
{
if (GUI.Button(new Rect(20, 20, 50, 50), "Close"))
{
isClicked = false;
}
StreamReader reader = new StreamReader("Assets/Text/Crable City.txt");
GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height));
GUI.Label(new Rect(5, 80, 200, 300), reader.ReadToEnd());
int truc = GUI.skin.GetStyle("Label").GetCursorStringIndex(
new Rect(5, 80, 200, 300), new GUIContent(reader.ReadToEnd()), Event.current.mousePosition);
}
Comment