void Awake() {
this.panel = GetComponent<UIPanel>();
this.scroll = GetComponent<UIScrollView>();
this.center = new Vector2
(this.panel.baseClipRegion.x,
this.panel.baseClipRegion.y); this.origSize = this.panel.GetViewSize();
}
public void UpdateClipSize(Vector2 newClipSize) {
this.panel.baseClipRegion = new Vector4
(center
.x, center
.y, newClipSize
.x, newClipSize
.y); }
public void CompleteTween() {
this.reverse = !this.reverse;
this.scroll.ResetPosition();
}
public void TweenClipSize() {
Vector2 from = this.origSize;
Vector2 to = this.targetSize;
if(this.reverse) {
from = this.targetSize;
to = this.origSize;
}
Hashtable ht
= new Hashtable
(); ht.Add("from", from);
ht.Add("to", to);
ht.Add("time", 0.2f);
ht.Add("onupdate", "UpdateClipSize");
ht.Add("onupdatetarget", this.gameObject);
ht.Add("oncomplete", "CompleteTween");
iTween.ValueTo(this.gameObject, ht);
}