93 lines
3.1 KiB
C#
93 lines
3.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using RDate;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using static InterfaceManager;
|
|
/// <summary>
|
|
/// 复盘回放
|
|
/// </summary>
|
|
public class DropdownDouble : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
private Dropdown dropdown;
|
|
|
|
public string Label;
|
|
/// <summary>
|
|
/// 详细数据
|
|
/// </summary>
|
|
public RDate.DataItem dataItem = new RDate.DataItem();
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public Traininginformation traininginformation = new Traininginformation();
|
|
/// <summary>
|
|
/// 房间数据
|
|
/// </summary>
|
|
public RSData.SubjectInfo currentSubjectInfo = new RSData.SubjectInfo();
|
|
public List<RSData.SubjectInfo> currentSubjectInfos =new List<RSData.SubjectInfo>();
|
|
private void Awake()
|
|
{
|
|
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
//Debug.Log(Label.text);
|
|
dropdown = GetComponent<Dropdown>();
|
|
dropdown.onValueChanged.AddListener(OnDropdownValueChanged);
|
|
//dropdown.onPointerClick.AddListener(OnDropdownPointerClick);
|
|
traininginformation = JsonUtility.FromJson<Traininginformation>(dataItem.ThinkingData);
|
|
for(int i=0;i< traininginformation.subjectsInfo.Count; i++)
|
|
{
|
|
dropdown.AddOptions(new List<string> { Label + "_" + traininginformation.subjectsInfo[i].subjectName });
|
|
}
|
|
|
|
string url = Url_QueryPracticeSeat + dataItem.Id;
|
|
Debug.Log(url);
|
|
StartCoroutine(GetString(url, data => {
|
|
Debug.Log(data);
|
|
currentSubjectInfo = JsonUtility.FromJson<RSData.SubjectInfo>(data);
|
|
string[] strings =new string[currentSubjectInfo.data.Count];
|
|
for (int i=0;i< currentSubjectInfo.data.Count; i++)
|
|
{
|
|
strings[i] = currentSubjectInfo.data[i].PracticeSubjectId;
|
|
}
|
|
|
|
HashSet<string> uniqueStrings = new HashSet<string>();
|
|
|
|
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<RSData.SubjectDataItem> _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);
|
|
}
|
|
}
|