using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace Views { public class ThreeTransformerPhotovoltaicView : MonoBehaviour { public SpriteRenderer spriteRenderer; public TextMesh textMesh; //public string isFD; public Sprite[] sprites; public List infos = new List(); /// /// 表计信息 /// //public List energylist = new List(); ///// ///// 是否正常 ///// //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 (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]; } } }