コード例 #1
0
ファイル: CUIShowCardsPanel.cs プロジェクト: xywv1/ScrollRect
        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
ファイル: CPlayedCardOnDrag.cs プロジェクト: xywv1/ScrollRect
        private GameObject createCard()
        {
            CUIPlayedCharCardWidget charCardWidget = null;

            m_DraggingCard = Instantiate(Resources.Load <GameObject>("Prefab/RoleCard") as GameObject);
            if (m_DraggingCard == null)
            {
                return(null);
            }
            charCardWidget = m_DraggingCard.GetComponent <CUIPlayedCharCardWidget>();

            if (charCardWidget == null)
            {
                return(null);
            }

            m_DraggingCard.transform.parent     = FindInParents <Canvas>(gameObject).transform;
            m_DraggingCard.transform.localScale = Vector3.one;
            CUIPlayedCharCardWidget.CUIContent uiContent = new CUIPlayedCharCardWidget.CUIContent();

            charCardWidget.InitContent(uiContent);
            return(m_DraggingCard);
        }