31 lines
654 B
C#
31 lines
654 B
C#
using EasyInject.Attributes;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 全屏按钮
|
|
/// </summary>
|
|
[GameObjectBean]
|
|
public sealed class FullScreenButton : MonoBehaviour
|
|
{
|
|
private Button button;
|
|
private TMP_Text text;
|
|
|
|
void Start()
|
|
{
|
|
|
|
button = GetComponent<Button>();
|
|
text = button.transform.GetComponentInChildren<TMP_Text>();
|
|
button.onClick.AddListener(ToggleFullScreen);
|
|
}
|
|
/// <summary>
|
|
/// 全屏
|
|
/// </summary>
|
|
void ToggleFullScreen()
|
|
{
|
|
Screen.fullScreen = !Screen.fullScreen;
|
|
text.text = Screen.fullScreen ? "全屏" : "退出全屏";
|
|
}
|
|
}
|