Exemplo n.º 1
0
    /*private void WrapContent ()
     * {
     *      Vector3[] conner_Local = new Vector3[4];
     *      for (int i = 0; i < 4; i++) {
     *              conner_Local [i] = transform.InverseTransformPoint (conners [i]);
     *              Debug.Log ("conner_Local[i]: " + conner_Local [i]);
     *      }
     * Vector3 lastItemPos = _listItem.Count > 0 ? _listItem[_listItem.Count - 1].transform.localPosition : Vector3.zero;
     * Debug.Log("lastItemPos.y <= conner_Local[0].y : " + lastItemPos.y + "conner_Local[0].y" + conner_Local[0].y);
     * Debug.Log("itemTypeStart: " + itemTypeStart);
     * if (lastItemPos.y <= conner_Local[0].y || _listItem.Count == 0)
     * {
     *  ChatContentIndexCallback temp = CreateItem(itemTypeStart);
     *  temp.transform.SetAsFirstSibling();
     *  itemTypeStart--;
     *  _listItem.Add(temp);
     * }
     * }*/
    // Update is called once per frame
    void Update()
    {
        //if (_listItem.Count > 0) {
        //GameObject obj = _listItem[]
        //Debug.Log(_scrollRect.content.sizeDelta.y);
        if (_chatStateType == ChatStateType.initItem)
        {
            if (itemTypeStart > 0)
            {
                Vector3[] conner_Local = new Vector3[4];
                for (int i = 0; i < 4; i++)
                {
                    conner_Local[i] = itemParent.InverseTransformPoint(conners[i]);
                    //Debug.Log ("conner_Local[i]: " + conner_Local [i]);
                }
                //Vector3 center = (conner_Local [0] + conner_Local [3]) / 2;//计算此时中心点的坐标
                Vector3 lastItemPos = _listItem.Count > 0 ? _listItem [_listItem.Count - 1].transform.localPosition : Vector3.zero;
                //Debug.Log("lastItemPos.y <= conner_Local[0].y : " + lastItemPos.y + "conner_Local[0].y" + conner_Local[0].y);
//Debug.Log("itemTypeStart: "+itemTypeStart);
                if (lastItemPos.y <= conner_Local[0].y || _listItem.Count == 0)
                {
                    ChatContentIndexCallback temp = CreateItem(itemTypeStart);
                    temp.transform.SetAsFirstSibling();
                    itemTypeStart--;
                    _listItem.Add(temp);
                }
                else
                {
                    startPostion   = _scrollRect.content.position;
                    _chatStateType = ChatStateType.empty;
                }
            }
            else
            {
                _chatStateType = ChatStateType.empty;
            }
        }
        else if (_chatStateType == ChatStateType.BotttomToTop)
        {
            //Debug.Log("itemTypeEnd: " + itemTypeEnd + "totalCount: " + totalCount);
            MoveBotttomToTop();
        }
        else if (_chatStateType == ChatStateType.TopToBottom)
        {
            //Debug.Log("itemTypeStart: "+itemTypeStart);
            MoveTopToBottom();
        }
        //startPostion = _scrollRect.content.anchoredPosition;
    }
Exemplo n.º 2
0
    public void SetChatCount(int count)
    {
        if (_verLayoutGroup == null)
        {
            totalCount = count;
            return;
        }

        _verLayoutGroup.padding.bottom = 0;
        Recycle();
        totalCount     = count;
        itemTypeEnd    = totalCount;
        itemTypeStart  = itemTypeEnd;
        _chatStateType = ChatStateType.initItem;

        //_verLayoutGroup.padding.bottom = (int)_scrollRect.GetComponent<RectTransform>().sizeDelta.y;
    }
Exemplo n.º 3
0
 void OnValueChanged(Vector2 vec)
 {
     //	return;
     if (vec != Vector2.zero)
     {
         Vector3 currentPos = _scrollRect.content.position;
         Vector3 temp       = currentPos - startPostion;
         //Debug.Log ("temp: " + temp);
         //float offest = currentPos.y - startPostion.y;
         if ((_chatStateType == ChatStateType.empty || _chatStateType == ChatStateType.BotttomToTop) && temp.y < 0)
         {
             _chatStateType = ChatStateType.TopToBottom;
             //_scrollRect.content.pivot = new Vector2(0.5f,0);
         }
         else if ((_chatStateType == ChatStateType.empty || _chatStateType == ChatStateType.TopToBottom) && temp.y > 0)
         {
             _chatStateType = ChatStateType.BotttomToTop;
             //_scrollRect.content.pivot = new Vector2(0.5f,1);
         }
         startPostion = _scrollRect.content.position;
         //Debug.Log("currentPos: "+currentPos+"startPosition: "+startPostion+"offest: "+offest);
         //Debug.Log ("_chatStateType: " + _chatStateType);
     }
 }