It is not that hard actualy, but I faced with one more problem:
I have some prefab "MarkupWord", that contains tooltip stuff to appear via behaviour:
using UnityEngine;
using System.Collections;
public class HoverTooltip : MonoBehaviour {
public string tooltip;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTooltip(bool show) {
Debug.LogWarning("TOOLTIP : " + show);
if (show) {
UITooltip.ShowText(tooltip);
} else {
UITooltip.ShowText(null);
}
}
}
It has UILabel component attached.
If I add this to root scene, tooltip works ok, but i have a card object that is UISprite with Button component attached.
That card object has empty widget - container for my words.
When i add these objects to that widget, the tooltip is never triggered for them
private void AddWord(string word) {
GameObject markupObject = NGUITools.AddChild(textContainer.gameObject, prefabLabel);
markupObject
.transform.localScale = new Vector3
(SCALE_CONTENT, SCALE_CONTENT, 1f
); UILabel label
= (UILabel
) markupObject
.GetComponent(typeof(UILabel
)); HoverMarkup markupHover
= (HoverMarkup
) markupObject
.GetComponent(typeof(HoverMarkup
)); markupHover.tooltip = word + "%c%f%b";
label.text = word;
Debug.LogWarning("Added text: <" + word + "> " + label.width + "," + label.height);
//caret new line
if (mCursorWidth + label.width * SCALE_CONTENT > textContainer.width) {
mCursorHeight -= label.height * SCALE_CONTENT;
mCursorWidth = 0f;
}
markupObject
.transform.localPosition = new Vector3
(mCursorWidth, mCursorHeight, 0f
); mCursorWidth += SCALE_CONTENT * label.width;
}
Is that true, that parent object catches all mouse stuff and doesnt allow children to trigger tooltips?
What can I do about it?