首次提交
This commit is contained in:
55
Assets/Plugins/FairyGUI/Examples/Extension/ExtensionMain.cs
Normal file
55
Assets/Plugins/FairyGUI/Examples/Extension/ExtensionMain.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class ExtensionMain : MonoBehaviour
|
||||
{
|
||||
GComponent _mainView;
|
||||
GList _list;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
UIPackage.AddPackage("UI/Extension");
|
||||
UIObjectFactory.SetPackageItemExtension("ui://Extension/mailItem", typeof(MailItem));
|
||||
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Stage.inst.onKeyDown.Add(OnKeyDown);
|
||||
|
||||
_mainView = this.GetComponent<UIPanel>().ui;
|
||||
|
||||
_list = _mainView.GetChild("mailList").asList;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
MailItem item = (MailItem)_list.AddItemFromPool();
|
||||
item.setFetched(i % 3 == 0);
|
||||
item.setRead(i % 2 == 0);
|
||||
item.setTime("5 Nov 2015 16:24:33");
|
||||
item.title = "Mail title here";
|
||||
}
|
||||
|
||||
_list.EnsureBoundsCorrect();
|
||||
float delay = 0f;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
MailItem item = (MailItem)_list.GetChildAt(i);
|
||||
if (_list.IsChildInView(item))
|
||||
{
|
||||
item.PlayEffect(delay);
|
||||
delay += 0.2f;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void OnKeyDown(EventContext context)
|
||||
{
|
||||
if (context.inputEvent.keyCode == KeyCode.Escape)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b0647927cbff65449b89590caf97481
|
||||
timeCreated: 1446648215
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/Plugins/FairyGUI/Examples/Extension/MailItem.cs
Normal file
41
Assets/Plugins/FairyGUI/Examples/Extension/MailItem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using FairyGUI;
|
||||
|
||||
public class MailItem : GButton
|
||||
{
|
||||
GTextField _timeText;
|
||||
Controller _readController;
|
||||
Controller _fetchController;
|
||||
Transition _trans;
|
||||
|
||||
public override void ConstructFromXML(FairyGUI.Utils.XML cxml)
|
||||
{
|
||||
base.ConstructFromXML(cxml);
|
||||
|
||||
_timeText = this.GetChild("timeText").asTextField;
|
||||
_readController = this.GetController("IsRead");
|
||||
_fetchController = this.GetController("c1");
|
||||
_trans = this.GetTransition("t0");
|
||||
}
|
||||
|
||||
public void setTime(string value)
|
||||
{
|
||||
_timeText.text = value;
|
||||
}
|
||||
|
||||
public void setRead(bool value)
|
||||
{
|
||||
_readController.selectedIndex = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setFetched(bool value)
|
||||
{
|
||||
_fetchController.selectedIndex = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public void PlayEffect(float delay)
|
||||
{
|
||||
this.visible = false;
|
||||
_trans.Play(1, delay, null);
|
||||
}
|
||||
}
|
||||
12
Assets/Plugins/FairyGUI/Examples/Extension/MailItem.cs.meta
Normal file
12
Assets/Plugins/FairyGUI/Examples/Extension/MailItem.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26140e87934f8754689c7bf2ac147fbe
|
||||
timeCreated: 1446648219
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user