Good day. I implemented a UI such that it initially displays a scroll view containing a table with three columns. See the screenshot
BeforePreviewNow, when of those images are clicked, a preview window should slide out. The intended behavior is in the screenshot
NormalPreview.
At first, I wanted to emulate the Example 9 with sliding panels, however it doesn't use any embedded scroll view. I tried to use the same approach creating a nested table with the preview window and the scroll view as the content. Unfortunately, it didn't work. The parent panel that holds the top table cannot clip the view inside scrollview. So I tried a different approach. I attached a Scale tween for the preview window and then attached a Position Tween and Custom script that I made to tween the scroll view clipping. I almost got my intended behavior but for some reason the scrollview moves too low on the screen. See screenshot
OverlapPreview. Here's the snippet of my tween for scroll view clip.
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);
}
This is invoked at the same time as the motion tween. I would like to ask what would be the probable cause of the misplaced scrollview and how to solve it. I'm also welcome for other approaches on how to implement the UI feature that I want to attain. Thanks in advance.