55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
|
|
public class UIFile : UIBase
|
|
{
|
|
public Button close;
|
|
|
|
public Transform content;
|
|
public VerticalLayoutGroup layoutGroup;
|
|
private void Awake()
|
|
{
|
|
close.onClick.AddListener(() => { UIManager.Instance.DestoryUI(UIType.UIFile); });
|
|
}
|
|
|
|
public void Init(List<FileInfoData> list)
|
|
{
|
|
if (list != null)
|
|
{
|
|
GameObject fileItem = (GameObject)Resources.Load("UIPrefabs/FileItem");
|
|
GameObject questionPrefab = (GameObject)Resources.Load("UIPrefabs/Question");
|
|
GameObject newUI;
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
{
|
|
if (list[i].type == FileType.question)
|
|
{
|
|
newUI = GameObject.Instantiate(questionPrefab, content);
|
|
QuestionItem currentItem = newUI.GetComponent<QuestionItem>();
|
|
currentItem.Init(list[i].question, true, true);
|
|
}
|
|
else
|
|
{
|
|
newUI = GameObject.Instantiate(fileItem, content);
|
|
FileItem item = newUI.GetComponent<FileItem>();
|
|
item.Init(list[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Refrush()
|
|
{
|
|
//layoutGroup.padding = new RectOffset(0, 0, 10, 10);
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(layoutGroup.GetComponent<RectTransform>());
|
|
}
|
|
|
|
|
|
}
|