liuzhiwei
2020-11-10 231e2ff02a5b95f95256f41b87bddaa28c300fd2
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
using UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
 
namespace EnhancedScrollerDemos.SnappingDemo
{
    public class SlotCellView : EnhancedScrollerCellView
    {
        /// <summary>
        /// These are the UI elements that will be updated when the data changes
        /// </summary>
        public Image slotImage;
 
        /// <summary>
        /// This function sets up the data for the cell view
        /// </summary>
        /// <param name="data">The data to use</param>
        public void SetData(SlotData data)
        {
            // update the cell view's UI
            if (data.sprite == null)
            {
                // this is a blank slot, so set the background color to no alpha
                slotImage.color = new Color(0, 0, 0, 0);
            }
            else
            {
                // this slot has an image so set its sprite
                slotImage.sprite = data.sprite;
                slotImage.color = Color.white;
            }
        }
    }
}