chenxin
2020-12-21 b966267d0deb508a0764fb13d6cb5bcadbce5e08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
 
namespace EnhancedScrollerDemos.RefreshDemo
{
    /// <summary>
    /// This is the view of our cell which handles how the cell looks.
    /// </summary>
    public class CellView : EnhancedScrollerCellView
    {
        /// <summary>
        /// This is a reference to the cell's underlying data.
        /// We will store it in the SetData method, and use it
        /// in the RefreshCellView method.
        /// </summary>
        private Data _data;
 
        /// <summary>
        /// A reference to the UI Text element to display the cell data
        /// </summary>
        public Text someTextText;
 
        public RectTransform RectTransform
        {
            get
            {
                var rt = gameObject.GetComponent<RectTransform>();
                return rt;
            }
        }
 
        /// <summary>
        /// This function just takes the Demo data and displays it
        /// </summary>
        /// <param name="data"></param>
        public void SetData(Data data)
        {
            // store the data so that it can be used when refreshing
            _data = data;
 
            // update the cell's UI
            RefreshCellView();
        }
 
        public override void RefreshCellView()
        {
            // update the UI text with the cell data
            someTextText.text = _data.someText;
        }
    }
}