|
|
@@ -59,10 +59,10 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
});
|
|
|
if (guide) { //看看哪项没校准,就引导校准
|
|
|
List<DeviceCalibrateItem> guideList = new List<DeviceCalibrateItem>();
|
|
|
- if (string.IsNullOrEmpty(PlayerPrefs.GetString("o0GyrCalibrater", null))) {
|
|
|
+ if (!AimHandler.ins.IsGyrCompleted()) {
|
|
|
guideList.Add(DeviceCalibrateItem.Gyr);
|
|
|
}
|
|
|
- if (string.IsNullOrEmpty(PlayerPrefs.GetString("new_mag_record", null))) {
|
|
|
+ if (!AimHandler.ins.IsMagCompleted()) {
|
|
|
guideList.Add(DeviceCalibrateItem.Mag);
|
|
|
}
|
|
|
deviceCalibrateItemForGuide = guideList.ToArray();
|
|
|
@@ -135,6 +135,7 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
this.transform.Find("Gyr").gameObject.SetActive(deviceCalibrateItem == DeviceCalibrateItem.Gyr);
|
|
|
this.transform.Find("Mag").gameObject.SetActive(deviceCalibrateItem == DeviceCalibrateItem.Mag);
|
|
|
RefreshResetMagBtn();
|
|
|
+ RefreshGyrBtn();
|
|
|
}
|
|
|
|
|
|
/* ------ 新地磁计校准(2022-10-3) ------ */
|
|
|
@@ -150,7 +151,7 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
Color outColor;
|
|
|
ColorUtility.TryParseHtmlString("#005AB6", out outColor);
|
|
|
magReset.GetComponentInChildren<Text>().color = outColor;
|
|
|
- if (AimHandler.ins.MagCalibrater.Complete) {
|
|
|
+ if (AimHandler.ins.IsMagCompleted()) {
|
|
|
magReset.GetComponentInChildren<TextAutoLanguage>().SetText(116);
|
|
|
} else {
|
|
|
magReset.GetComponentInChildren<TextAutoLanguage>().SetText(85);
|
|
|
@@ -172,7 +173,7 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
calibrateMagDoing = !calibrateMagDoing;
|
|
|
if (calibrateMagDoing) {
|
|
|
calibrateMagStartTime = Time.realtimeSinceStartup;
|
|
|
- AimHandler.ins.MagCalibrater = new o0._9Axis.MagnetometerAutoCalibrater();
|
|
|
+ AimHandler.ins.ResetMag();
|
|
|
flag_MagCalibarateOperateAndFinish = 0;
|
|
|
}
|
|
|
interactableAllSkipBtns(!calibrateMagDoing);
|
|
|
@@ -185,7 +186,7 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
}
|
|
|
void UpdateForMag() {
|
|
|
if (deviceCalibrateItem == DeviceCalibrateItem.Mag) {
|
|
|
- if (!AimHandler.ins.MagCalibrater.Complete) {
|
|
|
+ if (!AimHandler.ins.IsMagCompleted()) {
|
|
|
progressMagCalibrate.gameObject.SetActive(true);
|
|
|
magTipOk.SetActive(false);
|
|
|
//地磁校准超时提示
|
|
|
@@ -239,7 +240,6 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
PopupMgr.ins.ShowTipTop(TextAutoLanguage2.GetTextByKey("device-calibrate_n-connect"));
|
|
|
return;
|
|
|
}
|
|
|
- //Logic
|
|
|
gyrCalibrating = !gyrCalibrating;
|
|
|
interactableAllSkipBtns(!gyrCalibrating);
|
|
|
if (gyrCalibrating) {
|
|
|
@@ -250,44 +250,24 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
canUpdateGyrCalibrateProgress = false;
|
|
|
}
|
|
|
AimHandler.ins.CalibrateGyr(gyrCalibrating);
|
|
|
- //UI
|
|
|
- Button btn = btnGyrCalibrate.GetComponent<Button>();
|
|
|
- if (gyrCalibrating) {
|
|
|
- btn.GetComponentInChildren<TextAutoLanguage>().SetText(121);
|
|
|
- btn.GetComponentInChildren<Text>().color = Color.red;
|
|
|
- } else {
|
|
|
- btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
|
|
|
- Color outColor;
|
|
|
- ColorUtility.TryParseHtmlString("#005AB6", out outColor);
|
|
|
- btn.GetComponentInChildren<Text>().color = outColor;
|
|
|
- }
|
|
|
+ AimHandler.ins.ResetGyr();
|
|
|
+ RefreshGyrBtn();
|
|
|
}
|
|
|
|
|
|
void FinishGyrCalibrate()
|
|
|
{
|
|
|
- //Logic
|
|
|
gyrCalibrating = false;
|
|
|
interactableAllSkipBtns(true);
|
|
|
canUpdateGyrCalibrateProgress = false;
|
|
|
AimHandler.ins.CalibrateGyr(false);
|
|
|
StartCoroutine(AimHandler.ins.SaveGyr());
|
|
|
- //UI
|
|
|
- Button btn = btnGyrCalibrate.GetComponent<Button>();
|
|
|
- if (guide) {
|
|
|
- btn.enabled = false;
|
|
|
- btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
|
|
|
- btn.GetComponentInChildren<Text>().color = Color.gray;
|
|
|
- } else {
|
|
|
- btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
|
|
|
- Color outColor;
|
|
|
- ColorUtility.TryParseHtmlString("#005AB6", out outColor);
|
|
|
- btn.GetComponentInChildren<Text>().color = outColor;
|
|
|
- }
|
|
|
+ RefreshGyrBtn();
|
|
|
}
|
|
|
|
|
|
bool canUpdateGyrCalibrateProgress = false;
|
|
|
void UpdateForGyr()
|
|
|
{
|
|
|
+ if (deviceCalibrateItem != DeviceCalibrateItem.Gyr) return;
|
|
|
if (canUpdateGyrCalibrateProgress) {
|
|
|
int progress = AimHandler.ins.gyrCalibrateCompleteCount * 100 / AimHandler.ins.gyrCalibrateTotalCount;
|
|
|
progressGyrCalibrate.text = progress + "%";
|
|
|
@@ -298,6 +278,30 @@ public class DeviceCalibrateView : MonoBehaviour, MenuBackInterface
|
|
|
action_GyrCalibarateOperateAndFinish?.Invoke();
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (AimHandler.ins.IsGyrCompleted()) progressGyrCalibrate.text = "100%";
|
|
|
+ else progressGyrCalibrate.text = "0%";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void RefreshGyrBtn() {
|
|
|
+ Button btn = btnGyrCalibrate.GetComponent<Button>();
|
|
|
+ if (guide) {
|
|
|
+ if (AimHandler.ins.IsGyrCompleted()) {
|
|
|
+ btn.enabled = false;
|
|
|
+ btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
|
|
|
+ btn.GetComponentInChildren<Text>().color = Color.gray;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (gyrCalibrating) {
|
|
|
+ btn.GetComponentInChildren<TextAutoLanguage>().SetText(121);
|
|
|
+ btn.GetComponentInChildren<Text>().color = Color.red;
|
|
|
+ } else {
|
|
|
+ btn.GetComponentInChildren<TextAutoLanguage>().SetText(AimHandler.ins.IsGyrCompleted() ? 116 : 85);
|
|
|
+ Color outColor;
|
|
|
+ ColorUtility.TryParseHtmlString("#005AB6", out outColor);
|
|
|
+ btn.GetComponentInChildren<Text>().color = outColor;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|