void Start() { Application.targetFrameRate = 60; Stage.inst.onKeyDown.Add(OnKeyDown); _mainView = this.GetComponent <UIPanel>().ui; _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 override void HandleControllerChanged(Controller c) { base.HandleControllerChanged(c); if (gearColor.controller == c) gearColor.Apply(); }
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 GameSweet() { _sweet = UIPackage.CreateObject("main", "sweet").asCom; _SweetCon = _sweet.GetController("SweetsType"); _loader = _sweet.GetChild("icon").asLoader; _normalClearTra = _sweet.GetTransition("normal_clear"); _sweet.visible = true; _sweet.onTouchBegin.Set(OnStart); _sweet.onTouchEnd.Set(OnEnd); }
static public int constructor(IntPtr l) { try { FairyGUI.Controller o; o = new FairyGUI.Controller(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_selectedPage(IntPtr l) { try { FairyGUI.Controller self = (FairyGUI.Controller)checkSelf(l); string v; checkType(l, 2, out v); self.selectedPage = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int SetSelectedIndex(IntPtr l) { try { FairyGUI.Controller self = (FairyGUI.Controller)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.SetSelectedIndex(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int Setup(IntPtr l) { try { FairyGUI.Controller self = (FairyGUI.Controller)checkSelf(l); FairyGUI.Utils.XML a1; checkType(l, 2, out a1); self.Setup(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int AddPage(IntPtr l) { try { FairyGUI.Controller self = (FairyGUI.Controller)checkSelf(l); System.String a1; checkType(l, 2, out a1); self.AddPage(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static int ClearPages(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject(L, 1, typeof(FairyGUI.Controller)); obj.ClearPages(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int RunActions(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); obj.RunActions(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
protected override void OnInit() { this.contentPane = UIPackage.CreateObject("Bag", "BagWin").asCom; this.Center(); this.modal = true; _page = this.contentPane.GetController("page"); _list = this.contentPane.GetChild("list").asList; _list.onClickItem.Add(__clickItem); _list.itemRenderer = RenderListItem; _list.scrollPane.onScroll.Add(OnScroll); _list.numItems = 45; }
static int AddController(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject <FairyGUI.GComponent>(L, 1); FairyGUI.Controller arg0 = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 2); obj.AddController(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int GetPageIdByName(IntPtr l) { try { FairyGUI.Controller self = (FairyGUI.Controller)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.GetPageIdByName(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int RemoveController(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent)); FairyGUI.Controller arg0 = (FairyGUI.Controller)ToLua.CheckObject(L, 2, typeof(FairyGUI.Controller)); obj.RemoveController(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int RemovePage(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject(L, 1, typeof(FairyGUI.Controller)); string arg0 = ToLua.CheckString(L, 2); obj.RemovePage(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int HandleControllerChanged(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GComboBox obj = (FairyGUI.GComboBox)ToLua.CheckObject <FairyGUI.GComboBox>(L, 1); FairyGUI.Controller arg0 = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 2); obj.HandleControllerChanged(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int RemovePageAt(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject(L, 1, typeof(FairyGUI.Controller)); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.RemovePageAt(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int Setup(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); FairyGUI.Utils.XML arg0 = (FairyGUI.Utils.XML)ToLua.CheckObject <FairyGUI.Utils.XML>(L, 2); obj.Setup(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetSelectedIndex(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.SetSelectedIndex(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int SetSelectedPage(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); string arg0 = ToLua.CheckString(L, 2); obj.SetSelectedPage(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int HandleControllerChanged(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GButton obj = (FairyGUI.GButton)ToLua.CheckObject(L, 1, typeof(FairyGUI.GButton)); FairyGUI.Controller arg0 = (FairyGUI.Controller)ToLua.CheckObject(L, 2, typeof(FairyGUI.Controller)); obj.HandleControllerChanged(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetController(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject(L, 1, typeof(FairyGUI.GComponent)); string arg0 = ToLua.CheckString(L, 2); FairyGUI.Controller o = obj.GetController(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int HasPage(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); string arg0 = ToLua.CheckString(L, 2); bool o = obj.HasPage(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetPageIdByName(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject(L, 1, typeof(FairyGUI.Controller)); string arg0 = ToLua.CheckString(L, 2); string o = obj.GetPageIdByName(arg0); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int AddPageAt(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); string arg0 = ToLua.CheckString(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); obj.AddPageAt(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetControllerAt(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.GComponent obj = (FairyGUI.GComponent)ToLua.CheckObject <FairyGUI.GComponent>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); FairyGUI.Controller o = obj.GetControllerAt(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int GetPageName(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Controller obj = (FairyGUI.Controller)ToLua.CheckObject <FairyGUI.Controller>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); string o = obj.GetPageName(arg0); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void Setup(XML xml) { string str; _controller = _owner.parent.GetController(xml.GetAttribute("controller")); if (_controller == null) return; Init(); string[] pages = xml.GetAttributeArray("pages"); if (pages != null) { foreach (string s in pages) pageSet.AddById(s); } str = xml.GetAttribute("tween"); if (str != null) tween = true; str = xml.GetAttribute("ease"); if (str != null) easeType = FieldTypes.ParseEaseType(str); str = xml.GetAttribute("duration"); if (str != null) tweenTime = float.Parse(str); str = xml.GetAttribute("values"); string[] values = null; if (str != null) values = str.Split(jointChar1); if (values != null) { for (int i = 0; i < values.Length; i++) { str = values[i]; if (str != "-") AddStatus(pages[i], str); } } str = xml.GetAttribute("default"); if (str != null) AddStatus(null, str); }
static int get_relatedController(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); FairyGUI.GButton obj = (FairyGUI.GButton)o; FairyGUI.Controller ret = obj.relatedController; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index relatedController on a nil value" : e.Message)); } }
static int get_pageController(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); FairyGUI.ScrollPane obj = (FairyGUI.ScrollPane)o; FairyGUI.Controller ret = obj.pageController; ToLua.PushObject(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index pageController on a nil value")); } }
static int set_controller(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); FairyGUI.PageOption obj = (FairyGUI.PageOption)o; FairyGUI.Controller arg0 = (FairyGUI.Controller)ToLua.CheckObject(L, 2, typeof(FairyGUI.Controller)); obj.controller = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index controller on a nil value" : e.Message)); } }
public virtual void HandleControllerChanged(Controller c) { for (int i = 0; i < 8; i++) { GearBase gear = _gears[i]; if (gear != null && gear.controller == c) gear.Apply(); } }
public override void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("ComboBox"); string str; _buttonController = GetController("button"); _titleObject = GetChild("title") as GTextField; str = xml.GetAttribute("dropdown"); if (str != null && str.Length > 0) { dropdown = UIPackage.CreateObjectFromURL(str) as GComponent; if (dropdown == null) { Debug.LogWarning("FairyGUI: " + this.resourceURL + " should be a component."); return; } _list = dropdown.GetChild("list") as GList; if (_list == null) { Debug.LogWarning("FairyGUI: " + this.resourceURL + ": should container a list component named list."); return; } _list.onClickItem.Add(__clickItem); _list.AddRelation(dropdown, RelationType.Width); _list.RemoveRelation(dropdown, RelationType.Height); dropdown.AddRelation(_list, RelationType.Height); dropdown.RemoveRelation(_list, RelationType.Width); } displayObject.onRollOver.Add(__rollover); displayObject.onRollOut.Add(__rollout); displayObject.onTouchBegin.Add(__touchBegin); displayObject.onTouchEnd.Add(__touchEnd); }
public void RemoveController(Controller c) { int index = _controllers.IndexOf(c); if (index == -1) throw new Exception("controller not exists: " + c.name); c.parent = null; _controllers.RemoveAt(index); foreach (GObject child in _children) child.HandleControllerChanged(c); }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); SetSize(sourceWidth, sourceHeight); SetupOverflowAndScroll(overflow, scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; //build real display list foreach (GObject child in _children) { if (child.displayObject != null && child.finalVisible) container.AddChild(child.displayObject); } }
public void ApplyController(Controller c) { foreach (GObject child in _children) child.HandleControllerChanged(c); }
public void Setup(XML xml) { string str; _controller = _owner.parent.GetController(xml.GetAttribute("controller")); if (_controller == null) return; Init(); str = xml.GetAttribute("tween"); if (str != null) tween = true; str = xml.GetAttribute("ease"); if (str != null) easeType = FieldTypes.ParseEaseType(str); str = xml.GetAttribute("duration"); if (str != null) tweenTime = float.Parse(str); str = xml.GetAttribute("delay"); if (str != null) delay = float.Parse(str); if (this is GearDisplay) { string[] pages = xml.GetAttributeArray("pages"); if (pages != null) ((GearDisplay)this).pages = pages; } else { string[] pages = xml.GetAttributeArray("pages"); string[] values = xml.GetAttributeArray("values", '|'); if (pages != null && values != null) { for (int i = 0; i < values.Length; i++) AddStatus(pages[i], values[i]); } str = xml.GetAttribute("default"); if (str != null) AddStatus(null, str); } }
public override void HandleControllerChanged(Controller c) { base.HandleControllerChanged(c); if (_relatedController == c) this.selected = pageOption.id == c.selectedPageId; }
/// <summary> /// Removes a controller from the container. /// </summary> /// <param name="c">Controller object.</param> public void RemoveController(Controller c) { int index = _controllers.IndexOf(c); if (index == -1) throw new Exception("controller not exists: " + c.name); c.parent = null; _controllers.RemoveAt(index); int cnt = _children.Count; for (int i = 0; i < cnt; ++i) { GObject child = _children[i]; child.HandleControllerChanged(c); } }
internal void AdjustRadioGroupDepth(GObject obj, Controller c) { int cnt = _children.Count; int i; GObject child; int myIndex = -1, maxIndex = -1; for (i = 0; i < cnt; i++) { child = _children[i]; if (child == obj) { myIndex = i; } else if ((child is GButton) && ((GButton)child).relatedController == c) { if (i > maxIndex) maxIndex = i; } } if (myIndex < maxIndex) this.SwapChildrenAt(myIndex, maxIndex); }
internal void ApplyController(Controller c) { int cnt = _children.Count; for (int i = 0; i < cnt; ++i) { GObject child = _children[i]; child.HandleControllerChanged(c); } }
public virtual void ConstructFromXML(XML xml) { string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = _packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else SetupOverflow(overflow); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList col = xml.Elements("controller"); Controller controller; foreach (XML cxml in col) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(cxml); } XML listNode = xml.GetNode("displayList"); if (listNode != null) { col = listNode.Elements(); GObject u; foreach (XML cxml in col) { u = ConstructChild(cxml); if (u == null) continue; u.underConstruct = true; u.constructingData = cxml; u.Setup_BeforeAdd(cxml); AddChild(u); } } this.relations.Setup(xml); int cnt = _children.Count; for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.relations.Setup(u.constructingData); } for (int i = 0; i < cnt; i++) { GObject u = _children[i]; u.Setup_AfterAdd(u.constructingData); u.underConstruct = false; u.constructingData = null; } str = xml.GetAttribute("mask"); if (str != null) this.mask = GetChildById(str).displayObject; XMLList transCol = xml.Elements("transition"); foreach (XML cxml in transCol) { Transition trans = new Transition(this); trans.Setup(cxml); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); }
public void AddController(Controller controller) { _controllers.Add(controller); controller.parent = this; ApplyController(controller); }
public virtual void HandleControllerChanged(Controller c) { if (gearDisplay.controller == c) gearDisplay.Apply(); if (gearXY.controller == c) gearXY.Apply(); if (gearSize.controller == c) gearSize.Apply(); if (gearLook.controller == c) gearLook.Apply(); }
public override void ConstructFromXML(XML cxml) { base.ConstructFromXML(cxml); XML xml = cxml.GetNode("Button"); string str; str = xml.GetAttribute("mode"); if (str != null) _mode = FieldTypes.ParseButtonMode(str); else _mode = ButtonMode.Common; str = xml.GetAttribute("sound"); if (str != null) sound = UIPackage.GetItemAssetByURL(str) as AudioClip; str = xml.GetAttribute("volume"); if (str != null) soundVolumeScale = float.Parse(str) / 100f; str = xml.GetAttribute("downEffect"); if (str != null) { _downEffect = str == "dark" ? 1 : (str == "scale" ? 2 : 0); _downEffectValue = xml.GetAttributeFloat("downEffectValue"); } _buttonController = GetController("button"); _titleObject = GetChild("title"); _iconObject = GetChild("icon"); if (_mode == ButtonMode.Common) SetState(UP); displayObject.onRollOver.Add(__rollover); displayObject.onRollOut.Add(__rollout); displayObject.onTouchBegin.Add(__touchBegin); displayObject.onTouchEnd.Add(__touchEnd); displayObject.onRemovedFromStage.Add(__removedFromStage); displayObject.onClick.Add(__click); }
internal void ConstructFromResource(List<GObject> objectPool, int poolIndex) { this.gameObjectName = packageItem.name; XML xml = packageItem.componentData; string str; string[] arr; underConstruct = true; arr = xml.GetAttributeArray("size"); sourceWidth = int.Parse(arr[0]); sourceHeight = int.Parse(arr[1]); initWidth = sourceWidth; initHeight = sourceHeight; SetSize(sourceWidth, sourceHeight); arr = xml.GetAttributeArray("pivot"); if (arr != null) { float f1 = float.Parse(arr[0]); float f2 = float.Parse(arr[1]); this.SetPivot(f1, f2, xml.GetAttributeBool("anchor")); } this.opaque = xml.GetAttributeBool("opaque", true); arr = xml.GetAttributeArray("hitTest"); if (arr != null) { PixelHitTestData hitTestData = packageItem.owner.GetPixelHitTestData(arr[0]); if (hitTestData != null) this.rootContainer.hitArea = new PixelHitTest(hitTestData, int.Parse(arr[1]), int.Parse(arr[2])); } OverflowType overflow; str = xml.GetAttribute("overflow"); if (str != null) overflow = FieldTypes.ParseOverflowType(str); else overflow = OverflowType.Visible; str = xml.GetAttribute("margin"); if (str != null) _margin.Parse(str); if (overflow == OverflowType.Scroll) { ScrollType scroll; str = xml.GetAttribute("scroll"); if (str != null) scroll = FieldTypes.ParseScrollType(str); else scroll = ScrollType.Vertical; ScrollBarDisplayType scrollBarDisplay; str = xml.GetAttribute("scrollBar"); if (str != null) scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str); else scrollBarDisplay = ScrollBarDisplayType.Default; int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags"); Margin scrollBarMargin = new Margin(); str = xml.GetAttribute("scrollBarMargin"); if (str != null) scrollBarMargin.Parse(str); string vtScrollBarRes = null; string hzScrollBarRes = null; arr = xml.GetAttributeArray("scrollBarRes"); if (arr != null) { vtScrollBarRes = arr[0]; hzScrollBarRes = arr[1]; } SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes); } else SetupOverflow(overflow); arr = xml.GetAttributeArray("clipSoftness"); if (arr != null) this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1])); _buildingDisplayList = true; XMLList.Enumerator et = xml.GetEnumerator("controller"); Controller controller; while (et.MoveNext()) { controller = new Controller(); _controllers.Add(controller); controller.parent = this; controller.Setup(et.Current); } GObject child; DisplayListItem[] displayList = packageItem.displayList; int childCount = displayList.Length; for (int i = 0; i < childCount; i++) { DisplayListItem di = displayList[i]; if (objectPool != null) child = objectPool[poolIndex + i]; else if (di.packageItem != null) { di.packageItem.Load(); child = UIObjectFactory.NewObject(di.packageItem); child.packageItem = di.packageItem; child.ConstructFromResource(); } else child = UIObjectFactory.NewObject(di.type); child.underConstruct = true; child.Setup_BeforeAdd(di.desc); child.InternalSetParent(this); _children.Add(child); } this.relations.Setup(xml); for (int i = 0; i < childCount; i++) _children[i].relations.Setup(displayList[i].desc); for (int i = 0; i < childCount; i++) { child = _children[i]; child.Setup_AfterAdd(displayList[i].desc); child.underConstruct = false; if (child.displayObject != null) ToolSet.SetParent(child.displayObject.cachedTransform, this.displayObject.cachedTransform); } str = xml.GetAttribute("mask"); if (str != null) this.mask = GetChildById(str).displayObject; et = xml.GetEnumerator("transition"); while (et.MoveNext()) { Transition trans = new Transition(this); trans.Setup(et.Current); _transitions.Add(trans); } if (_transitions.Count > 0) { this.onAddedToStage.Add(__addedToStage); this.onRemovedFromStage.Add(__removedFromStage); } ApplyAllControllers(); _buildingDisplayList = false; underConstruct = false; BuildNativeDisplayList(); SetBoundsChangedFlag(); ConstructFromXML(xml); }
public override void Setup_AfterAdd(XML cxml) { base.Setup_AfterAdd(cxml); if (_downEffect == 2) this.SetPivot(0.5f, 0.5f); XML xml = cxml.GetNode("Button"); if (xml == null) return; string str; str = xml.GetAttribute("title"); if (str != null) this.title = str; str = xml.GetAttribute("icon"); if (str != null) this.icon = str; str = xml.GetAttribute("selectedTitle"); if (str != null) this.selectedTitle = str; str = xml.GetAttribute("selectedIcon"); if (str != null) this.selectedIcon = str; str = xml.GetAttribute("titleColor"); if (str != null) this.titleColor = ToolSet.ConvertFromHtmlColor(str); str = xml.GetAttribute("controller"); if (str != null) _relatedController = parent.GetController(str); pageOption.id = xml.GetAttribute("page"); this.selected = xml.GetAttributeBool("checked", false); str = xml.GetAttribute("sound"); if (str != null) sound = UIPackage.GetItemAssetByURL(str) as AudioClip; str = xml.GetAttribute("volume"); if (str != null) soundVolumeScale = float.Parse(str) / 100f; }