TouhouLS/Assets/FullscreenToggler.cs

26 lines
558 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FullscreenToggler : MonoBehaviour {
public Sprite Fullscreen, Window;
// Start is called before the first frame update
void Start() {
GetComponent<Button>().onClick.AddListener(onButtonClick);
}
void onButtonClick() {
Screen.fullScreen = !Screen.fullScreen;
}
// Update is called once per frame
void Update() {
bool state = Screen.fullScreen;
var img = GetComponent<Image>().sprite = state ? Fullscreen : Window;
}
}