using System.Collections; using System.Collections.Generic; using System.IO; using TMPro; using UnityEngine; using UnityEngine.UI; public class UI_StepsPanel : BasePanel { /// /// 步骤预制体父物体 /// public RectTransform StepsContent; /// /// 步骤滑动条 /// 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(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(); 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(this, E_UI_Layer.System, (panel) => { Debug.Log("UI_StepsPanel已经显示在" + E_UI_Layer.System); Bootstrap.Instance.uiManager.HidePanel(); }); break; default: break; } } }