diff options
author | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-03-13 11:00:58 +0800 |
commit | 6ce8b9e22fc13be34b442c7b6af48b42cd44275a (patch) | |
tree | b38119d2acf0a982cb67e381f146924b9bfc3b3f /ArchiveScript.cs |
+init
Diffstat (limited to 'ArchiveScript.cs')
-rw-r--r-- | ArchiveScript.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ArchiveScript.cs b/ArchiveScript.cs new file mode 100644 index 0000000..1f23c24 --- /dev/null +++ b/ArchiveScript.cs @@ -0,0 +1,61 @@ +using UnityEngine; +using UnityEngine.UI; + +public class ArchiveScript : MonoBehaviour +{ + private static ArchiveScript intance; + + public Image bar; + + public CanvasGroup escapeCG; + + public CanvasGroup wholeCG; + + private bool hide; + + private float escapeCounter; + + private void Start() + { + if (intance == null) + { + intance = this; + Object.DontDestroyOnLoad(base.gameObject); + } + else + { + Object.Destroy(intance.gameObject); + } + } + + private void Update() + { + if (Input.GetKeyDown(KeyCode.H)) + { + hide = !hide; + if (hide) + { + wholeCG.alpha = 0f; + } + else + { + wholeCG.alpha = 1f; + } + } + if (Input.GetKey(KeyCode.Escape)) + { + escapeCounter += Time.deltaTime; + if (escapeCounter > 1f) + { + Application.Quit(); + } + } + else + { + escapeCounter -= Time.deltaTime; + } + escapeCounter = Mathf.Clamp(escapeCounter, 0f, 2f); + escapeCG.alpha = escapeCounter * 2f; + bar.fillAmount = escapeCounter; + } +} |