using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace App
{
public class DisplaySwitcher : MonoBehaviour
{
[SerializeField] Dropdown _dropdown;
List<DisplayInfo> _infoList;
void Start()
{
if (_dropdown == null) _dropdown = GetComponent<Dropdown>();
_infoList = DisplayInfo.GetDisplayList();
List<string> nameList = new List<string>();
int len = _infoList.Count;
for(int i=0; i<len; i++)
{
nameList.Add(_infoList[i].DeviceName);
}
_dropdown.ClearOptions();
_dropdown.AddOptions(nameList);
_dropdown.onValueChanged.AddListener(OnChange);
}
void OnChange(int index)
{
DisplayInfo disp = _infoList[index];
string windowName = WindowManager.GetCurrentWindowTitle();
WindowControl.SetPosition(windowName, disp.ScreenX, disp.ScreenY, disp.ScreenWidth, disp.ScreenHeight, false);
}
}
}