68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 本地视频告警UI
|
|
/// </summary>
|
|
public class LocalVideoAlarm : CabinetUIBase
|
|
{
|
|
/// <summary>
|
|
/// 摄像头配置
|
|
/// </summary>
|
|
public BaseConf baseConf;
|
|
public LocalVideoAlarmUI localVideoAlarmUI;
|
|
public Transform Camera;
|
|
private void Awake()
|
|
{
|
|
baseConf = transform.parent.GetComponent<ClickEventLens>().baseConf;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
localVideoAlarmUI.preform.GetComponent<LocalVideoAlarmItem>().image_view = LocalVideo.Inst.transform.Find("图片轮播").gameObject;
|
|
Camera = UnityEngine.Camera.main.transform;
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
transform.eulerAngles = Camera.eulerAngles;
|
|
|
|
if (localVideoAlarmUI.Content && localVideoAlarmUI.Content.gameObject.activeSelf)
|
|
{
|
|
// Grid 的高 = 图高 * 行 + 行间距 * (行 - 1)
|
|
var content = localVideoAlarmUI.Content;
|
|
var grid = content.GetComponent<GridLayoutGroup>();
|
|
var x = content.sizeDelta.x;
|
|
var y = grid.cellSize.y * content.childCount;
|
|
content.sizeDelta = new Vector2(x, y);
|
|
}
|
|
}
|
|
|
|
public override void OnMenuChanged(Menu menu)
|
|
{
|
|
EnterTheCameraModule(menu);
|
|
}
|
|
|
|
public void EnterTheCameraModule(Menu menu = Menu.M_全景监控_摄像头)
|
|
{
|
|
base.OnMenuChanged(menu);
|
|
if (menu == Menu.M_全景监控_摄像头 && baseConf.conf1.alarmEntities.Count > 0)
|
|
{
|
|
gameObject.SetActive(true);
|
|
localVideoAlarmUI.LoadShowInfo(baseConf.conf1.alarmEntities.Count);
|
|
}
|
|
else
|
|
{
|
|
if (!gameObject.activeInHierarchy)
|
|
return;
|
|
localVideoAlarmUI.canvas.transform.GetChild(0).gameObject.SetActive(false);
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|