protected void LoadFromPackage(string itemURL) { _contentItem = UIPackage.GetItemByURL(itemURL); if (_contentItem != null) { _contentItem.Load(); if (_contentItem.type == PackageItemType.Image) { _image.texture = _contentItem.texture; _image.scale9Grid = _contentItem.scale9Grid; _image.scaleByTile = _contentItem.scaleByTile; _activeObject = _image; _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; UpdateLayout(); } else if (_contentItem.type == PackageItemType.MovieClip) { if (_movieClip == null) { _movieClip = new MovieClip(); if (grayed) { _movieClip.SetGrayed(true); } _container.AddChild(_movieClip); } _contentSourceWidth = _contentItem.width; _contentSourceHeight = _contentItem.height; _movieClip.interval = _contentItem.interval; _movieClip.SetData(_contentItem.texture, _contentItem.frames); _movieClip.boundsRect = new Rect(0, 0, _contentSourceWidth, _contentSourceHeight); _movieClip.playing = _playing; _movieClip.currentFrame = _frame; _activeObject = _movieClip; UpdateLayout(); } else { SetErrorState(); } } else { SetErrorState(); } }
override protected void CreateDisplayObject() { _container = new Container("GLoader"); _container.gOwner = this; _container.hitArea = new RectHitTest(); displayObject = _container; _image = new Image(); _container.AddChild(_image); }
override protected void CreateDisplayObject() { _container = new Container(); _container.gOwner = this; _container.hitArea = new Rect(); _container.SetScale(GRoot.contentScaleFactor, GRoot.contentScaleFactor); displayObject = _container; _image = new Image(); _container.AddChild(_image); }
static public int AddChild(IntPtr l) { try { FairyGUI.Container self = (FairyGUI.Container)checkSelf(l); FairyGUI.DisplayObject a1; checkType(l, 2, out a1); var ret = self.AddChild(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int AddChild(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject <FairyGUI.Container>(L, 1); FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject <FairyGUI.DisplayObject>(L, 2); FairyGUI.DisplayObject o = obj.AddChild(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
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); }
public ScrollPane(GComponent owner, ScrollType scrollType, Margin scrollBarMargin, ScrollBarDisplayType scrollBarDisplay, int flags, string vtScrollBarRes, string hzScrollBarRes) { onScroll = new EventListener(this, "onScroll"); _refreshDelegate = Refresh; _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); _scrollBarMargin = scrollBarMargin; _scrollType = scrollType; _scrollSpeed = UIConfig.defaultScrollSpeed; _mouseWheelSpeed = _scrollSpeed * 2; _softnessOnTopOrLeftSide = UIConfig.allowSoftnessOnTopOrLeftSide; _displayOnLeft = (flags & 1) != 0; _snapToItem = (flags & 2) != 0; _displayInDemand = (flags & 4) != 0; _pageMode = (flags & 8) != 0; if ((flags & 16) != 0) _touchEffect = true; else if ((flags & 32) != 0) _touchEffect = false; else _touchEffect = UIConfig.defaultScrollTouchEffect; if ((flags & 64) != 0) _bouncebackEffect = true; else if ((flags & 128) != 0) _bouncebackEffect = false; else _bouncebackEffect = UIConfig.defaultScrollBounceEffect; _xPerc = 0; _yPerc = 0; _aniFlag = true; _scrollBarVisible = true; _mouseWheelEnabled = true; _holdAreaPoint = new Vector2(); _pageSize = Vector2.one; if (scrollBarDisplay == ScrollBarDisplayType.Default) { if (Application.isMobilePlatform) scrollBarDisplay = ScrollBarDisplayType.Auto; else scrollBarDisplay = UIConfig.defaultScrollBarDisplay; } if (scrollBarDisplay != ScrollBarDisplayType.Hidden) { if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Vertical) { string res = string.IsNullOrEmpty(vtScrollBarRes) ? UIConfig.verticalScrollBar : vtScrollBarRes; if (!string.IsNullOrEmpty(res)) { _vtScrollBar = UIPackage.CreateObjectFromURL(res) as GScrollBar; if (_vtScrollBar == null) Debug.LogWarning("FairyGUI: cannot create scrollbar from " + res); else { _vtScrollBar.SetScrollPane(this, true); _container.AddChild(_vtScrollBar.displayObject); } } } if (_scrollType == ScrollType.Both || _scrollType == ScrollType.Horizontal) { string res = string.IsNullOrEmpty(hzScrollBarRes) ? UIConfig.horizontalScrollBar : hzScrollBarRes; if (!string.IsNullOrEmpty(res)) { _hzScrollBar = UIPackage.CreateObjectFromURL(res) as GScrollBar; if (_hzScrollBar == null) Debug.LogWarning("FairyGUI: cannot create scrollbar from " + res); 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; SetSize(owner.width, owner.height); _container.onMouseWheel.Add(__mouseWheel); _container.onTouchBegin.Add(__touchBegin); }
protected override void CreateDisplayObject() { _container = new Container(); _container.gOwner = this; _container.hitArea = new Rect(); _container.SetScale(GRoot.contentScaleFactor, GRoot.contentScaleFactor); displayObject = _container; _image = new Image(); _container.AddChild(_image); }
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); }