119 lines
3.2 KiB
C#
119 lines
3.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ClickEventLens : MonoBehaviour
|
|
{
|
|
public List<ClickEventLens> clickEventLens = new List<ClickEventLens>();
|
|
public AutoScaleUI scaleUI;
|
|
public Transform lensUI;
|
|
|
|
public static Transform Camera;
|
|
|
|
public Button button;
|
|
public TextMeshProUGUI text;
|
|
|
|
public Material material;
|
|
public MeshCollider mycollider;
|
|
//该摄像头是否在播放视频
|
|
public bool isplay = false;
|
|
private void Awake()
|
|
{
|
|
mycollider = gameObject.GetComponent<MeshCollider>();
|
|
clickEventLens = GameObject.FindObjectsOfType<ClickEventLens>().ToList();
|
|
lensUI = transform.GetChild(0);
|
|
scaleUI = lensUI.GetComponent<AutoScaleUI>();
|
|
button = scaleUI.button;
|
|
text = scaleUI.text;
|
|
material = GetComponent<Renderer>().materials[0];
|
|
}
|
|
void Start()
|
|
{
|
|
Camera = UnityEngine.Camera.main.transform;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (mycollider)
|
|
{
|
|
if (Menu.M_全景监控_摄像头 == CabinetUIManager.Instance.current_menu)
|
|
mycollider.enabled = true;
|
|
else
|
|
mycollider.enabled = false;
|
|
}
|
|
lensUI.eulerAngles = Camera.eulerAngles;
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
lensUI.gameObject.SetActive(true);
|
|
if (!isplay)
|
|
ChangeMaterialColor(gameObject, 1);
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
lensUI.gameObject.SetActive(false);
|
|
if (!isplay)
|
|
ChangeMaterialColor(gameObject, 99);
|
|
}
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
var t = text.text.Replace("摄像", "");
|
|
//if (BoolMonitor.Value)
|
|
{
|
|
ChangeMaterialColor(gameObject, 4);
|
|
WebInteraction.Inst.current_videoNumber = t;
|
|
WebInteraction.Inst.isVideoPlay = true;
|
|
WebInteraction.Inst.OpenVideo(t);
|
|
|
|
float x = Input.mousePosition.x;
|
|
float y = Screen.height - Input.mousePosition.y;
|
|
|
|
WebInteraction.Inst.SendVideoPosition(x, y);
|
|
}
|
|
}
|
|
|
|
public void ChangeMaterialColor(GameObject go, int index)
|
|
{
|
|
Material material = null;
|
|
|
|
switch (index)
|
|
{
|
|
case 1:
|
|
material = Resources.Load<Material>("Materials/1Tou");
|
|
break;
|
|
case 2:
|
|
material = Resources.Load<Material>("Materials/2Tou");
|
|
break;
|
|
case 3:
|
|
material = Resources.Load<Material>("Materials/3Tou");
|
|
break;
|
|
case 4:
|
|
material = Resources.Load<Material>("Materials/4Tou");
|
|
break;
|
|
default:
|
|
material = this.material;
|
|
break;
|
|
}
|
|
go.GetComponent<Renderer>().material = material;
|
|
}
|
|
|
|
// 闪烁
|
|
public IEnumerator TwinkleLens(float looptime)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
ChangeMaterialColor(gameObject, 1);
|
|
yield return new WaitForSeconds(looptime);
|
|
ChangeMaterialColor(gameObject, 99);
|
|
yield return new WaitForSeconds(looptime);
|
|
}
|
|
}
|
|
}
|