1
NGUI 3 Support / Re: Box-Collider does not adjust when changing label text programatically
« on: November 20, 2014, 09:16:05 AM »
I still have the same issu in v3.7.4. Any workaround?
Edit: tried using an invisible widget as the gameobject for the collider, and anchoring it to the label. The widget resizes correctly but the collider still doesn't.
Edit2: I wrote a little piece of script that calls a resize on the collider if it finds a difference, during Update(). Just attach it to the label that has a collider, works as-is.
Edit: tried using an invisible widget as the gameobject for the collider, and anchoring it to the label. The widget resizes correctly but the collider still doesn't.
Edit2: I wrote a little piece of script that calls a resize on the collider if it finds a difference, during Update(). Just attach it to the label that has a collider, works as-is.
Quote from: UpdateLabelCollider.cs
using UnityEngine; using System.Collections; public class UpdateLabelCollider : MonoBehaviour { private Collider _col; private UILabel _lab; void OnEnable() { _col= gameObject.GetComponent<Collider>(); _lab= gameObject.GetComponent<UILabel>(); } void Update () { if(_lab.width != _col.bounds.size.x || _lab.height != _col.bounds.size.y) _lab.ResizeCollider(); } }
