You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
65 lines
2.2 KiB
using AX.NetworkSystem; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class DisasterItem : MonoBehaviour { |
|
public DisasterInfo msg = new DisasterInfo(); |
|
private GameObject selectedImg; |
|
private Text disasterName; |
|
private Text disasterTime; |
|
private Button del; |
|
|
|
public void OnEnable() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.AddListener(OnValueChanged); |
|
} |
|
|
|
public void OnDisable() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.RemoveListener(OnValueChanged); |
|
} |
|
|
|
public void OnDestroy() |
|
{ |
|
GetComponent<Toggle>().onValueChanged.RemoveListener(OnValueChanged); |
|
del.onClick.RemoveListener(Delete); |
|
} |
|
public void OnValueChanged(bool value) |
|
{ |
|
//selectedImg.SetActive(value); |
|
if (value) |
|
{ |
|
disasterName.color = Color.cyan; |
|
disasterTime.color = Color.cyan; |
|
UpdateManager.Instance.selectedMsg = this.msg; |
|
} |
|
else |
|
{ |
|
disasterName.color = Color.white; |
|
disasterTime.color = Color.white; |
|
} |
|
} |
|
// Use this for initialization |
|
void Awake () { |
|
GetComponent<Toggle>().group = transform.parent.GetComponent<ToggleGroup>(); |
|
selectedImg = transform.Find("Selected").gameObject; |
|
selectedImg.SetActive(false); |
|
disasterName = transform.Find("DisasterName").GetComponent<Text>(); |
|
disasterTime = transform.Find("DisasterTime").GetComponent<Text>(); |
|
del = transform.Find("Delete").GetComponent<Button>(); |
|
del.onClick.AddListener(Delete); |
|
} |
|
public void Set(DisasterInfo msg) |
|
{ |
|
this.msg = msg; |
|
disasterName.text = msg.Name; |
|
disasterTime.text = msg.LastTime; |
|
} |
|
private void Delete() |
|
{ |
|
//ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { NetworkManager.Default.SendAsync("DELETE_DISASTER_INFO_SYNC", msg.Id); }, null); //单机版注释 |
|
ResourceLoadWindow.Instance.LoadTipWindow("是否删除预案?", () => { DisasterInfosManager.Instance.DeleteDisasterInfo(msg.Id); }, null);//非单机版打开 |
|
} |
|
}
|
|
|