killapp/Assets/Scripts/UI/Pages/SelfPage/DeviceTeachingPage.cs

49 lines
1.3 KiB
C#
Raw Permalink Normal View History

2026-06-08 08:55:10 +08:00
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;
private void Start() {
Init(null);
}
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);
}
}
}