102 lines
3.8 KiB
C#
102 lines
3.8 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>
|
|
private RSData.SubjectInfo subjectInfo = new RSData.SubjectInfo();
|
|
/// <summary>
|
|
/// 房间科目
|
|
/// </summary>
|
|
public List<RSData.SubjectInfo> subjectInfos =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);
|
|
subjectInfo = JsonUtility.FromJson<RSData.SubjectInfo>(data);
|
|
string[] strings =new string[subjectInfo.data.Count];
|
|
for (int i=0;i< subjectInfo.data.Count; i++)
|
|
{
|
|
strings[i] = subjectInfo.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 = subjectInfo.data.FindAll(x => x.PracticeSubjectId == str);
|
|
_currentSubjectInfo.data = _data;
|
|
subjectInfos.Add(_currentSubjectInfo);
|
|
}
|
|
|
|
}));
|
|
}
|
|
|
|
|
|
|
|
// 选项值改变事件
|
|
private void OnDropdownValueChanged(int optionIndex)
|
|
{
|
|
Debug.Log("Dropdown value 1: " + optionIndex);
|
|
DoublePlayMain.instance.doublePlayIntroduceList.IntroduceListShow(dataItem, traininginformation, optionIndex, subjectInfos[optionIndex]);
|
|
DoublePlayMain.instance.doublePlayEvaluatePanel.DoublePlayEvaluatePanelShow(dataItem, traininginformation, optionIndex, subjectInfos[optionIndex]);
|
|
DoublePlayMain.instance.videolistmanager._name = dataItem.Id;
|
|
//DoublePlayMain.instance.videolistmanager.VideoMain();
|
|
}
|
|
|
|
// 单击事件
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
Debug.Log("Dropdown value 2: " + dropdown.value);
|
|
DoublePlayMain.instance.doublePlayIntroduceList.IntroduceListShow(dataItem, traininginformation, dropdown.value, subjectInfos[dropdown.value]);
|
|
DoublePlayMain.instance.doublePlayEvaluatePanel.DoublePlayEvaluatePanelShow(dataItem, traininginformation, dropdown.value, subjectInfos[dropdown.value]);
|
|
DoublePlayMain.instance.videolistmanager._name = dataItem.Id;
|
|
//DoublePlayMain.instance.videolistmanager.VideoMain();
|
|
}
|
|
}
|