private static void InitWindow(Rect rect, string label, int selectedIndex, string[] displayedOptions)
        {
            var dataSource = new AdvancedDropdownSimpleDataSource();

            dataSource.DisplayedOptions = displayedOptions;
            dataSource.SelectedIndex    = selectedIndex;
            dataSource.Label            = label;

            s_Instance.dataSource = dataSource;

            s_Instance.onSelected += (w) =>
            {
                if (s_ParentWindow != null)
                {
                    s_ParentWindow.Repaint();
                }
            };

            s_Instance.Init(rect);
        }
Ejemplo n.º 2
0
        public void Show(Rect rect)
        {
            if (s_Instance != null)
            {
                s_Instance.Close();
                s_Instance = null;
            }

            s_Instance = ScriptableObject.CreateInstance <AdvancedDropdownWindow>();

            var dataSource = new AdvancedDropdownSimpleDataSource();

            dataSource.DisplayedOptions = DisplayedOptions;
            dataSource.SelectedIndex    = SelectedIndex;
            dataSource.Label            = Label;

            s_Instance.dataSource = dataSource;

            s_Instance.onSelected += w => onSelected(w.GetIdOfSelectedItem());

            s_Instance.Init(rect);
        }