Browse Source

算法切换

lvjincheng 3 years ago
parent
commit
39b18cca6d

+ 2 - 2
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -37,8 +37,8 @@ public class AimHandler : MonoBehaviour
         ins = this;
         BluetoothDispatcher.aim = OnDataReceived;
 
-        m_axisHandler = new Axis9NopackHandler(this); //九轴旧
-        // m_axisHandler = new Axis9Handler(this);  //九轴新
+        // m_axisHandler = new Axis9NopackHandler(this); //九轴旧
+        m_axisHandler = new Axis9Handler(this);  //九轴新
         // m_axisHandler = new Axis663Handler(this); //双陀螺仪
         m_axisHandler.Init();
 

+ 2 - 1
Assets/BowArrow/Scripts/Bluetooth/New/AttitudeJson.cs

@@ -16,7 +16,8 @@ public class AttitudeJson : JCUnityLib.CustomJson
             "ByteToGyr", 
             "ByteToMag",
             "GyrCalibrater", 
-            "MagCalibrater"
+            "MagCalibrater",
+            "ByteReverseMS"
         );
         InitJsonClass<MagnetometerAutoCalibrater>(() => new MagnetometerAutoCalibrater(),
             "CountPerLength", 

+ 4 - 2
Assets/ThirdAssets/JCUnityLib/CustomJson.cs

@@ -21,6 +21,7 @@ namespace JCUnityLib
             importerDict.Add(typeof(double), (o) => JValue.FromObject(o));
             importerDict.Add(typeof(bool), (o) => JValue.FromObject(o));
             importerDict.Add(typeof(double[][]), (o) => JArray.FromObject(o));
+            importerDict.Add(typeof(Nullable<bool>), (o) => JValue.FromObject(o));
             //add exporter
             exporterDict.Add(typeof(short), (jt) => jt.ToObject<short>());
             exporterDict.Add(typeof(int), (jt) => jt.ToObject<int>());
@@ -29,6 +30,7 @@ namespace JCUnityLib
             exporterDict.Add(typeof(double), (jt) => jt.ToObject<double>());
             exporterDict.Add(typeof(bool), (jt) => jt.ToObject<bool>());
             exporterDict.Add(typeof(double[][]), (jt) => ((JArray)jt).ToObject<double[][]>());
+            exporterDict.Add(typeof(Nullable<bool>), (jt) => jt.ToObject<Nullable<bool>>());
         }
 
         public void InitJsonClass<T>(Func<object, JToken> importer, Func<JToken, object> exporter)
@@ -71,7 +73,7 @@ namespace JCUnityLib
             {
                 FieldInfo targetField = fromObjectType.GetField(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                 if (targetField == null) {
-                    PropertyInfo propertyInfo = fromObjectType.GetProperty(propertyName);
+                    PropertyInfo propertyInfo = fromObjectType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                     JToken propertyValue = ToJTokenByImporter(propertyInfo.GetValue(fromObject));
                     target[propertyName] = propertyValue;
                 } else {
@@ -133,7 +135,7 @@ namespace JCUnityLib
             {
                 FieldInfo targetField = targetType.GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                 if (targetField == null) {
-                    PropertyInfo propertyInfo = targetType.GetProperty(fieldName);
+                    PropertyInfo propertyInfo = targetType.GetProperty(fieldName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
                     object fieldValue = ParseByExporter(fromJson[fieldName], propertyInfo.PropertyType);
                     propertyInfo.SetValue(target, fieldValue);
                 } else {