84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_StepsPanel : BasePanel
|
|
{
|
|
/// <summary>
|
|
/// 步骤预制体父物体
|
|
/// </summary>
|
|
public RectTransform StepsContent;
|
|
|
|
/// <summary>
|
|
/// 步骤滑动条
|
|
/// </summary>
|
|
public ScrollRect scrollRect;
|
|
|
|
public UI_StepsPanelItem StepsItem;
|
|
|
|
public PptFilesData data = new PptFilesData();
|
|
|
|
public string jsonFileName = "StepsConfig"; // JSON文件名
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
data = JsonManager.LoadData<PptFilesData>(jsonFileName);
|
|
foreach (var pptFile in data.pptFiles)
|
|
{
|
|
if (StepsItem == null || StepsContent == null)
|
|
{
|
|
Debug.LogError("按钮预制体或父对象未设置");
|
|
return;
|
|
}
|
|
|
|
// 实例化按钮
|
|
var item = Instantiate(StepsItem, StepsContent);
|
|
item.Init(pptFile.fileName);
|
|
var buttonText = item.GetComponentInChildren<TextMeshProUGUI>();
|
|
if (buttonText != null)
|
|
{
|
|
buttonText.text = $"{pptFile.fileName}";
|
|
}
|
|
|
|
//if (button == null)
|
|
//{
|
|
// Debug.LogError("预制体上没有Button组件");
|
|
// return;
|
|
//}
|
|
|
|
// 设置按钮文本
|
|
|
|
}
|
|
}
|
|
|
|
public override void ShowMe()
|
|
{
|
|
base.ShowMe();
|
|
}
|
|
|
|
public override void HideMe()
|
|
{
|
|
base.HideMe();
|
|
}
|
|
protected override async void OnClick(string btnName)
|
|
{
|
|
Debug.Log(btnName);
|
|
await LoadPPTTest.RefreshScrollView(StepsContent, scrollRect);
|
|
switch (btnName)
|
|
{
|
|
case "retrun_Btn":
|
|
Bootstrap.Instance.uiManager.ShowPanel<UI_StepsPanel>(this, E_UI_Layer.System, (panel) =>
|
|
{
|
|
Debug.Log("UI_StepsPanel已经显示在" + E_UI_Layer.System);
|
|
Bootstrap.Instance.uiManager.HidePanel<UI_TipsForPracticePanel>();
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|