Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add UPM structure #190

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ sysinfo.txt
*.apk
*.unitypackage
.DS_Store
/.idea/
39 changes: 0 additions & 39 deletions .vscode/launch.json

This file was deleted.

57 changes: 0 additions & 57 deletions .vscode/settings.json

This file was deleted.

70 changes: 35 additions & 35 deletions Assets/Examples/Bag/BagMain.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
using UnityEngine;
using FairyGUI;
/// <summary>
/// A game bag demo, demonstrated how to customize loader to load icons not in the UI package.
/// </summary>
public class BagMain : MonoBehaviour
{
GComponent _mainView;
BagWindow _bagWindow;
void Awake()
{
//Register custom loader class
UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));
}
void Start()
{
Application.targetFrameRate = 60;
Stage.inst.onKeyDown.Add(OnKeyDown);
GRoot.inst.SetContentScaleFactor(1136, 640);
_mainView = this.GetComponent<UIPanel>().ui;
_bagWindow = new BagWindow();
_mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); });
}
void OnKeyDown(EventContext context)
{
if (context.inputEvent.keyCode == KeyCode.Escape)
{
Application.Quit();
}
}
using UnityEngine;
using FairyGUI;

/// <summary>
/// A game bag demo, demonstrated how to customize loader to load icons not in the UI package.
/// </summary>
public class BagMain : MonoBehaviour
{
GComponent _mainView;
BagWindow _bagWindow;

void Awake()
{
//Register custom loader class
UIObjectFactory.SetLoaderExtension(typeof(MyGLoader));
}

void Start()
{
Application.targetFrameRate = 60;
Stage.inst.onKeyDown.Add(OnKeyDown);
GRoot.inst.SetContentScaleFactor(1136, 640);
_mainView = this.GetComponent<UIPanel>().ui;

_bagWindow = new BagWindow();
_mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); });
}

void OnKeyDown(EventContext context)
{
if (context.inputEvent.keyCode == KeyCode.Escape)
{
Application.Quit();
}
}
}
98 changes: 49 additions & 49 deletions Assets/Examples/Bag/BagWindow.cs
Original file line number Diff line number Diff line change
@@ -1,49 +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;
}
}
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;
}
}
Loading