override protected void ConstructExtension(ByteBuffer buffer) { buffer.Seek(0, 6); _buttonController = GetController("button"); _titleObject = GetChild("title"); _iconObject = GetChild("icon"); string str = buffer.ReadS(); if (str != null) { 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); dropdown.SetHome(this); } displayObject.onRollOver.Add(__rollover); displayObject.onRollOut.Add(__rollout); displayObject.onTouchBegin.Add(__touchBegin); displayObject.onTouchEnd.Add(__touchEnd); }
override public 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); }
void Create(string resourceURL) { if (resourceURL == null) { resourceURL = UIConfig.popupMenu; if (resourceURL == null) { Debug.LogError("FairyGUI: UIConfig.popupMenu not defined"); return; } } _contentPane = UIPackage.CreateObjectFromURL(resourceURL).asCom; _contentPane.onAddedToStage.Add(__addedToStage); _list = _contentPane.GetChild("list").asList; _list.RemoveChildrenToPool(); _list.AddRelation(_contentPane, RelationType.Width); _list.RemoveRelation(_contentPane, RelationType.Height); _contentPane.AddRelation(_list, RelationType.Height); _list.onClickItem.Add(__clickItem); }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <returns></returns> public GObject GetObject(string url) { url = UIPackage.NormalizeURL(url); Queue <GObject> arr; if (_pool.TryGetValue(url, out arr) && arr.Count > 0) { return(arr.Dequeue()); } GObject obj = UIPackage.CreateObjectFromURL(url); if (obj != null) { if (initCallback != null) { initCallback(obj); } } return(obj); }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem = _contentItem.getBranch(); sourceWidth = _contentItem.width; sourceHeight = _contentItem.height; _contentItem = _contentItem.getHighResolution(); _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _content.texture = _contentItem.texture; _content.textureScale = new Vector2(_contentItem.width / (float)sourceWidth, _contentItem.height / (float)sourceHeight); _content.scale9Grid = _contentItem.scale9Grid; _content.scaleByTile = _contentItem.scaleByTile; _content.tileGridIndice = _contentItem.tileGridIndice; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { _content.interval = _contentItem.interval; _content.swing = _contentItem.swing; _content.repeatDelay = _contentItem.repeatDelay; _content.frames = _contentItem.frames; UpdateLayout(); } else if (_contentItem.type == PackageItemType.Component) { GObject obj = UIPackage.CreateObjectFromURL(itemURL); if (obj == null) { SetErrorState(); } else if (!(obj is GComponent)) { obj.Dispose(); SetErrorState(); } else { _content2 = (GComponent)obj; ((Container)displayObject).AddChild(_content2.displayObject); UpdateLayout(); } } else { if (_autoSize) { this.SetSize(_contentItem.width, _contentItem.height); } SetErrorState(); Debug.LogWarning("Unsupported type of GLoader: " + _contentItem.type); } } else { SetErrorState(); } }
protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _content.texture = _contentItem.texture; _content.scale9Grid = _contentItem.scale9Grid; _content.scaleByTile = _contentItem.scaleByTile; _content.tileGridIndice = _contentItem.tileGridIndice; _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; _content.interval = _contentItem.interval; _content.swing = _contentItem.swing; _content.repeatDelay = _contentItem.repeatDelay; _content.SetData(_contentItem.texture, _contentItem.frames, new Rect(0, 0, _contentSourceWidth, _contentSourceHeight)); UpdateLayout(); } else if (_contentItem.type == PackageItemType.Component) { _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; GObject obj = UIPackage.CreateObjectFromURL(itemURL); if (obj == null) { SetErrorState(); } else if (!(obj is GComponent)) { obj.Dispose(); SetErrorState(); } else { _content2 = (GComponent)obj; ((Container)displayObject).AddChild(_content2.displayObject); UpdateLayout(); } } else { if (_autoSize) { this.SetSize(_contentItem.width, _contentItem.height); } SetErrorState(); } } else { SetErrorState(); } }
public ScrollPane(GComponent owner, ScrollType scrollType, Margin margin, Margin scrollBarMargin, ScrollBarDisplayType scrollBarDisplay, int flags) { _throwTween = new ThrowTween(); _owner = owner; _container = _owner.rootContainer; _maskHolder = new Container(); _container.AddChild(_maskHolder); _maskContentHolder = _owner.container; _maskContentHolder.x = 0; _maskContentHolder.y = 0; _maskHolder.AddChild(_maskContentHolder); if (Stage.touchScreen) { _holdArea = 20; } else { _holdArea = 5; } _holdAreaPoint = new Vector2(); _margin = margin; _scrollBarMargin = scrollBarMargin; _bouncebackEffect = UIConfig.defaultScrollBounceEffect; _touchEffect = UIConfig.defaultScrollTouchEffect; _xPerc = 0; _yPerc = 0; _aniFlag = true; _scrollBarVisible = true; _scrollSpeed = UIConfig.defaultScrollSpeed; _mouseWheelSpeed = _scrollSpeed * 2; _displayOnLeft = (flags & 1) != 0; _snapToItem = (flags & 2) != 0; _displayInDemand = (flags & 4) != 0; _scrollType = scrollType; _mouseWheelEnabled = true; if (scrollBarDisplay == ScrollBarDisplayType.Default) { scrollBarDisplay = UIConfig.defaultScrollBarDisplay; } if (scrollBarDisplay != ScrollBarDisplayType.Hidden) { if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical) { if (UIConfig.verticalScrollBar != null) { _vtScrollBar = UIPackage.CreateObjectFromURL(UIConfig.verticalScrollBar) as GScrollBar; if (_vtScrollBar == null) { Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.verticalScrollBar); } else { _vtScrollBar.SetScrollPane(this, true); _container.AddChild(_vtScrollBar.displayObject); } } } if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal) { if (UIConfig.horizontalScrollBar != null) { _hzScrollBar = UIPackage.CreateObjectFromURL(UIConfig.horizontalScrollBar) as GScrollBar; if (_hzScrollBar == null) { Debug.LogError("FairyGUI: cannot create scrollbar from " + UIConfig.horizontalScrollBar); } else { _hzScrollBar.SetScrollPane(this, false); _container.AddChild(_hzScrollBar.displayObject); } } } _scrollBarDisplayAuto = scrollBarDisplay == ScrollBarDisplayType.Auto; if (_scrollBarDisplayAuto) { if (_vtScrollBar != null) { _vtScrollBar.displayObject.visible = false; } if (_hzScrollBar != null) { _hzScrollBar.displayObject.visible = false; } _scrollBarVisible = false; _container.onRollOver.Add(__rollOver); _container.onRollOut.Add(__rollOut); } } else { _mouseWheelEnabled = false; } if (_displayOnLeft && _vtScrollBar != null) { _maskHolder.x = Mathf.FloorToInt((_margin.left + _vtScrollBar.width) * GRoot.contentScaleFactor); } else { _maskHolder.x = Mathf.FloorToInt(_margin.left * GRoot.contentScaleFactor); } _maskHolder.y = Mathf.FloorToInt(_margin.top * GRoot.contentScaleFactor); SetSize(owner.width, owner.height); SetContentSize(owner.Bounds.width, owner.Bounds.height); _container.onMouseWheel.Add(__mouseWheel); _container.onMouseDown.Add(__mouseDown); }