using Assets.Scripts; using Assets.Scripts.Apis.Models; using Assets.Scripts.UI.UIEffect; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class Item : MonoBehaviour, IPointerClickHandler { private Text text; private string Text { get { return text.text; } set { text.text = value; } } private Text km; private string Distance { get { return km.text; } set { km.text = value; } } private Text count; private string Count { get { return count.text; } set { count.text = value; } } public Action onClick; private void Awake() { text = this.transform.Find("name").GetComponent(); km = this.transform.Find("km").GetComponent(); count = this.transform.Find("count").GetComponent(); Material material = null; if (material == null) { material = Instantiate(Resources.Load("UI/Material/RoundedCornersTextureMaterial")); } var rect = ((RectTransform)transform).rect; material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0)); this.GetComponent().material = material; } public void Selected(bool value) { if (value) { this.GetComponent().enabled = true; this.GetComponent().color1 = Utils.HexToColor("FF7485"); this.GetComponent().color2 = Utils.HexToColor("F93086"); this.GetComponent().color = Color.white; this.transform.Find("km").GetComponent().color = Color.white; this.transform.Find("count").GetComponent().color = Color.white; } else { this.GetComponent().enabled = false; this.GetComponent().color = Utils.HexToColor("353543"); this.transform.Find("km").GetComponent().color = Utils.HexToColor("5C5C6E"); this.transform.Find("count").GetComponent().color = Utils.HexToColor("F93086"); } } public void SetModel(NearRouteModel model) { this.Text = model.Name; this.Distance = model.Distance + "KM"; this.Count = model.TheHeat.ToString(); } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public void OnPointerClick(PointerEventData eventData) { if(onClick != null) { onClick(); } } }