killapp/Assets/Scripts/UI/Pages/SelfPage/DeviceTeachingPage.cs
“虞渠成” e4556286ff fix(ui/homepage/设备说明): 调整布局底部边距,移除冗余的Start初始化调用
1.  调整了首页设备说明预制体的m_Bottom布局边距从0改为30,修复布局偏移问题
2.  移除了DeviceTeachingPage中冗余的自动调用Init的Start方法
2026-08-26 09:43:16 +08:00

46 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using Kill.Network;
using Kill.UI.Components;
using UnityEngine;
using UnityEngine.UI;
namespace Kill.UI.Pages
{
public class DeviceTeachingPage : MonoBehaviour
{
public Button back;
Action callback;
public GameObject videoPlane;
public VideoCtrl videoCtrl;
public List<DeviceTeachingVideo> deviceTeachingVideos;
public void Init(Action callback)
{
this.callback=callback;
back.onClick.RemoveAllListeners();
back.onClick.AddListener(Back);
UIManager.Instance.RegisterBackAction(Back);
foreach(DeviceTeachingVideo d in deviceTeachingVideos)
{
d.GetComponent<Button>().onClick.RemoveAllListeners();
d.GetComponent<Button>().onClick.AddListener(()=>{ClickVideo(d.videoUrl);});
}
}
public void ClickVideo(string url)
{
videoPlane.SetActive(true);
videoCtrl.Init(url,null);
}
public void CloseVideo()
{
videoCtrl.Stop();
videoPlane.SetActive(false);
}
public void Back()
{
callback?.Invoke();
Destroy(gameObject);
}
}
}