首次提交
This commit is contained in:
49
Assets/Plugins/FairyGUI/Examples/Bag/BagWindow.cs
Normal file
49
Assets/Plugins/FairyGUI/Examples/Bag/BagWindow.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using FairyGUI;
|
||||
using UnityEngine;
|
||||
|
||||
public class BagWindow : Window
|
||||
{
|
||||
GList _list;
|
||||
|
||||
public BagWindow()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
this.contentPane = UIPackage.CreateObject("Bag", "BagWin").asCom;
|
||||
this.Center();
|
||||
this.modal = true;
|
||||
|
||||
_list = this.contentPane.GetChild("list").asList;
|
||||
_list.onClickItem.Add(__clickItem);
|
||||
_list.itemRenderer = RenderListItem;
|
||||
_list.numItems = 45;
|
||||
}
|
||||
|
||||
void RenderListItem(int index, GObject obj)
|
||||
{
|
||||
GButton button = (GButton)obj;
|
||||
button.icon = "i" + UnityEngine.Random.Range(0, 10);
|
||||
button.title = "" + UnityEngine.Random.Range(0, 100);
|
||||
}
|
||||
|
||||
override protected void DoShowAnimation()
|
||||
{
|
||||
this.SetScale(0.1f, 0.1f);
|
||||
this.SetPivot(0.5f, 0.5f);
|
||||
this.TweenScale(new Vector2(1, 1), 0.3f).OnComplete(this.OnShown);
|
||||
}
|
||||
|
||||
override protected void DoHideAnimation()
|
||||
{
|
||||
this.TweenScale(new Vector2(0.1f, 0.1f), 0.3f).OnComplete(this.HideImmediately);
|
||||
}
|
||||
|
||||
void __clickItem(EventContext context)
|
||||
{
|
||||
GButton item = (GButton)context.data;
|
||||
this.contentPane.GetChild("n11").asLoader.url = item.icon;
|
||||
this.contentPane.GetChild("n13").text = item.icon;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user