402 lines
14 KiB
C#
402 lines
14 KiB
C#
using HighlightPlus;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ShowGroup : MonoBehaviour
|
|
{
|
|
public static ShowGroup _instance;
|
|
public List<GameObject> 一号生产线;
|
|
public List<GameObject> _空压机房_;
|
|
public List<GameObject> 二号生产线;
|
|
public List<GameObject> 三号生产线;
|
|
public List<GameObject> 破碎系统;
|
|
public List<GameObject> 生料系统;
|
|
public List<GameObject> 回转窑系统;
|
|
public List<GameObject> _回转窑空压机房_;
|
|
public List<GameObject> 煤磨系统;
|
|
public List<GameObject> 水泥磨系统;
|
|
public List<GameObject> 煤;
|
|
|
|
public List<GameObject> 配电室点位;
|
|
public List<GameObject> 水;
|
|
public List<GameObject> 所有配电室;
|
|
public GameObject Parent_配电室点位;
|
|
public GameObject 配电室;
|
|
public GameObject Parent_水;
|
|
void Start()
|
|
{
|
|
_instance = this;
|
|
foreach (Transform item in Parent_配电室点位.transform)
|
|
{
|
|
if (item.gameObject.activeInHierarchy)
|
|
配电室点位.Add(item.gameObject);
|
|
}
|
|
foreach (Transform item in Parent_水.transform)
|
|
{
|
|
if (item.gameObject.activeInHierarchy)
|
|
水.Add(item.gameObject);
|
|
}
|
|
foreach (Transform item in 配电室.transform)
|
|
{
|
|
if (item.gameObject.activeInHierarchy)
|
|
所有配电室.Add(item.gameObject);
|
|
}
|
|
}
|
|
|
|
public void Show(string name)
|
|
{
|
|
if (name.Contains("1号生产线"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 一号生产线.Count; i++)
|
|
{
|
|
一号生产线[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(一号生产线[i], out GameObject tip);
|
|
if (!一号生产线[i].name.Equals("空压机房"))
|
|
{
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 一号生产线[i].name;
|
|
}
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("1号生产线");
|
|
}
|
|
else if (name.Contains("2号生产线"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 二号生产线.Count; i++)
|
|
{
|
|
二号生产线[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(二号生产线[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 二号生产线[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("2号生产线");
|
|
}
|
|
else if (name.Contains("3号生产线"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 三号生产线.Count; i++)
|
|
{
|
|
三号生产线[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(三号生产线[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 三号生产线[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("3号生产线");
|
|
}
|
|
|
|
else if (name.Contains("破碎系统"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 破碎系统.Count; i++)
|
|
{
|
|
破碎系统[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(破碎系统[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 破碎系统[i].name;
|
|
m.Message = 破碎系统[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("破碎系统");
|
|
}
|
|
else if (name.Contains("生料系统"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 生料系统.Count; i++)
|
|
{
|
|
生料系统[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(生料系统[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 生料系统[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("生料系统");
|
|
}
|
|
else if (name.Contains("回转窑系统"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 回转窑系统.Count; i++)
|
|
{
|
|
回转窑系统[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(回转窑系统[i], out GameObject tip);
|
|
if (!回转窑系统[i].name.Equals("回转窑空压机房"))
|
|
{
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 回转窑系统[i].name;
|
|
}
|
|
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("回转窑系统");
|
|
}
|
|
else if (name.Contains("煤磨系统"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 煤磨系统.Count; i++)
|
|
{
|
|
煤磨系统[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(煤磨系统[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 煤磨系统[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("煤磨系统");
|
|
}
|
|
else if (name.Contains("水泥磨系统"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 水泥磨系统.Count; i++)
|
|
{
|
|
水泥磨系统[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(水泥磨系统[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = 水泥磨系统[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("水泥磨系统");
|
|
}
|
|
else if (name.Contains("能源监测_煤"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 煤.Count; i++)
|
|
{
|
|
煤[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(煤[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.煤;
|
|
m.Message = 煤[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("主视角");
|
|
}
|
|
else if (name.Contains("配电室"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 配电室点位.Count; i++)
|
|
{
|
|
ShowTip(配电室点位[i], out GameObject tip);
|
|
AddEventListener(tip.transform, 配电室点位[i]);
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("主视角");
|
|
}
|
|
else if (name.Contains("能源监测_水"))
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < 水.Count; i++)
|
|
{
|
|
ShowTip(水[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.水;
|
|
m.Message = 水[i].name;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Hide();
|
|
CameraTween.instance.MoveCameraToPos("主视角");
|
|
}
|
|
}
|
|
#region 隐藏高亮
|
|
private void Hide()
|
|
{
|
|
ClaerTips();
|
|
for (int i = 0; i < 一号生产线.Count; i++)
|
|
{
|
|
一号生产线[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < _回转窑空压机房_.Count; i++)
|
|
{
|
|
_回转窑空压机房_[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < _空压机房_.Count; i++)
|
|
{
|
|
_空压机房_[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 二号生产线.Count; i++)
|
|
{
|
|
二号生产线[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 三号生产线.Count; i++)
|
|
{
|
|
三号生产线[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 破碎系统.Count; i++)
|
|
{
|
|
破碎系统[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 生料系统.Count; i++)
|
|
{
|
|
生料系统[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 回转窑系统.Count; i++)
|
|
{
|
|
回转窑系统[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 煤磨系统.Count; i++)
|
|
{
|
|
一号生产线[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 水泥磨系统.Count; i++)
|
|
{
|
|
水泥磨系统[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 煤.Count; i++)
|
|
{
|
|
煤[i].GetComponent<HighlightEffect>().highlighted = false;
|
|
}
|
|
for (int i = 0; i < 水.Count; i++)
|
|
{
|
|
}
|
|
for (int i = 0; i < 配电室点位.Count; i++)
|
|
{
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public GameObject PointTipPrefab;
|
|
[Header("生成的标签")]
|
|
public List<GameObject> PointTips;
|
|
/// <summary>
|
|
/// 展示标签,标签内容更新
|
|
/// </summary>
|
|
/// <param name="tf"></param>
|
|
private void ShowTip(GameObject tf, out GameObject tip)
|
|
{
|
|
if (tf.transform.Find("LabelPos"))
|
|
{
|
|
var t = Instantiate(PointTipPrefab, tf.transform.Find("LabelPos"));
|
|
tip = t;
|
|
tf.transform.Find("LabelPos").eulerAngles = Vector3.zero;
|
|
t.GetComponentInChildren<TextMeshProUGUI>().text = tf.name;
|
|
if (tf.name.Equals("回转窑空压机房"))
|
|
{
|
|
t.transform.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < _回转窑空压机房_.Count; i++)
|
|
{
|
|
_回转窑空压机房_[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(_回转窑空压机房_[i], out GameObject tip);
|
|
var m = tip.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = _回转窑空压机房_[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("回转窑空压机房");
|
|
});
|
|
t.transform.Find("video").gameObject.SetActive(true);
|
|
t.transform.Find("video").GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
VideoManager.instance.ShowVideo("空压机动画");
|
|
});
|
|
}
|
|
else if (tf.name.Equals("空压机房"))
|
|
{
|
|
t.transform.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
|
{
|
|
Hide();
|
|
for (int i = 0; i < _空压机房_.Count; i++)
|
|
{
|
|
_空压机房_[i].GetComponent<HighlightEffect>().highlighted = true;
|
|
ShowTip(_空压机房_[i], out GameObject tip1);
|
|
var m = tip1.AddComponent<UITIP>();
|
|
m.type = TipType.电;
|
|
m.Message = _空压机房_[i].name;
|
|
}
|
|
CameraTween.instance.MoveCameraToPos("空压机房");
|
|
});
|
|
}
|
|
PointTips.Add(t);
|
|
}
|
|
else
|
|
{
|
|
var t = Instantiate(PointTipPrefab, tf.transform);
|
|
tip = t;
|
|
t.GetComponentInChildren<TextMeshProUGUI>().text = tf.name;
|
|
if (tf.name.Contains("_"))
|
|
{
|
|
string[] array = tf.name.Split("_");
|
|
t.GetComponentInChildren<TextMeshProUGUI>().text = array[1];
|
|
}
|
|
PointTips.Add(t);
|
|
}
|
|
}
|
|
|
|
|
|
private void AddEventListener(Transform BtnTransform, GameObject g)
|
|
{
|
|
Button btn = BtnTransform.GetComponentInChildren<Button>();
|
|
//string t = "{\"type\": \"Btn\", \"message\": \"" + g.name + "\"}";
|
|
string t = g.name;
|
|
btn.onClick.AddListener(() =>
|
|
{
|
|
for (int i = 0; i < 所有配电室.Count; i++)
|
|
{
|
|
if (所有配电室[i].name == g.name)
|
|
{
|
|
CameraTween.instance.MoveCameraToPos(g.name);
|
|
}
|
|
}
|
|
|
|
BrideWebView.Instance.webViewPrefab.WebView.PostMessage(t);
|
|
Debug.Log("(C#Log)JSON Post:" + t);
|
|
});
|
|
}
|
|
private void ClaerTips()
|
|
{
|
|
for (int i = 0; i < PointTips.Count; i++)
|
|
{
|
|
Destroy(PointTips[i]);
|
|
}
|
|
PointTips.Clear();
|
|
}
|
|
void Update()
|
|
{
|
|
//if (Input.GetKeyDown(KeyCode.Alpha1))
|
|
//{
|
|
// Show("主视角");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha2))
|
|
//{
|
|
// Show("1号生产线");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha3))
|
|
//{
|
|
// Show("2号生产线");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha4))
|
|
//{
|
|
// Show("3号生产线");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha5))
|
|
//{
|
|
// Show("破碎系统");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha6))
|
|
//{
|
|
// Show("生料系统");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha7))
|
|
//{
|
|
// Show("水泥磨系统");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha8))
|
|
//{
|
|
// Show("回转窑系统");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Alpha9))
|
|
//{
|
|
// Show("煤磨系统");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.Keypad0))
|
|
//{
|
|
// Show("煤");
|
|
//}
|
|
}
|
|
}
|
|
|