72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DataModel.Model;
|
|
using System.Linq;
|
|
using LitJson;
|
|
|
|
public class CreateRoomThinkingItem : MonoBehaviour
|
|
{
|
|
thinkingfile thinkingfile1;
|
|
ThinkingData data;
|
|
List<CreateRoomSubjectItem> subjectitems1 = new List<CreateRoomSubjectItem>();
|
|
|
|
public Button self;
|
|
public Text Name;
|
|
public void Init(thinkingfile thinkingfile)
|
|
{
|
|
thinkingfile1 = thinkingfile;
|
|
Name.text = thinkingfile.Name;
|
|
|
|
//创建科目item
|
|
CreateSubjectitem();
|
|
|
|
self.onClick.AddListener(()=>
|
|
{
|
|
Chose();
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创新建科目item
|
|
/// </summary>
|
|
private void CreateSubjectitem()
|
|
{
|
|
ThinkingData data =JsonMapper.ToObject<ThinkingData>(thinkingfile1.VirtualPath);
|
|
int index = 0;
|
|
data.subjectsInfo.ForEach(a =>
|
|
{
|
|
GameObject obj = Instantiate<GameObject>(CreateRoomPanel.instance.选择想定subjectItemPrefb, CreateRoomPanel.instance.group2_2.transform);
|
|
CreateRoomSubjectItem script= obj.GetComponent<CreateRoomSubjectItem>();
|
|
script.Init(a, index);
|
|
index++;
|
|
subjectitems1.Add(script);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择
|
|
/// </summary>
|
|
public void Chose()
|
|
{
|
|
//选中
|
|
CreateRoomPanel.instance.choseThinkingfile = thinkingfile1;
|
|
|
|
//显示想定信息
|
|
CreateRoomPanel.instance.thinkingName.text = thinkingfile1.Name;
|
|
CreateRoomPanel.instance.thinkingMode.text = thinkingfile1.PracticeMode;
|
|
CreateRoomPanel.instance.group2_2.transform.GetComponentsInChildren<CreateRoomSubjectItem>(true).ToList().ForEach(a =>
|
|
{
|
|
if (subjectitems1.Contains(a))
|
|
{
|
|
a.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
a.gameObject.SetActive(false);
|
|
}
|
|
});
|
|
}
|
|
}
|