| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- /*
- 按下自动校准键出现倒计时3秒,同时伴有文字提示用户“三秒后即将开始校准,
- 请扶稳弓箭。”倒计时3秒后出现一个进度条也是三秒,用户在3秒内自己尽量扶稳弓即可,
- 进度条完成后,取一个平均值作为校准值。
- */
- public class AutoResetView : MonoBehaviour
- {
- [SerializeField] TextAutoLanguage2 prepareTipText;
- static AutoResetView ins;
- public static void DoIdentity() {
- if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.StartsWith("Game")) {
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
- } else {
- AimHandler.ins.DoIdentity();
- }
- }
-
- void Awake() {
- if (ins) {
- Destroy(gameObject);
- return;
- }
- ins = this;
- }
- void Start() {
- if (SceneManager.GetActiveScene().name == "GameChallenge") {
- transform.Find("IconHumanShoot").gameObject.SetActive(true);
- transform.Find("FrameTip").gameObject.SetActive(true);
- }
- prepareTipText.textFormatArgs = new object[]{Mathf.CeilToInt(prepareTime)};
- prepareTipText.ApplyToText();
- ChallengeTargetForResetView.Show();
- }
- void OnDestroy() {
- if (ins == this) ins = null;
- }
- float prepareTime = 3;
- void Update() {
- prepareTime -= Time.deltaTime;
- if (prepareTime <= 0) {
- try {
- AimHandler.ins.DoIdentity();
- Destroy(gameObject);
- }
- catch (System.Exception) {}
- Destroy(gameObject);
- } else {
- prepareTipText.textFormatArgs[0] = Mathf.CeilToInt(prepareTime);
- prepareTipText.ApplyToText();
- }
- }
- }
|