大连中石油电子沙盘
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.
 
 
 
 

63 lines
1.7 KiB

using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class NAVSelectCarItem : MonoBehaviour
{
public Toggle Toggle;
public Text Text;
public Button Button;
public GameObject SelectCar;
public static List<NAVSelectCarItem> SelectCarItem = new List<NAVSelectCarItem>();
// Use this for initialization
void Start()
{
SelectCarItem.Add(this);
Toggle.onValueChanged.AddListener(Change);
Button.onClick.AddListener(Delete);
MessageDispatcher.AddListener("RemoveSelectCar", RemoveSelectCar);
MessageDispatcher.AddListener("DeleteObj", DeleteObj);
}
private void DeleteObj(IMessage message)
{
var obj = message.Data as GameObject;
if (SelectCar == obj)
{
Delete();
}
}
private void RemoveSelectCar(IMessage message)
{
var obj = message.Data as GameObject;
if (SelectCar == obj)
{
Toggle.isOn = false;
}
}
private void Delete()
{
MultiSelectNAV.GetInstance.RemoveSelectCar(SelectCar);
SelectCarItem.Remove(this);
Destroy(gameObject);
}
private void Change(bool arg0)
{
if (arg0) MultiSelectNAV.GetInstance.AddSelectCar(SelectCar);
else MultiSelectNAV.GetInstance.RemoveSelectCar(SelectCar);
}
private void OnDisable()
{
MessageDispatcher.RemoveListener("RemoveSelectCar", RemoveSelectCar);
MessageDispatcher.RemoveListener("DeleteObj", DeleteObj);
SelectCarItem.Remove(this);
Destroy(gameObject);
}
}