using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UIElements; namespace Kirurobo { public class SampleManager : MonoBehaviour { private static SampleManager _instance; public static SampleManager Instance => _instance ?? (_instance = GameObject.FindObjectOfType() ?? new SampleManager()); public Canvas canvas; private void Awake() { // シングルトンとする。既にインスタンスがあれば自分を破棄 if (this != Instance) { Destroy(this.gameObject); return; } DontDestroyOnLoad(Instance); DontDestroyOnLoad(UniWindowController.current); SceneManager.sceneLoaded += SceneManager_sceneLoaded; } /// /// シーンロード時にメインカメラを記憶 /// /// /// private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1) { UniWindowController.current.SetCamera(Camera.main); } /// /// 指定の名前のシーンを開く /// /// シーン名 public void LoadScene(string name) { if (name == "SimpleSample") { // SimpleSample の場合はスクリプトでの制御がないため、ここで透明化 UniWindowController.current.isTransparent = true; } else if (name == "FullScreenSample") { // FullScreenSample の場合は強制的に最大化 UniWindowController.current.shouldFitMonitor = true; } SceneManager.LoadScene(name); } /// /// 終了 /// public void Quit() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } } }