Пример #1
0
        private void _createRoleCard(CLocalCharInfo roleInfo, int index)
        {
            CUIPlayedCharCardWidget charCardWidget = null;

            if (CardsList.Count > index)
            {
                charCardWidget = CardsList[index];
            }
            else
            {
                var obj = Instantiate(Resources.Load <GameObject>("Prefab/RoleCard")) as GameObject;
                if (obj == null)
                {
                    UnityEngine.Debug.LogError("有误");
                    return;
                }
                obj.name = roleInfo.Name;

                charCardWidget = obj.GetComponent <CUIPlayedCharCardWidget>();

                if (charCardWidget == null)
                {
                    UnityEngine.Debug.LogError("有误");
                    return;
                }
                obj.transform.parent     = Obj_ScrollViewContent.transform;
                obj.transform.localScale = Vector3.one;
                CardsList.Add(charCardWidget);
            }

            CUIPlayedCharCardWidget.CUIContent uiContent = new CUIPlayedCharCardWidget.CUIContent();
            uiContent.RoleInfo      = roleInfo;
            uiContent.ScrollRectObj = m_ScrollRect;
            uiContent.FixGridRect   = m_FixGrid;
            uiContent.BeginDrag     = () =>
            {
                m_currentDrapChar = roleInfo;
                m_beginDrag       = true;
                charCardWidget.SetState(false);
            };
            uiContent.BeginScroll = () =>
            {
                //CCommonUtility.SetActive(Obj_LeftOverLap, false);
                //CCommonUtility.SetActive(Obj_RightOverLap, false);
            };
            uiContent.EndDrag = () =>
            {
                m_currentDrapChar = null;
                m_beginDrag       = false;
                charCardWidget.SetState(true);
            };
            uiContent.EndScroll = () =>
            {
                //if (!m_canShowOverLap)
                //	return;
                //CCommonUtility.SetActive(Obj_LeftOverLap, m_ScrollRect.horizontalNormalizedPosition > 0.082);
                //CCommonUtility.SetActive(Obj_RightOverLap, m_ScrollRect.horizontalNormalizedPosition < 0.98);
            };
            charCardWidget.InitContent(uiContent);
        }
Пример #2
0
 public void Init(CLocalCharInfo roleInfo, System.Action beginCallBack = null, System.Action endCallBack = null, System.Action beginScroll = null, System.Action endScroll = null)
 {
     m_OnBeginDragCallBack = beginCallBack;
     m_OnEndDragCallBack   = endCallBack;
     m_OnBeginScroll       = beginScroll;
     m_OnEndScroll         = endScroll;
 }