示例#1
0
    private float _LastScrollRectPos;                       //上次记录的ScrollRectPos的位置

    protected override void OnSafeInit()
    {
        base.OnSafeInit();
        if (_ScrollRect == null)
        {
            _ScrollRect = GetComponent <ScrollRect>();
        }
        _ScrollRectTrans    = _ScrollRect.transform.GetComponent <RectTransform>();
        _Pool               = new GNewPrivatePool <GDragablePageItem>(16);
        _Items              = new List <GDragablePageItem>();
        _IsDraging          = false;
        _IsStopMove         = true;
        _TimeInterval       = 0;
        _TotalTime          = 0;
        _StartMoveTime      = 0;
        _ItemCount          = 0;
        _CurItemIndex       = 0;
        _StartListenTime    = 0;
        _ListenTimeInterval = 0.1f;
        _LastScrollRectPos  = 0;
        _ScrollRect.onValueChanged.AddListener(OnScorllRectChanged);
        GNewUITools.SetVisible(_CellItem, false);
        //测试用
        //SetPageItemCount(6);
        //_TimeInterval = 3;
    }
示例#2
0
    protected virtual GListItem TryCreateItem()
    {
        if (CellTemplate == null)
        {
            return(null);
        }

        GListItem rv = null;

        rv = _CellPool.TakeOut();

        if (rv == null)
        {
            GameObject item    = CUnityUtil.Instantiate(CellTemplate.gameObject) as GameObject;
            GListItem  itemCon = GListItem.Get(item);
            itemCon.RectTrans.SetParent(_Content, false);

            rv = itemCon;

            if (HasChildButton && this.ClickItemButtonCallBack != null)
            {
                itemCon.OnItemClickButton = this.OnClickItemButton;
            }
        }

        GNewUITools.SetVisible(rv.RectTrans, true);

        return(rv);
    }
示例#3
0
文件: Main.cs 项目: frozen4/UnityPlus
 public static void EnableBlockCanvas(bool enabled)
 {
     if (Main.BlockCanvas != null)
     {
         GNewUITools.SetVisible(Main.BlockCanvas, enabled);
     }
 }
示例#4
0
    protected GListItem TryCreateItem()
    {
        GListItem rv = null;

#if IN_GAME
        rv = _Pool.TakeOut();
#endif

        if (rv == null)
        {
            RectTransform item = CUnityUtil.Instantiate(_CellRect) as RectTransform;
            item.SetParent(Trans, false);

            GListItem item_com = item.GetComponent <GListItem>();
            if (item_com == null)
            {
                item_com = item.gameObject.AddComponent <GListItem>();
            }

            //register events
            if (this.InitItemCallBack != null)
            {
                item_com.OnItemInit = this.OnShowItem;
            }

            if (this.ClickItemCallBack != null)
            {
                item_com.OnItemClick = this.OnClickItem;
            }

            //if (this.PressItemCallBack != null)
            //{
            //    item_com.OnItemPointerDown = this.OnPressItem;
            //}

            //if (this.ReleaseItemCallBack != null)
            //{
            //    item_com.OnItemPointerUp = this.OnReleaseItem;
            //}

            if (this.LongPressCallBack != null)
            {
                item_com.OnItemLongPress = this.OnLongPressItem;
            }

            if (HasChildButton && this.ClickItemButtonCallBack != null)
            {
                item_com.OnItemClickButton = this.OnClickItemButton;
            }

            rv = item_com;
        }

        GNewUITools.SetVisible(rv.RectTrans, true);

        return(rv);
    }
示例#5
0
文件: Main.cs 项目: frozen4/UnityPlus
    public static void SetTopPatesVisible(bool enabled)
    {
        //if (TopPateCamera != null)
        //{
        //IsTopPateVisible = is_enable;
        //TopPateCamera.enabled = is_enable;
        //}

        if (TopPateCanvas != null)
        {
            GNewUITools.SetVisible(TopPateCanvas, enabled);
            //TopPateCanvas.localScale = is_enable ? Vector3.one : Vector3.zero;
        }
    }
示例#6
0
 protected void DisPosePageItem(List <GDragablePageItem> items, int index)
 {
     if (items.Count > index)
     {
         GDragablePageItem item = items[index];
         if (item != null)
         {
             if (_Pool.PutIn(item))
             {
                 GNewUITools.SetVisible(item.RectTrans, false);
             }
         }
         items.RemoveAt(index);
     }
 }
示例#7
0
    protected GDragablePageItem CreateItem()
    {
        GDragablePageItem page_item = null;

        page_item = _Pool.TakeOut();

        if (page_item == null)
        {
            RectTransform item = CUnityUtil.Instantiate(_CellItem) as RectTransform;
            item.SetParent(Trans, false);
            Vector2 new_pos = GNewUITools.GetAlignedPivot(NewAlign.Left);
            if (IsVertical)
            {
                new_pos = GNewUITools.GetAlignedPivot(NewAlign.Top);
            }
            item.pivot     = new_pos;
            item.anchorMax = new_pos;
            item.anchorMin = new_pos;

            GDragablePageItem item_com = item.GetComponent <GDragablePageItem>();
            if (item_com == null)
            {
                item_com = item.gameObject.AddComponent <GDragablePageItem>();
            }

            if (this._PageItemInitCallBack != null)
            {
                item_com.OnItemInit = OnInitPageItem;
            }

            if (this._ClickPageItemCallBack != null)
            {
                item_com.OnItemClick = OnClickPageItem;
            }

            if (_HasChildButton && this._ClickPageItemButtonCallBack != null)
            {
                item_com.OnItemClickButton = this.OnClickPageItemButton;
            }

            page_item = item_com;
        }

        GNewUITools.SetVisible(page_item.RectTrans, true);

        return(page_item);
    }
示例#8
0
 protected virtual void DisposeItem(List <GListItem> items, int index)
 {
     if (items.Count > 0)
     {
         GListItem item = items[items.Count - 1];
         if (item != null)
         {
             if (_CellPool.PutIn(item))
             {
                 GNewUITools.SetVisible(item.RectTrans, false);
             }
             else
             {
                 Destroy(item.gameObject);
             }
         }
         items.RemoveAt(index);
     }
 }
示例#9
0
    protected void DisposeItem(List <GListItem> items, int index)
    {
        if (items.Count > index)
        {
            GListItem item = items[index];
            if (item != null)
            {
#if IN_GAME
                if (_Pool.PutIn(item))
                {
                    GNewUITools.SetVisible(item.RectTrans, false);
                }
                else
#endif
                {
                    Destroy(item.gameObject);
                }
            }
            items.RemoveAt(index);
        }
    }
示例#10
0
    protected override void DisposeItem(List <GListItem> items, int index)
    {
        if (items.Count > index)
        {
            GListItem item = items[index];
            if (item != null)
            {
                if (_CellPool.PutIn(item))
                {
                    GNewUITools.SetVisible(item.RectTrans, false);

                    item.RectTrans.SetParent(poolNode, false);
                }
                else
                {
                    Destroy(item.gameObject);
                }
            }
            items.RemoveAt(index);
        }
    }
示例#11
0
    protected override GListItem TryCreateItem()
    {
        if (CellTemplate == null)
        {
            return(null);
        }

        GListItem rv = null;

        rv = _CellPool.TakeOut();

        if (rv == null)
        {
            GameObject item    = CUnityUtil.Instantiate(CellTemplate.gameObject) as GameObject;
            GListItem  itemCon = GListItem.Get(item);
            rv = itemCon;

            if (HasChildButton && ClickItemButtonCallBack != null)
            {
                rv.OnItemClickButton = OnClickItemButton;
            }

            //register events
            if (InitItemCallBack != null)
            {
                rv.OnItemInit = OnShowItem;
            }

            if (ClickItemCallBack != null)
            {
                rv.OnItemClick = OnClickItem;
            }
        }

        rv.RectTrans.SetParent(_Content, false);
        GNewUITools.SetVisible(rv.RectTrans, true);

        return(rv);
    }
示例#12
0
    protected override void OnSafeInit()
    {
        base.OnSafeInit();

        //RectTrans.anchorMax = RectTrans.anchorMin = RectTrans.pivot = Vector2.up;
        if (_CellRect == null)
        {
            if (Trans.childCount > 0)
            {
                _CellRect = Trans.GetChild(0) as RectTransform;
            }

            if (_CellRect == null)
            {
                Debug.Log("<GNewList>: Item template not found!");
            }
        }

        if (_CellRect != null)
        {
            //_cellRect.gameObject.SetActive(false);
            GNewUITools.SetVisible(_CellRect, false);
        }

        if (_NumberOfRow < 1)
        {
            _NumberOfRow = 1;
        }
        if (_NumberOfColumn < 1)
        {
            _NumberOfColumn = 1;
        }

        if (IsAddLayoutElem)
        {
            AddLayoutElem();
        }
    }
示例#13
0
    public void Show(string text, Vector3 uipos, GBMFontAndMotionTextModel config)
    {
        //Debug.LogWarning("Show HUDText " + text + ", " + config.name + ", " + bg_type);

        if (!IsActive())
        {
            gameObject.SetActive(true);
        }


        uipos += new Vector3(config._Offset.x, config._Offset.y, 0);

        RectTrans.localPosition = uipos;
        var fontScale = config._FontScale;

        RectTrans.localScale = Vector3.one * fontScale;
        Label.font           = config._Font;
        //Label.fontSize = config._FontSize;
        Label.text = text;

        if (config._BGType > -1)
        {
            GNewUITools.SetVisible(_NodeBG, true);
            ImageGrpBG.SetImageIndex(config._BGType);
        }
        else
        {
            GNewUITools.SetVisible(_NodeBG, false);
        }

        if (config._MotionList != null)
        {
            for (int i = 0; i < config._MotionList.Count; i++)
            {
                if (config._MotionList[i] == null)
                {
                    continue;
                }

                var motion     = config._MotionList[i];
                var duration   = motion._Duration;
                var dalay      = motion._Delay;
                var motionType = motion.GetMotionType();
                if (motionType == GMotionModel.MotionType.Scale)
                {
                    var model = motion as GMotionScaleModel;
                    RectTrans.DOScale(model._Scale * Vector3.one * fontScale, duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.Linear)
                {
                    var model = motion as GMotionLinearModel;
                    RectTrans.DOMove(model.GetDest(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.Alpha)
                {
                    var model = motion as GMotionAlphaModel;
                    //DOTween.ToAlpha(() => Label.color, x => Label.color = x, model._Alpha, duration)
                    //    .SetDelay(dalay);

                    DOTween.To(() => CanvasGrp.alpha, x => CanvasGrp.alpha = x, model._Alpha, duration)
                    .SetDelay(dalay);
                }
                else if (motionType == GMotionModel.MotionType.Curve)
                {
                    var model = motion as GMotionCurveModel;
                    RectTrans.DOPath(model.GetCurvePath(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
                else if (motionType == GMotionModel.MotionType.ParaCurve)
                {
                    var model = motion as GMotionParaCurveModel;
                    RectTrans.DOPath(model.GetParaCurvePath(transform.position), duration)
                    .SetDelay(dalay)
                    .SetEase(model._EaseType);
                }
            }

            Invoke("OnMotionEnd", MAX_LIFT_TIME);
        }
    }