public class NewsPanelManager : MonoBehaviour
{
public UISlicedSprite stretchedBackground;
public UISlicedSprite expandButtonBackground;
public UIPanel textPanel;
public UILabel textLabel;
private UIDraggablePanel draggableTextPanel;
private Vector3 buttonScale;
void Start()
{
draggableTextPanel = textPanel.GetComponent<UIDraggablePanel>();
buttonScale = expandButtonBackground.transform.localScale;
UpdateLabelCollider();
}
void Update()
{
ResizeClippingArea();
}
private void UpdateLabelCollider()
{
NGUITools.AddWidgetCollider(textLabel.gameObject);
}
private void ResizeClippingArea()
{
Vector3 stretchedScale = stretchedBackground.transform.localScale;
float clippingSizeX = stretchedScale.x - buttonScale.x;
float clippingSizeY = stretchedScale.y;
float clippingCenterX = (stretchedScale.x + buttonScale.x) * 0.5f;
float clippingCenterY = 0f;
Vector4 clipRange
= new Vector4
(clippingCenterX, clippingCenterY, clippingSizeX, clippingSizeY
); textPanel.clipRange = clipRange;
//draggableTextPanel.ResetPosition();
}
}