summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/UICommon/XUIPopupList.cs
blob: f78b6c0108671af3ae2e1f11f5647d043171e7e0 (plain)
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
using UILib;
using UnityEngine;
using System.Collections.Generic;

public class XUIPopupList : XUIObject, IXUIPopupList
{
   
    protected override void OnAwake()
    {
		base.OnAwake();
        m_uiPopupList = GetComponent<UIPopupList>();
        if (null == m_uiPopupList)
        {
            Debug.LogError("null == m_uiPopupList");
        }
    }

    public void SetOptionList(List<string> options)
    {
        m_uiPopupList.items = options;
    }

    public string value
    {
        get { return m_uiPopupList.value; }
        set { m_uiPopupList.value = value; }
    }

    public int currentIndex
    {
        get 
        {
            return m_uiPopupList.items.IndexOf(m_uiPopupList.value);
        }
        set
        {
            if(value >= m_uiPopupList.items.Count)
            {
                Debug.LogError("Index out of range. " + value);
                return;
            }
            m_uiPopupList.value = m_uiPopupList.items[value];
        }
    }
    private UIPopupList m_uiPopupList;
}