void OnEnable () { UpdateImage(false); } // Gillissie added false argument.
void UpdateImage(bool makePixelPerfect = true) // Gillissie added makePixelPerfect argument.
{
if (target != null)
{
if (isEnabled)
{
target.spriteName = UICamera.IsHighlighted(gameObject) ? hoverSprite : normalSprite;
}
else
{
target.spriteName = disabledSprite;
}
if (makePixelPerfect)
{
// Gillissie - Added this condition, since calling this when dragging a prefab
// into the scene in the editor causes a UIPanel to be added unnecessarily,
// due to a bug in Unity where the OnEnable() function is called on objects
// before they reach their final place in the hierarchy, so NGUI doesn't find
// the UIPanel when first being activated.
target.MakePixelPerfect();
}
}
}