How to make a single word in a Text object clickable / have hover.

Hey everyone.

As the question suggests, I’d like to know how one might have a single word within a Text element clickable.

An example would be in a lot of MMOs in the chat log, player names can be clicked on to open their profile, or Items can have a tooltip when your mouse is hovered over them.

How would one do this using Unity’s 4.6 UI system?

Thanks!

Not sure if this is doable in Unity’s UI. However, it is doable in NGUI.

Hello.
I work on clickable string with simple UI, and made this simple solution.
Create a big Button for your text to be in.
Put your text in TEXT of this button.
Store the position of the first letter of your clickable word in the entire text.

In you do this at runtime, wait for an update, and.

Rect target = new Rect();
					target.position = new Vector2(YourText.cachedTextGenerator.characters[clickable.index].cursorPos.x,YourText.cachedTextGenerator.characters[clickable.index].cursorPos.y + YourText.cachedTextGenerator.lines[0].height / 2);
					target.width = Mathf.Abs(YourText.cachedTextGenerator.characters[clickable.index].cursorPos.x - YourText.cachedTextGenerator.characters[clickable.index + clickable.Length].cursorPos.x);
					target.height = - YourText.cachedTextGenerator.lines[0].height;

This will create a target Rect.
Store it in a list of Object, with what you want this clickable to do.

And when player clic on this TextButton.

PointerEventData eventData = new PointerEventData(EventSystem.current);
eventData.position = Input.mousePosition;

Vector2 localCursor;
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(TextButton.GetComponent<RectTransform>(), eventData.position, eventData.pressEventCamera, out localCursor))
			return;

foreach (Clickable cc in MyListOfClickable) {
if (cc.target.Contains(localCursor,true)) {
// Hit this clickable string
}
}

My response is late, but maybe can help someone else.