258 lines
7.6 KiB
C#
258 lines
7.6 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using DG.Tweening;
|
||
using HighlightPlus;
|
||
using Unity.VisualScripting;
|
||
|
||
/// <summary>
|
||
/// 所有的方法脚本
|
||
/// </summary>
|
||
public class Manager : MonoBehaviour
|
||
{
|
||
public static Manager Instance;
|
||
public List<GameObject> ShowPanel; //展示的界面
|
||
|
||
public LookAtCameraName MyLookAtCameraNamel;
|
||
#region 驾驶舱
|
||
[Header("驾驶舱")]
|
||
public List<Toggle> UpAllToggle; //下方toggle
|
||
public GameObject EnterpriseInformation_image; //企业信息图片
|
||
public TextMeshProUGUI EnterpriseInformationName_text; //企业信息名称
|
||
public Image targetImage; // 企业信息替换图片
|
||
public bool isClick; //第一次展示第二次隐藏
|
||
public Button PipelineBtn; //点击展示管道按钮
|
||
public List<GameObject> Pipeline; //展示管道
|
||
public Tween Tween;
|
||
#endregion
|
||
|
||
#region 企业信息管理
|
||
[Header("企业信息管理")]
|
||
public List<Toggle> ScendToggle; //二级菜单可点击toggle
|
||
public GameObject middleTable_Image; //表2-2全厂项目工程类别及产品方案
|
||
public Image tableImage; //中间的表图片
|
||
public TextMeshProUGUI middleTable_Text; //
|
||
public Button ForDetailsBtn; // 企业信息管理企业产品产能的详情按钮
|
||
public bool isForDetails; //判断是否点击了详情按钮
|
||
|
||
public Sprite[] toggleSpr;//下拉
|
||
public List<GameObject> toggleObj;
|
||
public bool isxiala;
|
||
#endregion
|
||
|
||
#region 环保治理现状
|
||
[Header("环保治理现状")]
|
||
public List<Sprite> bookPages = new List<Sprite>(); //台账翻页
|
||
public int currentPage = 1; //当前页数
|
||
public GameObject LedgerObj; //台账界面
|
||
public Button LedgerCloseBtn; //台账关闭按钮
|
||
public Image LedgerImage; //台账image
|
||
public Button[] NextOrPrevBtn; //上一页下一页按钮
|
||
public List<Toggle> HBGLTZToggle; //环保管理台账
|
||
#endregion
|
||
|
||
#region 园区在线检测
|
||
[Header("园区在线检测")]
|
||
public List<Button> YQSPJKBtn; //园区视频监控按钮
|
||
public List<Button> PFJKSPBtn; //排放监视频
|
||
public GameObject GSYQSPJKObj; //公司园区视频监控
|
||
public RawImage GSYQSPJKRawImg;
|
||
public TextMeshProUGUI GSYQSPJKTopText; //公司园区视频监控顶部文字
|
||
|
||
#endregion
|
||
|
||
#region 污染排放管理
|
||
[Header("污染排放管理")]
|
||
public Button[] FSFQBtn; //右侧废水废气按钮
|
||
public GameObject[] FQObj; //高亮废气
|
||
public GameObject FSObj; //高亮废水
|
||
#endregion
|
||
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
Init();
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
currentPage = 1;
|
||
UpDatePageDisplay();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化
|
||
/// </summary>
|
||
public void Init()
|
||
{
|
||
for (int i = 0; i < ShowPanel.Count; i++)
|
||
{
|
||
ShowPanel[i].SetActive(false);
|
||
ShowPanel[i].SetActive(i==0);
|
||
}
|
||
}
|
||
|
||
private void Start()
|
||
{
|
||
UpDatePageDisplay();
|
||
NextOrPrevBtn[0].onClick.AddListener(PrevPage);
|
||
NextOrPrevBtn[1].onClick.AddListener(NextPage);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物体高亮(闪来闪去)
|
||
/// </summary>
|
||
public void ObjOfHiglight(HighlightEffect HighlightObj)
|
||
{
|
||
Tween = DOVirtual.Float(1, 0f, 1f, t =>
|
||
{
|
||
HighlightObj.innerGlow = t;
|
||
HighlightObj.outline = t;
|
||
}).SetLoops(-1, LoopType.Yoyo);
|
||
HighlightObj?.SetHighlighted(true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 弹框
|
||
/// </summary>
|
||
/// <param name="ShowImage">所要展示的页面</param>
|
||
/// <param name="targetImages">中间的画面</param>
|
||
/// <param name="text">上方的标题文字</param>
|
||
/// <param name="path">中间图片的路径</param>
|
||
public void LoadImageFromResources(GameObject ShowImage,Image targetImages,TextMeshProUGUI text,string path)
|
||
{
|
||
ShowImage.SetActive(true);
|
||
Sprite sprite = Resources.Load<Sprite>(path);
|
||
Debug.Log(sprite.name);
|
||
text.text = sprite.name;
|
||
if (sprite != null)
|
||
{
|
||
targetImages.sprite = sprite;
|
||
Debug.Log("Sprite 加载成功!");
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("Sprite 加载失败,请检查路径和文件名");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 监控弹框
|
||
/// </summary>
|
||
/// <param name="ShowImage">所要展示的页面</param>
|
||
/// <param name="targetImages">中间的画面</param>
|
||
/// <param name="text">上方的标题文字</param>
|
||
/// <param name="path">中间图片的路径</param>
|
||
public void LoadRawImageFromResources(GameObject ShowImage,RawImage targetImages,TextMeshProUGUI text,string path)
|
||
{
|
||
ShowImage.SetActive(true);
|
||
Sprite sprite = Resources.Load<Sprite>(path);
|
||
text.text = sprite.name;
|
||
if (sprite != null)
|
||
{
|
||
targetImages.texture = sprite.texture;
|
||
Debug.Log("Sprite 加载成功!");
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("Sprite 加载失败,请检查路径和文件名");
|
||
}
|
||
}
|
||
|
||
# region 台账界面
|
||
/// <summary>
|
||
/// 加载台账界面
|
||
/// </summary>
|
||
/// <param name="ShowImage"></param>
|
||
/// <param name="LedgerImage"></param>
|
||
/// <param name="path"></param>
|
||
public void LoadLedgerFromResources(GameObject ShowImage ,Image LedgerImage ,Button CloesBtn,string path)
|
||
{
|
||
ShowImage.SetActive(true);
|
||
Sprite[] loadedSprites = Resources.LoadAll<Sprite>(path);
|
||
|
||
if (loadedSprites == null || loadedSprites.Length == 0)
|
||
{
|
||
Debug.LogError($"路径 {path} 中未找到任何Sprite文件夹中没图片!");
|
||
ShowImage.SetActive(false);
|
||
return;
|
||
}
|
||
|
||
// 将加载的Sprite直接存入bookPages列表
|
||
bookPages = new List<Sprite>(loadedSprites);
|
||
Debug.Log($"成功将 {bookPages.Count} 个Sprite存入bookPages列表");
|
||
UpDatePageDisplay();
|
||
// 使用第一个Sprite(从bookPages中获取)
|
||
if (bookPages.Count > 0 && bookPages[0] != null)
|
||
{
|
||
LedgerImage.sprite = bookPages[0];
|
||
Debug.Log("从bookPages中获取Sprite成功!");
|
||
}
|
||
|
||
CloesBtn.onClick.RemoveAllListeners();
|
||
CloesBtn.onClick.AddListener(() =>
|
||
{
|
||
bookPages?.Clear();
|
||
ShowImage.SetActive(false);
|
||
Debug.Log("台账面板已关闭,bookPages 列表已清空");
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// 上一页
|
||
/// </summary>
|
||
public void PrevPage()
|
||
{
|
||
Debug.Log("上一页");
|
||
if (currentPage > 1)
|
||
{
|
||
currentPage--;
|
||
UpDatePageDisplay();
|
||
// if (currentPage == 1)
|
||
// {
|
||
// NextOrPrevBtn[0].gameObject.SetActive(false);
|
||
// NextOrPrevBtn[1].gameObject.SetActive(true);
|
||
// }
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 下一页
|
||
/// </summary>
|
||
public void NextPage()
|
||
{
|
||
Debug.Log("下一页");
|
||
if (currentPage < bookPages.Count)
|
||
{
|
||
currentPage++;
|
||
UpDatePageDisplay();
|
||
// if (currentPage == bookPages.Count)
|
||
// {
|
||
// NextOrPrevBtn[0].gameObject.SetActive(true);
|
||
// NextOrPrevBtn[1].gameObject.SetActive(false);
|
||
// }
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 更新页数
|
||
/// </summary>
|
||
public void UpDatePageDisplay()
|
||
{
|
||
Debug.Log(bookPages.Count);
|
||
if (currentPage >= 1 && currentPage <= bookPages.Count)
|
||
{
|
||
LedgerImage.sprite = bookPages[currentPage - 1];
|
||
LedgerImage.gameObject.SetActive(true);
|
||
Debug.Log($"显示第 {currentPage} 页,共 {bookPages.Count} 页");
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("当前文件夹内为空");
|
||
LedgerImage.gameObject.SetActive(false);
|
||
}
|
||
NextOrPrevBtn[0].gameObject.SetActive(currentPage > 1); // 上一页
|
||
NextOrPrevBtn[1].gameObject.SetActive(currentPage < bookPages.Count); // 下一页
|
||
}
|
||
#endregion
|
||
}
|