So I made a UITooltip and it works wonderfully other than it thinks the text is some weird size compared to what it actually is, causing the background box to be too slim and too tall. After much brainpower spent, I also realized there were some other on-the-fly type options I wanted for the tooltip, so I ended up adding:
static public void ShowText(string tooltipText, NGUIText.Alignment align, UILabel.Overflow overflow, Vector4 offset, int width = 0)
{
if (mInstance != null)
{
mInstance.text.overflowMethod = overflow;
mInstance.text.alignment = align;
if (width != 0)
mInstance.text.width = width;
mInstance.SetText(tooltipText, offset);
}
}
and I overloaded SetText with
protected virtual void SetText(string tooltipText)
{
SetText(tooltipText, Vector4.zero);
}
protected virtual void SetText(string tooltipText, Vector4 offsetBorderSize)
{
...
if (background != null)
{
Vector4 border = background.border + offsetBorderSize;
Granted I'm no code genius, but it lets me set the tooltip's label overflow and alignment to be different as needed, the width of the tooltip when needed, and pad the sides of the background box as needed.
It works great. I am sure the border thing isn't working 100% as desired, but it works so far.
So the question is, could this be added? I tried extending the class, but using the static method and mInstance was giving me fits and rather than figure it out I just went with this approach.
Regardless of my lack of knowledge of how to do it properly, having a more customized version of setting the UITooltip text is helpful.