// 显示指定玩家的牌型图标 void showNiu(int uid, int type) { var p = Data.Game.GetPlayer(uid); if (p == null) { return; } GComponent niu = UIPackage.CreateObject("qipai", "niu").asCom; var cp = cardPlaces[p.Index]; var cpos = cp.position; niu.GetController("niu").selectedIndex = type; niu.visible = true; if (uid == Data.User.Id) { cpos.y += 65; cpos.x += 65; niu.SetScale(1.4f, 1.4f); } else { cpos.y += 45; cpos.x += 30; niu.SetScale(0.8f, 0.8f); } niu.position = cpos; niu.AddRelation(cp, RelationType.Middle_Middle, true); niu.AddRelation(cp, RelationType.Center_Center, true); ui.AddChild(niu); nius.Add(niu); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/VirtualList"); UIObjectFactory.SetPackageItemExtension(UIPackage.GetItemURL("VirtualList", "mailItem"), typeof(MailItem)); _mainView = UIPackage.CreateObject("VirtualList", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _mainView.GetChild("n6").onClick.Add(() => { _list.AddSelection(500, true); }); _mainView.GetChild("n7").onClick.Add(() => { _list.scrollPane.ScrollTop(); }); _mainView.GetChild("n8").onClick.Add(() => { _list.scrollPane.ScrollBottom(); }); _list = _mainView.GetChild("mailList").asList; _list.SetVirtual(); _list.itemRenderer = RenderListItem; _list.numItems = 1000; }
void Start() { Application.targetFrameRate = 60; DontDestroyOnLoad(this.gameObject); Stage.Instantiate(5); Stage.inst.AddChild(new GRoot().displayObject); Stage.inst.camera.clearFlags = CameraClearFlags.Depth; Stage.inst.onKeyDown.Add(OnKeyDown); GRoot.inst.SetContentScaleFactor(1136, 640); UIPackage.AddPackage("UI/CustomMaterialDemo"); _mainView = UIPackage.CreateObject("Demo", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _btn0 = _mainView.GetChild("b0").asButton; _btn0.icon = "k0"; _time1 = 5; _mat0 = new Material(Shader.Find("Cooldown mask")); _mat0.SetFloat("_Progress", 0f); _mat0.SetTexture("_MaskTex", (Texture)Resources.Load("CooldownMask")); _btn0.GetChild("icon").asLoader.material = _mat0; _btn1 = _mainView.GetChild("b1").asButton; _btn1.icon = "k1"; _time2 = 10; _mat1 = new Material(Shader.Find("Cooldown mask")); _mat1.SetFloat("_Progress", 0f); _mat1.SetTexture("_MaskTex", (Texture)Resources.Load("CooldownMask")); _btn1.GetChild("icon").asLoader.material = _mat1; }
void Start() { Application.targetFrameRate = 60; Stage.inst.onKeyDown.Add(OnKeyDown); _mainView = this.GetComponent <UIPanel>().ui; _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom; _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height); _guideLayer.AddRelation(GRoot.inst, RelationType.Size); GObject bagBtn = _mainView.GetChild("bagBtn"); bagBtn.onClick.Add(() => { _guideLayer.RemoveFromParent(); }); _mainView.GetChild("n2").onClick.Add(() => { GRoot.inst.AddChild(_guideLayer); //!!Before using GlobalToLocal, the object must be added first Rect rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer); GObject window = _guideLayer.GetChild("window"); window.size = new Vector2((int)rect.size.x, (int)rect.size.y); window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f); }); }
public BasicsScene() { UIConfig.verticalScrollBar = "ui://Basics/ScrollBar_VT"; UIConfig.horizontalScrollBar = "ui://Basics/ScrollBar_HZ"; UIConfig.tooltipsWin = "ui://Basics/WindowFrame"; UIConfig.popupMenu = "ui://Basics/PopupMenu"; UIConfig.defaultFont = "Arial"; UIPackage.AddPackage("UI/Basics"); _mainView = UIPackage.CreateObject("Basics", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); AddChild(_mainView); _backBtn = _mainView.GetChild("btn_Back"); _backBtn.visible = false; _backBtn.onClick.Add(onClickBack); _demoContainer = _mainView.GetChild("container").asCom; _viewController = _mainView.GetController("c1"); _demoObjects = new Dictionary <string, GComponent>(); int cnt = _mainView.numChildren; for (int i = 0; i < cnt; i++) { GObject obj = _mainView.GetChildAt(i); if (obj.group != null && obj.group.name == "btns") { obj.onClick.Add(runDemo); } } }
// Use this for initialization void Start() { Application.targetFrameRate = 60; //Stage.inst.onKeyDown.Add(OnKeyDown); ResourceManager.Instance.SepDownloadURL = GameUtil.SepPath + "/StreamingAssets"; ResourceManager.Instance.UpdateDownloadURL = GameUtil.AssetRoot + "/StreamingAssets"; ResourceManager.Instance.BaseDownloadingURL = GameUtil.BaseStreamAssetPath + "/res_base/StreamingAssets"; ResourceManager.Instance.BundleExt = ".assetbundle"; ResourceManager.Instance.LoadBundle("assets/arts/fairygui/login", (AssetBundle ab) => { Debug.Log(ab); UIPackage.AddPackage(ab); _mainView = UIPackage.CreateObject("Login", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); //_mainView.GetTransition("t0").Play(); GObject p = FGUIHelper.Find(_mainView, "n4/n8"); GButton button = p.asButton; Debug.Log(button); button.onClick.Add(() => { Debug.Log("Click Me"); }); }); }
IEnumerator LoadUIPackage() { string url = Application.streamingAssetsPath.Replace("\\", "/") + "/FairyGUI-Examples/bundleusage.ab"; if (Application.platform != RuntimePlatform.Android) { url = "file:///" + url; } WWW www = new WWW(url); yield return(www); if (string.IsNullOrEmpty(www.error)) { AssetBundle bundle = www.assetBundle; if (bundle == null) { Debug.LogWarning("Run Window->Build FairyGUI example Bundles first."); yield return(0); } UIPackage.AddPackage(bundle); _mainView = UIPackage.CreateObject("BundleUsage", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _mainView.GetTransition("t0").Play(); } else { Debug.LogError(www.error); } }
public ChatScene() { UIPackage.AddPackage("UI/Emoji"); UIConfig.verticalScrollBar = "ui://Emoji/ScrollBar_VT"; UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto; _messages = new List <Message>(); _mainView = UIPackage.CreateObject("Emoji", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); AddChild(_mainView); _list = _mainView.GetChild("list").asList; _list.SetVirtual(); _list.itemProvider = GetListItemResource; _list.itemRenderer = RenderListItem; _input = _mainView.GetChild("input").asTextInput; _input.onSubmit.Add(onSubmit); _mainView.GetChild("btnSend").onClick.Add(__clickSendBtn); _mainView.GetChild("btnEmoji").onClick.Add(__clickEmojiBtn); _emojiSelectUI = UIPackage.CreateObject("Emoji", "EmojiSelectUI").asCom; _emojiSelectUI.GetChild("list").asList.onClickItem.Add(__clickEmoji); }
void Start() { Application.targetFrameRate = 60; DontDestroyOnLoad(this.gameObject); Stage.Instantiate(5); Stage.inst.AddChild(new GRoot().displayObject); Stage.inst.camera.clearFlags = CameraClearFlags.Depth; Stage.inst.onKeyDown.Add(OnKeyDown); //setup custom loader classs UIObjectFactory.SetLoaderExtension(typeof(MyGLoader)); GRoot.inst.SetContentScaleFactor(1136, 640); UIPackage.AddPackage("BagDemo"); _mainView = UIPackage.CreateObject("Bag", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _bagWindow = new BagWindow(); _mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); }); }
void Start() { Application.targetFrameRate = 60; DontDestroyOnLoad(this.gameObject); Stage.Instantiate(5); Stage.inst.AddChild(new GRoot().displayObject); Stage.inst.camera.clearFlags = CameraClearFlags.Depth; Stage.inst.onKeyDown.Add(OnKeyDown); GRoot.inst.SetContentScaleFactor(1136, 640); UIPackage.AddPackage("UI/JoystickDemo"); _mainView = UIPackage.CreateObject("Demo", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _joystick = new JoystickModule(_mainView); _joystick.onMove.Add(__joystickMove); _joystick.onEnd.Add(__joystickEnd); _npc = GameObject.Find("npc").transform; }
public void Show() { UIPackage.AddPackage("SD/ShuDu"); UIObjectFactory.SetPackageItemExtension(strItemUrl, typeof(ShuItem)); GComponent com = UIManager.inst.CreateObject<GComponent>("ShuDu", "GamePanel"); GRoot.inst.AddChild(com); com.SetSize(GRoot.inst.width, GRoot.inst.height); com.AddRelation(GRoot.inst, RelationType.Size); com.Center(); GList list = com.GetChild("n1").asList; list.RemoveChildrenToPool(); list.defaultItem = strItemUrl; ShuData.inst.InitData(); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9 ; j++) { ShuItem item = list.AddItemFromPool() as ShuItem; item.Init(i, j); } } GRoot.inst.DispatchEvent("ShuUpdate"); list.onClickItem.Add(ItemClick); for(int i = 0; i < 10; i++) { ExchangeRow(Random.Range(0, 9), Random.Range(0, 9)); ExchangeCol(Random.Range(0, 9), Random.Range(0, 9)); } GRoot.inst.DispatchEvent("ShuHide"); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Emoji"); UIConfig.verticalScrollBar = UIPackage.GetItemURL("Emoji", "ScrollBar_VT"); UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto; _mainView = UIPackage.CreateObject("Emoji", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _list = _mainView.GetChild("list").asList; _list.RemoveChildrenToPool(); _input = _mainView.GetChild("input").asTextInput; _input.onKeyDown.Add(__inputKeyDown); _itemURL1 = UIPackage.GetItemURL("Emoji", "chatLeft"); _itemURL2 = UIPackage.GetItemURL("Emoji", "chatRight"); _mainView.GetChild("btnSend").onClick.Add(__clickSendBtn); _mainView.GetChild("btnEmoji").onClick.Add(__clickEmojiBtn); _emojiSelectUI = UIPackage.CreateObject("Emoji", "EmojiSelectUI").asCom; _emojiSelectUI.fairyBatching = true; _emojiSelectUI.GetChild("list").asList.onClickItem.Add(__clickEmoji); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Gesture"); _mainView = UIPackage.CreateObject("Gesture", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); GObject holder = _mainView.GetChild("holder"); _ball = GameObject.Find("Globe").transform; SwipeGesture gesture1 = new SwipeGesture(holder); gesture1.onMove.Add(OnSwipeMove); gesture1.onEnd.Add(OnSwipeEnd); LongPressGesture gesture2 = new LongPressGesture(holder); gesture2.once = false; gesture2.onAction.Add(OnHold); PinchGesture gesture3 = new PinchGesture(holder); gesture3.onAction.Add(OnPinch); RotationGesture gesture4 = new RotationGesture(holder); gesture4.onAction.Add(OnRotate); }
public MainPanel() { _view = UIPackage.CreateObject("Demo", "Demo").asCom; _view.fairyBatching = true;//优化drawcall,可以切换这条语句看效果 _view.SetSize(GRoot.inst.width, GRoot.inst.height); _view.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_view); _backBtn = _view.GetChild("btn_Back"); _backBtn.visible = false; _backBtn.onClick.Add(onClickBack); _demoContainer = _view.GetChild("container").asCom; _cc = _view.GetController("c1"); int cnt = _view.numChildren; for (int i = 0; i < cnt; i++) { GObject obj = _view.GetChildAt(i); if (obj.group != null && obj.group.name == "btns") { obj.onClick.Add(runDemo); } } _demoObjects = new Dictionary <string, GComponent>(); }
// Use this for initialization void Start() { UIConfig.defaultFont = "afont"; GRoot.inst.SetContentScaleFactor(1152, 648); UIPackage.AddPackage("UI/Common"); UIPackage.AddPackage("UI/DengLu"); UIPackage.AddPackage("UI/Main"); UIPackage.AddPackage("UI/DengLu"); GComponent mainView = UIPackage.CreateObject("DengLu", "Main").asCom; mainView.SetSize(GRoot.inst.width, GRoot.inst.height); mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(mainView); GComponent mainCom = new GComponent(); GComponent n8 = mainCom.GetChild("n8").asCom; GObject n9 = n8.GetChild("n9").asLabel; n9.onClick.Add(Click); //UIObjectFactory.SetLoaderExtension() }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Guide"); _mainView = UIPackage.CreateObject("Guide", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _guideLayer = UIPackage.CreateObject("Guide", "GuideLayer").asCom; _guideLayer.SetSize(GRoot.inst.width, GRoot.inst.height); _guideLayer.AddRelation(GRoot.inst, RelationType.Size); GObject bagBtn = _mainView.GetChild("bagBtn"); bagBtn.onClick.Add(() => { _guideLayer.RemoveFromParent(); }); _mainView.GetChild("n2").onClick.Add(() => { Rect rect = bagBtn.LocalToGlobal(new Rect(0, 0, bagBtn.width, bagBtn.height)); GRoot.inst.AddChild(_guideLayer); //!!Before using GlobalToLocal, the object must be added first rect = bagBtn.TransformRect(new Rect(0, 0, bagBtn.width, bagBtn.height), _guideLayer); GObject window = _guideLayer.GetChild("window"); window.size = new Vector2((int)rect.size.x, (int)rect.size.y); window.TweenMove(new Vector2((int)rect.position.x, (int)rect.position.y), 0.5f); }); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Transition"); _mainView = UIPackage.CreateObject("Transition", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _btnGroup = _mainView.GetChild("g0").asGroup; _g1 = UIPackage.CreateObject("Transition", "BOSS").asCom; _g2 = UIPackage.CreateObject("Transition", "BOSS_SKILL").asCom; _g3 = UIPackage.CreateObject("Transition", "TRAP").asCom; _g4 = UIPackage.CreateObject("Transition", "GoodHit").asCom; _g5 = UIPackage.CreateObject("Transition", "PowerUp").asCom; _g5.GetTransition("t0").SetHook("play_num_now", __playNum); _mainView.GetChild("btn0").onClick.Add(() => { __play(_g1); }); _mainView.GetChild("btn1").onClick.Add(() => { __play(_g2); }); _mainView.GetChild("btn2").onClick.Add(() => { __play(_g3); }); _mainView.GetChild("btn3").onClick.Add(__play4); _mainView.GetChild("btn4").onClick.Add(__play5); }
public void ForceUpdataCheckUI() { loadingView = UIPackage.CreateObject("public", "PublicLoadingPop").asCom; loadingView.SetSize(GRoot.inst.width, GRoot.inst.height); loadingView.AddRelation(GRoot.inst, RelationType.Size); loadingView.GetChild("Text").asTextField.text = "正在检查更新"; GRoot.inst.AddChild(loadingView); }
IEnumerator LoadUIPackage() { string url = Application.streamingAssetsPath.Replace("\\", "/") + "/fairygui-examples/bundleusage.ab"; if (Application.platform != RuntimePlatform.Android) { url = "file:///" + url; } #if UNITY_5_4_OR_NEWER #if UNITY_2018_1_OR_NEWER UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url); #else UnityWebRequest www = UnityWebRequest.GetAssetBundle(url); #endif yield return(www.SendWebRequest()); if (!www.isNetworkError && !www.isHttpError) { AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www); #else WWW www = new WWW(url); yield return(www); if (string.IsNullOrEmpty(www.error)) { AssetBundle bundle = www.assetBundle; #endif if (bundle == null) { Debug.LogWarning("Run Window->Build FairyGUI example Bundles first."); yield return(0); } UIPackage.AddPackage(bundle); _mainView = UIPackage.CreateObject("BundleUsage", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _mainView.GetTransition("t0").Play(); } else { Debug.LogError(www.error); } } void OnKeyDown(EventContext context) { if (context.inputEvent.keyCode == KeyCode.Escape) { Application.Quit(); } } }
public void Init() { _sceneLoaderView = UIPackage.CreateObject("CutScene", "CutScene").asCom; _sceneLoaderView.SetSize(GRoot.inst.width, GRoot.inst.height); _sceneLoaderView.AddRelation(GRoot.inst, RelationType.Size); _sceneLevels = new List <GComponent>(); _levelDictionary = new Dictionary <string, int>(); _uiDictionary = new Dictionary <string, int>(); }
public HitTestScene() { UIPackage.AddPackage("UI/HitTest"); _mainView = UIPackage.CreateObject("HitTest", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); AddChild(_mainView); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Emoji"); UIConfig.verticalScrollBar = UIPackage.GetItemURL("Emoji", "ScrollBar_VT"); UIConfig.defaultScrollBarDisplay = ScrollBarDisplayType.Auto; _messages = new List <Message>(); _mainView = UIPackage.CreateObject("Emoji", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _list = _mainView.GetChild("list").asList; _list.SetVirtual(); _list.itemProvider = GetListItemResource; _list.itemRenderer = RenderListItem; _input1 = _mainView.GetChild("input1").asTextInput; _input1.onKeyDown.Add(__inputKeyDown1); _input2 = _mainView.GetChild("input2").asTextInput; _input2.onKeyDown.Add(__inputKeyDown2); //作为demo,这里只添加了部分表情素材 _emojies = new Dictionary <uint, Emoji>(); for (uint i = 0x1f600; i < 0x1f637; i++) { string url = UIPackage.GetItemURL("Emoji", Convert.ToString(i, 16)); if (url != null) { _emojies.Add(i, new Emoji(url)); } } _input2.emojies = _emojies; _mainView.GetChild("btnSend1").onClick.Add(__clickSendBtn1); _mainView.GetChild("btnSend2").onClick.Add(__clickSendBtn2); _mainView.GetChild("btnEmoji1").onClick.Add(__clickEmojiBtn1); _mainView.GetChild("btnEmoji2").onClick.Add(__clickEmojiBtn2); _emojiSelectUI1 = UIPackage.CreateObject("Emoji", "EmojiSelectUI").asCom; _emojiSelectUI1.fairyBatching = true; _emojiSelectUI1.GetChild("list").asList.onClickItem.Add(__clickEmoji1); _emojiSelectUI2 = UIPackage.CreateObject("Emoji", "EmojiSelectUI_ios").asCom; _emojiSelectUI2.fairyBatching = true; _emojiSelectUI2.GetChild("list").asList.onClickItem.Add(__clickEmoji2); }
/// <summary> /// 实现设置列表 /// </summary> private void SubList() { if (list.numChildren > 6) { list.RemoveChildAt(7); } list.AddChild(list_sub); list_sub.AddRelation(list.GetChild("n14"), RelationType.Top_Top); list_sub.AddRelation(list.GetChild("n14"), RelationType.Left_Left); Transition t = list_sub.GetTransition("t0"); t.Play(); list_sub.SetPosition(list.GetChild("n0").asCom.GetChildAt(3).position.x + 120, 92, 0); sub.numItems = 2; sub.GetChildAt(0).icon = UIPackage.GetItemURL("Lobby", "Sethover1"); sub.GetChildAt(0).text = "Volume"; sub.GetChildAt(1).icon = UIPackage.GetItemURL("Lobby", "Sethover2"); sub.GetChildAt(1).text = "Logout"; //监听列表中的按钮 sub.GetChildAt(0).onClick.Add(VolumeAlert); sub.GetChildAt(1).onClick.Add(Logout); }
public BagScene() { UIPackage.AddPackage("UI/Bag"); UIObjectFactory.SetLoaderExtension(typeof(MyGLoader)); _mainView = UIPackage.CreateObject("Bag", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _bagWindow = new BagWindow(); _mainView.GetChild("bagBtn").onClick.Add(() => { _bagWindow.Show(); }); }
public void EngineBuild() { GUIManager.ReferenceAssetBundle(PackageName); ViewComponent = UIPackage.CreateObject(PackageName, UIName).asCom; ViewComponent.fairyBatching = true; ViewComponent.SetSize(GRoot.inst.width, GRoot.inst.height); ViewComponent.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(ViewComponent); OnStart(); }
void Start() { #if UNITY_WEBPLAYER || UNITY_WEBGL || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR CopyPastePatch.Apply(); #endif Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/Basics"); #if UNITY_5 //Use the font names directly UIConfig.defaultFont = "Droid Sans,Droid Sans Fallback,Microsoft YaHei"; #else //Need to put a ttf file into Resources folder. Here is the file name of the ttf file. UIConfig.defaultFont = "afont"; #endif UIConfig.verticalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_VT"); UIConfig.horizontalScrollBar = UIPackage.GetItemURL("Basics", "ScrollBar_HZ"); UIConfig.popupMenu = UIPackage.GetItemURL("Basics", "PopupMenu"); UIConfig.buttonSound = (AudioClip)UIPackage.GetItemAsset("Basics", "click"); _mainView = UIPackage.CreateObject("Basics", "Main").asCom; _mainView.fairyBatching = true; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); _backBtn = _mainView.GetChild("btn_Back"); _backBtn.visible = false; _backBtn.onClick.Add(onClickBack); _demoContainer = _mainView.GetChild("container").asCom; _viewController = _mainView.GetController("c1"); _demoObjects = new Dictionary <string, GComponent>(); int cnt = _mainView.numChildren; for (int i = 0; i < cnt; i++) { GObject obj = _mainView.GetChildAt(i); if (obj.group != null && obj.group.name == "btns") { obj.onClick.Add(runDemo); } } }
public TreeViewScene() { UIPackage.AddPackage("UI/TreeView"); _mainView = UIPackage.CreateObject("TreeView", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); AddChild(_mainView); _folderURL1 = "ui://TreeView/folder_closed"; _folderURL2 = "ui://TreeView/folder_opened"; _fileURL = "ui://TreeView/file"; _treeView = new TreeView(_mainView.GetChild("tree").asList); _treeView.onClickNode.Add(__clickNode); _treeView.treeNodeRender = RenderTreeNode; TreeNode topNode = new TreeNode(true); topNode.data = "I'm a top node"; _treeView.root.AddChild(topNode); for (int i = 0; i < 5; i++) { TreeNode node = new TreeNode(false); node.data = "Hello " + i; topNode.AddChild(node); } TreeNode aFolderNode = new TreeNode(true); aFolderNode.data = "A folder node"; topNode.AddChild(aFolderNode); for (int i = 0; i < 5; i++) { TreeNode node = new TreeNode(false); node.data = "Good " + i; aFolderNode.AddChild(node); } for (int i = 0; i < 3; i++) { TreeNode node = new TreeNode(false); node.data = "World " + i; topNode.AddChild(node); } TreeNode anotherTopNode = new TreeNode(false); anotherTopNode.data = new string[] { "I'm a top node too", "ui://TreeView/heart" }; _treeView.root.AddChild(anotherTopNode); }
public JoystickScene() { UIPackage.AddPackage("UI/Joystick"); _mainView = UIPackage.CreateObject("Joystick", "Main").asCom; _mainView.MakeFullScreen(); _mainView.AddRelation(GRoot.inst, RelationType.Size); AddChild(_mainView); _text = _mainView.GetChild("n9").asTextField; _joystick = new JoystickModule(_mainView); _joystick.onMove.Add(__joystickMove); _joystick.onEnd.Add(__joystickEnd); }
/////////////////////////// /// public static GComponent CreateLayerObject(int sortingOrder, string layerName = null) { var obj = new GComponent(); obj.sortingOrder = sortingOrder; obj.SetSize(GRoot.inst.width, GRoot.inst.height); obj.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(obj); if (!string.IsNullOrEmpty(layerName)) { obj.rootContainer.gameObject.name = layerName; } return(obj); }
void Start() { Application.targetFrameRate = 60; GRoot.inst.SetContentScaleFactor(1136, 640); Stage.inst.onKeyDown.Add(OnKeyDown); UIPackage.AddPackage("UI/HitTest"); _mainView = UIPackage.CreateObject("HitTest", "Main").asCom; _mainView.SetSize(GRoot.inst.width, GRoot.inst.height); _mainView.AddRelation(GRoot.inst, RelationType.Size); GRoot.inst.AddChild(_mainView); cube = GameObject.Find("Cube").transform; Stage.inst.onTouchBegin.Add(OnTouchBegin); }