69 lines
1.5 KiB
C#
69 lines
1.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BtClick : MonoBehaviour
|
|
{
|
|
public Sprite clickSprite;
|
|
private Sprite defaultSprite;
|
|
|
|
public CarType carType;
|
|
private Image image;
|
|
public event Action OnStartCompleted;
|
|
|
|
private void Awake()
|
|
{
|
|
image = this.GetComponent<Image>();
|
|
defaultSprite = image.sprite;
|
|
}
|
|
|
|
|
|
private void Start()
|
|
{
|
|
// switch (carType)
|
|
// {
|
|
// case CarType.首页:
|
|
// GameManager.instance.home.Add(this.GetComponent<BtClick>());
|
|
//
|
|
// break;
|
|
// // case CarType.车类型:
|
|
// // GameManager.instance.carType.Add(this.GetComponent<BtClick>());
|
|
// //
|
|
// // break;
|
|
// case CarType.天气:
|
|
// GameManager.instance.weather.Add(this.GetComponent<BtClick>());
|
|
//
|
|
// break;
|
|
// case CarType.危险驾驶:
|
|
// GameManager.instance.dangerDriving.Add(this.GetComponent<BtClick>());
|
|
//
|
|
// break;
|
|
// }
|
|
|
|
|
|
this.GetComponent<Button>().onClick.AddListener(delegate { MenuManager.instance.OnBtClick(carType, this.name); });
|
|
|
|
|
|
// OnStartCompleted?.Invoke();
|
|
}
|
|
|
|
|
|
|
|
public void OnClickSprite()
|
|
{
|
|
image.sprite = clickSprite;
|
|
}
|
|
|
|
public void OnCancel()
|
|
{
|
|
image.sprite = defaultSprite;
|
|
}
|
|
|
|
|
|
public void Click()
|
|
{
|
|
Debug.Log("点击");
|
|
}
|
|
} |