using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RDate;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using static InterfaceManager;
///
/// 复盘回放
///
public class DropdownDouble : MonoBehaviour, IPointerClickHandler
{
private Dropdown dropdown;
public string Label;
///
/// 详细数据
///
public RDate.DataItem dataItem = new RDate.DataItem();
///
///
///
public Traininginformation traininginformation = new Traininginformation();
///
/// 房间数据
///
public RSData.SubjectInfo currentSubjectInfo = new RSData.SubjectInfo();
public List currentSubjectInfos =new List();
private void Awake()
{
}
// Start is called before the first frame update
void Start()
{
//Debug.Log(Label.text);
dropdown = GetComponent();
dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
//dropdown.onPointerClick.AddListener(OnDropdownPointerClick);
traininginformation = JsonUtility.FromJson(dataItem.ThinkingData);
for(int i=0;i< traininginformation.subjectsInfo.Count; i++)
{
dropdown.AddOptions(new List { Label + "_" + traininginformation.subjectsInfo[i].subjectName });
}
string url = Url_QueryPracticeSeat + dataItem.Id;
Debug.Log(url);
StartCoroutine(GetString(url, data => {
Debug.Log(data);
currentSubjectInfo = JsonUtility.FromJson(data);
string[] strings =new string[currentSubjectInfo.data.Count];
for (int i=0;i< currentSubjectInfo.data.Count; i++)
{
strings[i] = currentSubjectInfo.data[i].PracticeSubjectId;
}
HashSet uniqueStrings = new HashSet();
foreach (string str in strings)
{
uniqueStrings.Add(str);
}
Debug.Log("不同的字符串数量为:" + uniqueStrings.Count);
foreach (string str in uniqueStrings)
{
Debug.Log(str);
RSData.SubjectInfo _currentSubjectInfo = new RSData.SubjectInfo();
List _data = currentSubjectInfo.data.FindAll(x => x.PracticeSubjectId == str);
_currentSubjectInfo.data = _data;
currentSubjectInfos.Add(_currentSubjectInfo);
}
}));
}
// 选项值改变事件
private void OnDropdownValueChanged(int optionIndex)
{
Debug.Log("Dropdown value 1: " + optionIndex);
DoublePlayMain.instance.doublePlayIntroduceList.IntroduceListShow(dataItem, traininginformation, optionIndex);
}
// 单击事件
public void OnPointerClick(PointerEventData eventData)
{
Debug.Log("Dropdown value 2: " + dropdown.value);
DoublePlayMain.instance.doublePlayIntroduceList.IntroduceListShow(dataItem, traininginformation, dropdown.value);
}
}