| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- /*
- 按下自动校准键出现倒计时3秒,同时伴有文字提示用户“三秒后即将开始校准,
- 请扶稳弓箭。”倒计时3秒后出现一个进度条也是三秒,用户在3秒内自己尽量扶稳弓即可,
- 进度条完成后,取一个平均值作为校准值。
- */
- public class AutoResetViewNew : MonoBehaviour
- {
- public Transform pos;
- public Transform iconHumanShoot;
- public Transform frameTip;
- public Transform leftPoint;
- public Transform rightPoint;
- void Awake() {
-
- }
- void Start() {
- //if (SceneManager.GetActiveScene().name == "Game") {
- // (iconHumanShoot as RectTransform).anchoredPosition = new Vector2(-193, -85);
- //}
- prepareTime = UserSettings.ins.calibrationTime;
- Debug.Log("弓箭重置时间:"+ prepareTime);
- GetGuideTip().textFormatArgs = new object[]{showedPrepareTime = Mathf.CeilToInt(prepareTime)};
- GetGuideTip().ApplyToText();
- ChallengeTargetForResetView.Show();
- }
- public void setPosLeft() {
- //Debug.Log(Screen.width + " == "+ Screen.height);
- (pos as RectTransform).anchoredPosition = leftPoint.GetComponent<RectTransform>().anchoredPosition;
- }
- public void setPosRight()
- {
- (pos as RectTransform).anchoredPosition = rightPoint.GetComponent<RectTransform>().anchoredPosition;
- }
- public Action action_OnDestroy;
- void OnDestroy() {
- }
- float prepareTime = 3;
- int showedPrepareTime;
- void Update() {
- prepareTime -= Time.unscaledDeltaTime;//Time.deltaTime;
- if (prepareTime <= 0) {
- action_OnDestroy?.Invoke();
- Destroy(gameObject);
- } else {
- int curTime = Mathf.CeilToInt(prepareTime);
- if (showedPrepareTime != curTime) {
- showedPrepareTime = curTime;
- TextAutoLanguage2 gt = GetGuideTip();
- gt.textFormatArgs[0] = Mathf.CeilToInt(prepareTime);
- gt.ApplyToText();
- }
- }
- }
- TextAutoLanguage2 _guideTip;
- TextAutoLanguage2 GetGuideTip() {
- if (_guideTip == null) _guideTip = frameTip.GetComponentInChildren<TextAutoLanguage2>();
- return _guideTip;
- }
- }
|