120 lines
3.3 KiB
C#
120 lines
3.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ToolsPack;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace Views
|
|
{
|
|
public class ThreeTransformerPhotovoltaicView : MonoBehaviour
|
|
{
|
|
public SpriteRenderer spriteRenderer;
|
|
|
|
public TextMesh textMesh;
|
|
|
|
//public string isFD;
|
|
public Sprite[] sprites;
|
|
public List<string> infos = new List<string>();
|
|
public ElectricEnergyMeterData ElectricEnergyMeterData;
|
|
|
|
/// <summary>
|
|
/// 表计信息
|
|
/// </summary>
|
|
//public List<EnergylistItem> energylist = new List<EnergylistItem>();
|
|
///// <summary>
|
|
///// 是否正常
|
|
///// </summary>
|
|
//public TrainState trainData;
|
|
//private void Start()
|
|
//{
|
|
// energylist = UIManager.Instance.messageData.energylist;
|
|
//}
|
|
//// Use this for initialization
|
|
//private void OnEnable ()
|
|
//{
|
|
// //ttpData = ExamusersController.Instance.GetTTPDs();
|
|
// for (int i = 0; i < energylist.Count; i++)
|
|
// {
|
|
// int index = i;
|
|
// for (int j = 0; j < energylist[index].worklist.Count; j++)
|
|
// {
|
|
// infos.Add(energylist[index].worklist[j].valuework);
|
|
// }
|
|
|
|
// }
|
|
// textMesh.text = infos[0];
|
|
//}
|
|
public int index = 0;
|
|
|
|
public void Update()
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject())
|
|
return;
|
|
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
bool raycast = Physics.Raycast(ray, out hit);
|
|
if (raycast)
|
|
{
|
|
if (hit.collider.gameObject.name == "DNB_上")
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
OnUp();
|
|
}
|
|
|
|
if (hit.collider.gameObject.name == "DNB_下")
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
OnDown();
|
|
}
|
|
|
|
if (hit.collider.gameObject.name == "上")
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
OnUp();
|
|
}
|
|
|
|
if (hit.collider.gameObject.name == "下")
|
|
{
|
|
Debug.Log(hit.collider.name);
|
|
OnDown();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnUp()
|
|
{
|
|
index--;
|
|
if (index < 0)
|
|
{
|
|
index = 0;
|
|
}
|
|
|
|
SetValue(index);
|
|
}
|
|
|
|
public void OnDown()
|
|
{
|
|
index++;
|
|
if (index >= sprites.Length - 1)
|
|
{
|
|
index = sprites.Length - 1;
|
|
}
|
|
|
|
SetValue(index);
|
|
}
|
|
|
|
private void SetValue(int index)
|
|
{
|
|
// if (infos == null || infos.Count == 0) return;
|
|
spriteRenderer.sprite = sprites[index];
|
|
//textMesh.text = infos[index];
|
|
|
|
ElectricEnergyMeterData.SetValue(index);
|
|
}
|
|
}
|
|
} |