private void Start()
        {
            m_list = new List <ListItemData>();

            for (int i = 0; i < 1000; i++)
            {
                var charaIndex      = Random.Range(0, m_charaList.Length);
                var textIndex       = Random.Range(0, m_textList.Length);
                var imageIndex      = Random.Range(0, m_imageSpriteNameList.Length);
                var charaData       = m_charaList[charaIndex];
                var text            = m_textList[textIndex];
                var imageSpriteName = m_imageSpriteNameList[imageIndex];
                var isMessage       = Random.Range(0, 5) != 0;

                var data = new ListItemData
                           (
                    charaData: charaData,
                    message: isMessage ? text : null,
                    imageSpriteName: isMessage ? null : imageSpriteName
                           );

                m_list.Add(data);
            }

            m_view.InitListView(m_list.Count, OnUpdate);
        }
Esempio n. 2
0
        public void SetDisp(ListItemData data, ListItemData prevData)
        {
            var charaData     = data.CharaData;
            var isMessage     = data.IsMessage;
            var prevCharaData = prevData != null ? prevData.CharaData : m_dummyCharaData;
            var isSameChara   = charaData.Id == prevCharaData.Id;

            m_iconUI.gameObject.SetActive(!isSameChara);
            m_iconUI.sprite = Resources.Load <Sprite>(charaData.IconSpriteName);
            m_arrowUI.gameObject.SetActive(isMessage);
            m_frameRectUI.gameObject.SetActive(isMessage);
            m_textUI.gameObject.SetActive(isMessage);
            m_textUI.text = data.Message;
            m_textFitterUI.SetLayoutVertical();
            m_imageUI.gameObject.SetActive(!isMessage);
            m_imageUI.sprite = Resources.Load <Sprite>(data.ImageSpriteName);

            var contentSize = isMessage
                                ? m_textRectUI.sizeDelta
                                : m_imageRectUI.sizeDelta
            ;

            var frameSize = contentSize + new Vector2(20, 20);
            var color     = charaData.Id == 0
                                ? new Color32(255, 255, 255, 255)
                                : new Color32(160, 231, 90, 255);

            ;

            m_frameRectUI.sizeDelta = frameSize;
            m_frameUI.color         = color;
            m_arrowUI.color         = color;

            var y = Mathf.Max(frameSize.y, 75);

            m_rootUI.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y);
        }