Наследование: DisplayObject
Пример #1
0
        public void EnterClipping(Container container)
        {
            _clipStack.Push(clipInfo);

            Rect rect = container.GetWorldClipRect();
            if (clipped)
                rect = ToolSet.Intersection(ref clipInfo.rect, ref rect);
            clipped = true;

            clipInfo.rect = rect;
            rect.x = rect.x + rect.width / 2f;
            rect.y = rect.y + rect.height / 2f;
            rect.width /= 2f;
            rect.height /= 2f;
            if (rect.width == 0 || rect.height == 0)
            {
                clipInfo.offset = new Vector2(-2, -2);
                clipInfo.scale = new Vector2(0, 0);
            }
            else
            {
                clipInfo.offset = new Vector2(-rect.x / rect.width, -rect.y / rect.height);
                clipInfo.scale = new Vector2(1.0f / rect.width, 1.0f / rect.height);
            }

            clipInfo.clipId = container.internalIndex;

            clipInfo.soft = container.clipSoftness != null;
            if (clipInfo.soft)
            {
                clipInfo.softness = (Vector4)container.clipSoftness;
                float vx = clipInfo.rect.width * Stage.inst.stageHeight * 0.25f;
                float vy = clipInfo.rect.height * Stage.inst.stageHeight * 0.25f;

                if (clipInfo.softness.x > 0)
                    clipInfo.softness.x = vx / clipInfo.softness.x;
                else
                    clipInfo.softness.x = 10000f;

                if (clipInfo.softness.y > 0)
                    clipInfo.softness.y = vy / clipInfo.softness.y;
                else
                    clipInfo.softness.y = 10000f;

                if (clipInfo.softness.z > 0)
                    clipInfo.softness.z = vx / clipInfo.softness.z;
                else
                    clipInfo.softness.z = 10000f;

                if (clipInfo.softness.w > 0)
                    clipInfo.softness.w = vy / clipInfo.softness.w;
                else
                    clipInfo.softness.w = 10000f;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="container"></param>
        /// <param name="localPoint"></param>
        /// <returns></returns>
        public virtual bool HitTest(Container container, ref Vector2 localPoint)
        {
            Camera camera = container.GetRenderCamera();
            RaycastHit hit;
            if (!HitTestContext.GetRaycastHitFromCache(camera, out hit))
                return false;

            if (hit.collider != collider)
                return false;

            localPoint = container.GetHitTestLocalPoint();
            return true;
        }
 static public int set_hitArea(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         FairyGUI.IHitTest  v;
         checkType(l, 2, out v);
         self.hitArea = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Update(IntPtr l)
 {
     try {
         FairyGUI.Container     self = (FairyGUI.Container)checkSelf(l);
         FairyGUI.UpdateContext a1;
         checkType(l, 2, out a1);
         self.Update(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_renderCamera(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         UnityEngine.Camera v;
         checkType(l, 2, out v);
         self.renderCamera = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int SetChildrenLayer(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         System.Int32       a1;
         checkType(l, 2, out a1);
         self.SetChildrenLayer(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int InvalidateBatchingState(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         System.Boolean     a1;
         checkType(l, 2, out a1);
         self.InvalidateBatchingState(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #8
0
 static int Dispose(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         obj.Dispose();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static public int set_clipRect(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         UnityEngine.Rect   v;
         checkValueType(l, 2, out v);
         self.clipRect = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_touchChildren(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         System.Boolean     v;
         checkType(l, 2, out v);
         self.touchChildren = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #11
0
 static int InvalidateBatchingState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
         obj.InvalidateBatchingState(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #12
0
 static public int GetChildAt(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         System.Int32       a1;
         checkType(l, 2, out a1);
         var ret = self.GetChildAt(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #13
0
 static public int Contains(IntPtr l)
 {
     try {
         FairyGUI.Container     self = (FairyGUI.Container)checkSelf(l);
         FairyGUI.DisplayObject a1;
         checkType(l, 2, out a1);
         var ret = self.Contains(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #14
0
 static int Contains(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         FairyGUI.DisplayObject arg0 = (FairyGUI.DisplayObject)ToLua.CheckObject(L, 2, typeof(FairyGUI.DisplayObject));
         bool o = obj.Contains(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #15
0
 static int GetChild(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         FairyGUI.Container     obj  = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         string                 arg0 = ToLua.CheckString(L, 2);
         FairyGUI.DisplayObject o    = obj.GetChild(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #16
0
 static public int ChangeChildrenOrder(IntPtr l)
 {
     try {
         FairyGUI.Container self = (FairyGUI.Container)checkSelf(l);
         System.Collections.Generic.List <System.Int32> a1;
         checkType(l, 2, out a1);
         System.Collections.Generic.List <FairyGUI.DisplayObject> a2;
         checkType(l, 3, out a2);
         self.ChangeChildrenOrder(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #17
0
 static public int SwapChildren(IntPtr l)
 {
     try {
         FairyGUI.Container     self = (FairyGUI.Container)checkSelf(l);
         FairyGUI.DisplayObject a1;
         checkType(l, 2, out a1);
         FairyGUI.DisplayObject a2;
         checkType(l, 3, out a2);
         self.SwapChildren(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #18
0
 static int SwapChildrenAt(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         FairyGUI.Container obj = (FairyGUI.Container)ToLua.CheckObject(L, 1, typeof(FairyGUI.Container));
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.SwapChildrenAt(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #19
0
        public override bool HitTest(Container container, ref Vector2 localPoint)
        {
            Camera camera = container.GetRenderCamera();

            RaycastHit hit;
            if (!HitTestContext.GetRaycastHitFromCache(camera, out hit))
                return false;

            if (hit.collider != collider)
                return false;

            localPoint = new Vector2(hit.textureCoord.x * this.width, (1 - hit.textureCoord.y) * this.height);
            HitTestContext.direction = Vector3.back;
            HitTestContext.worldPoint = StageCamera.main.ScreenToWorldPoint(new Vector2(localPoint.x, Screen.height - localPoint.y));

            return true;
        }
        public bool HitTest(Container container, ref Vector2 localPoint)
        {
            localPoint = container.GetHitTestLocalPoint();

            int x = Mathf.FloorToInt((localPoint.x / scaleX - offsetX) * _data.scale);
            int y = Mathf.FloorToInt((localPoint.y / scaleY - offsetY) * _data.scale);
            if (x < 0 || y < 0 || x >= _data.pixelWidth)
                return false;

            int pos = y * _data.pixelWidth + x;
            int pos2 = pos / 8;
            int pos3 = pos % 8;

            if (pos2 >= 0 && pos2 < _data.pixels.Length)
                return ((_data.pixels[pos2] >> pos3) & 0x1) > 0;
            else
                return false;
        }
Пример #21
0
        int _virtualListChanged; //1-content changed, 2-size changed

        #endregion Fields

        #region Constructors

        public GList()
            : base()
        {
            _trackBounds = true;
            autoResizeItem = true;
            this.opaque = true;
            scrollItemToViewOnClick = true;

            container = new Container();
            rootContainer.AddChild(container);
            rootContainer.gameObject.name = "GList";

            _pool = new GObjectPool(container.cachedTransform);

            onClickItem = new EventListener(this, "onClickItem");
        }
Пример #22
0
 internal void InternalSetParent(Container value)
 {
     if (parent != value)
     {
         if (value == null && parent._disposed)
             parent = value;
         else
         {
             parent = value;
             UpdateHierarchy();
         }
     }
 }
Пример #23
0
        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);
        }
Пример #24
0
        static void GetChildEventBridges(string strType, Container container, List<EventBridge> bridges)
        {
            EventBridge bridge = container.TryGetEventBridge(strType);
            if (bridge != null)
                bridges.Add(bridge);
            if (container.gOwner != null)
            {
                bridge = container.gOwner.TryGetEventBridge(strType);
                if (bridge != null && !bridge.isEmpty)
                    bridges.Add(bridge);
            }

            int count = container.numChildren;
            for (int i = 0; i < count; ++i)
            {
                DisplayObject obj = container.GetChildAt(i);
                if (obj is Container)
                    GetChildEventBridges(strType, (Container)obj, bridges);
                else
                {
                    bridge = obj.TryGetEventBridge(strType);
                    if (bridge != null && !bridge.isEmpty)
                        bridges.Add(bridge);

                    if (obj.gOwner != null)
                    {
                        bridge = obj.gOwner.TryGetEventBridge(strType);
                        if (bridge != null && !bridge.isEmpty)
                            bridges.Add(bridge);
                    }
                }
            }
        }
Пример #25
0
        protected void SetupOverflow(OverflowType overflow)
        {
            if (overflow == OverflowType.Hidden)
            {
                container = new Container();
                rootContainer.AddChild(container);
                UpdateClipRect();
                container.SetXY(_margin.left, _margin.top);
            }
            else if (_margin.left != 0 || _margin.top != 0)
            {
                container = new Container();
                rootContainer.AddChild(container);

                container.SetXY(_margin.left, _margin.top);
            }

            SetBoundsChangedFlag();
        }
Пример #26
0
        protected void SetupScroll(Margin scrollBarMargin,
            ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags,
            String vtScrollBarRes, String hzScrollBarRes)
        {
            container = new Container();
            rootContainer.AddChild(container);

            scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes);
            UpdateClipRect();
            SetBoundsChangedFlag();
        }
Пример #27
0
        private void CollectChildren(Container initiator)
        {
            int count = _children.Count;
            for (int i = 0; i < count; i++)
            {
                DisplayObject child = _children[i];
                if (child is Container)
                {
                    Container container = (Container)child;
                    container._fBatchingInherited = true;
                    initiator._descendants.Add(container);

                    if (container._clipRect == null)
                    {
                        child.tmpBounds.Set(0, 0, 0, 0);
                        container.CollectChildren(initiator);
                    }
                    else
                    {
                        container.tmpBounds = container.GetClipRect(initiator);
                        container.DoFairyBatching();
                    }
                }
                else
                {
                    child.tmpBounds = child.GetBounds(initiator);
                    initiator._descendants.Add(child);
                }
            }
        }
Пример #28
0
 public bool HitTest(Container container, ref Vector2 localPoint)
 {
     localPoint = container.GetHitTestLocalPoint();
     return rect.Contains(localPoint);
 }
Пример #29
0
 private void CollectChildren(Container initiator)
 {
     int count = _children.Count;
     for (int i = 0; i < count; i++)
     {
         DisplayObject child = _children[i];
         if (child is Container)
         {
             Container container = (Container)child;
             if (container._fBatchingRoot)
             {
                 initiator._descendants.Add(container);
                 container._internal_bounds = container.GetBounds(initiator);
                 if (container._fBatchingRequested)
                     container.DoFairyBatching();
             }
             else
                 container.CollectChildren(initiator);
         }
         else if (child != initiator._mask)
         {
             child._internal_bounds = child.GetBounds(initiator);
             initiator._descendants.Add(child);
         }
     }
 }
Пример #30
0
 protected internal void SetParent(Container value)
 {
     if (parent != value)
     {
         parent = value;
         SetGO_Visible();
     }
 }
Пример #31
0
		/// <summary>
		/// 设置UIPanel/UIPainter等的渲染层次,由UIPanel等内部调用。开发者不需要调用。
		/// </summary>
		/// <param name="target"></param>
		/// <param name="value"></param>
		public void ApplyPanelOrder(Container target)
		{
			int sortingOrder = target._panelOrder;
			int numChildren = Stage.inst.numChildren;
			int i = 0;
			int j;
			int curIndex = -1;
			for (; i < numChildren; i++)
			{
				DisplayObject obj = Stage.inst.GetChildAt(i);
				if (obj == target)
				{
					curIndex = i;
					continue;
				}

				if (obj == GRoot.inst.displayObject)
					j = 1000;
				else if (obj is Container)
					j = ((Container)obj)._panelOrder;
				else
					continue;

				if (sortingOrder <= j)
				{
					if (curIndex != -1)
						Stage.inst.AddChildAt(target, i - 1);
					else
						Stage.inst.AddChildAt(target, i);
					break;
				}
			}
			if (i == numChildren)
				Stage.inst.AddChild(target);
		}
Пример #32
0
        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);
        }
Пример #33
0
 protected override void CreateDisplayObject()
 {
     displayObject = new Container("GLoader");
     displayObject.gOwner = this;
     _content = new MovieClip();
     ((Container)displayObject).AddChild(_content);
     ((Container)displayObject).opaque = true;
 }
Пример #34
0
        protected void SetupOverflowAndScroll(OverflowType overflow, Margin scrollBarMargin,
			ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags)
        {
            if (overflow == OverflowType.Hidden)
            {
                container = new Container();
                rootContainer.AddChild(container);
                UpdateMask();
                container.SetXY(_margin.left * GRoot.contentScaleFactor, _margin.top * GRoot.contentScaleFactor);
            }
            else if (overflow == OverflowType.Scroll)
            {
                container = new Container();
                rootContainer.AddChild(container);

                scrollPane = new ScrollPane(this, scroll, _margin, scrollBarMargin, scrollBarDisplay, flags);
            }
            else if (_margin.left != 0 || _margin.top != 0)
            {
                container = new Container();
                rootContainer.AddChild(container);

                container.SetXY(_margin.left * GRoot.contentScaleFactor, _margin.top * GRoot.contentScaleFactor);
            }

            SetBoundsChangedFlag();
        }
Пример #35
0
        protected void SetupScroll(Margin scrollBarMargin,
            ScrollType scroll, ScrollBarDisplayType scrollBarDisplay, int flags,
            String vtScrollBarRes, String hzScrollBarRes)
        {
            if (rootContainer == container)
            {
                container = new Container();
                rootContainer.AddChild(container);
            }

            scrollPane = new ScrollPane(this, scroll, scrollBarMargin, scrollBarDisplay, flags, vtScrollBarRes, hzScrollBarRes);
        }
Пример #36
0
        protected override void CreateDisplayObject()
        {
            rootContainer = new Container();
            rootContainer.gOwner = this;
            rootContainer.onUpdate = onUpdate;
            container = rootContainer;

            displayObject = rootContainer;
        }
Пример #37
0
        static void GetChildEventListeners(string strType, Container container, List<EventListener> listeners)
        {
            EventListener listener = container.GetEventListener(strType);
            if (listener != null)
                listeners.Add(listener);
            if (container.gOwner != null)
            {
                listener = container.gOwner.GetEventListener(strType);
                if (listener != null && !listener.isEmpty)
                    listeners.Add(listener);
            }

            int count = container.numChildren;
            for (int i = 0; i < count; ++i)
            {
                DisplayObject obj = container.GetChildAt(i);
                if (obj is Container)
                    GetChildEventListeners(strType, (Container)obj, listeners);
                else
                {
                    listener = obj.GetEventListener(strType);
                    if (listener != null && !listener.isEmpty)
                        listeners.Add(listener);

                    if (obj.gOwner != null)
                    {
                        listener = obj.gOwner.GetEventListener(strType);
                        if (listener != null && !listener.isEmpty)
                            listeners.Add(listener);
                    }
                }
            }
        }
Пример #38
0
        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);
        }
 protected internal void SetParent(Container value)
 {
     if (parent != value)
     {
         parent = value;
         UpdateHierarchy();
     }
 }