RuralPowerCompetition_yizhe.../RuralPowerCompetition_yizheng1/Assets/Zion/Scripts/MicroSystem/Option.cs

39 lines
907 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 选项
/// </summary>
public class Option : MonoBehaviour
{
private Image image;
private Text text;
public Image Image { get { if (image == null) image = GetComponent<Image>(); return image; } set => image = value; }
public Text Text { get { if (text == null) text = GetComponentInChildren<Text>(); return text; } set => text = value; }
/// <summary>
/// 该按钮是否切换场景
/// </summary>
public bool CutScreen;
public void OnSelected()
{
Color imgColor = Image.color;
imgColor.a = 1;
Image.color = imgColor;
Text.color = Color.white;
}
public void UnSelected()
{
Color imgColor = Image.color;
imgColor.a = 0;
Image.color = imgColor;
Text.color = Color.black;
}
}