|
@@ -176,8 +176,8 @@ class AimHandler
|
|
|
Vector3 Gyr = default;
|
|
Vector3 Gyr = default;
|
|
|
Vector3 Mag = default;
|
|
Vector3 Mag = default;
|
|
|
o09Axis _9Axis = new o09Axis();
|
|
o09Axis _9Axis = new o09Axis();
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //是否校正地磁计
|
|
|
|
|
+ bool bAjustMagnetometer = false;
|
|
|
//转换读取的数据,无符号->有符号
|
|
//转换读取的数据,无符号->有符号
|
|
|
float TwoByteToFloat(byte b1, byte b2)
|
|
float TwoByteToFloat(byte b1, byte b2)
|
|
|
{
|
|
{
|
|
@@ -223,9 +223,12 @@ class AimHandler
|
|
|
if (MagCalibrationButton != null)
|
|
if (MagCalibrationButton != null)
|
|
|
{
|
|
{
|
|
|
MagCalibrationButton.onClick.AddListener(delegate {
|
|
MagCalibrationButton.onClick.AddListener(delegate {
|
|
|
- if (MagCalibrater.Calibration)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // if (MagCalibrater.Calibration)
|
|
|
|
|
+ if (bAjustMagnetometer)
|
|
|
{
|
|
{
|
|
|
- MagCalibrater.Calibration = false;
|
|
|
|
|
|
|
+ // MagCalibrater.Calibration = false;
|
|
|
|
|
+ bAjustMagnetometer = false;
|
|
|
MagCalibrationButton.GetComponentInChildren<Text>().text = "开始地磁计校准";
|
|
MagCalibrationButton.GetComponentInChildren<Text>().text = "开始地磁计校准";
|
|
|
float[] dataFloats = new float[6];
|
|
float[] dataFloats = new float[6];
|
|
|
dataFloats[0] = MagCalibrater.Center.x;
|
|
dataFloats[0] = MagCalibrater.Center.x;
|
|
@@ -234,13 +237,12 @@ class AimHandler
|
|
|
dataFloats[3] = MagCalibrater.Radius.x;
|
|
dataFloats[3] = MagCalibrater.Radius.x;
|
|
|
dataFloats[4] = MagCalibrater.Radius.y;
|
|
dataFloats[4] = MagCalibrater.Radius.y;
|
|
|
dataFloats[5] = MagCalibrater.Radius.z;
|
|
dataFloats[5] = MagCalibrater.Radius.z;
|
|
|
- string dataStr = String.Join(",", dataFloats);
|
|
|
|
|
- PlayerPrefs.SetString("o0MagneticCalibrater", dataStr);
|
|
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- MagCalibrater.Calibration = true;
|
|
|
|
|
- MagCalibrationButton.GetComponentInChildren<Text>().text = "停止地磁计校准";
|
|
|
|
|
|
|
+ // MagCalibrater.Calibration = true;
|
|
|
|
|
+ bAjustMagnetometer = true;
|
|
|
|
|
+ MagCalibrationButton.GetComponentInChildren<Text>().text = "停止地磁计校准";
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -367,7 +369,8 @@ class AimHandler
|
|
|
}
|
|
}
|
|
|
if (doIdentity)
|
|
if (doIdentity)
|
|
|
{
|
|
{
|
|
|
- _9Axis.SetIdentityAccordingToRecords();
|
|
|
|
|
|
|
+ // _9Axis.SetIdentityAccordingToRecords();
|
|
|
|
|
+ _9Axis.SetIdentity();
|
|
|
if (controlObj != null)
|
|
if (controlObj != null)
|
|
|
{
|
|
{
|
|
|
controlObj.localRotation = Quaternion.identity;
|
|
controlObj.localRotation = Quaternion.identity;
|