| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections;
- using UnityEngine;
- using UnityEngine.Scripting;
- using o0.Num;
- using o0.Geometry;
- //AOT适配器[#该脚本非常重要不要删除#]
- //该脚本需要挂载在场景中才会生效,只要静态构造函数得以调用就ok了
- [Preserve]
- public class AOTAdapter : MonoBehaviour
- {
- static AOTAdapter()
- {
- //o0.Num泛型类的显式创建
- Num<Vector<double>>.Plus = (a, b) => a + b;
- Num<Vector<double>>.Minus = (a, b) => a - b;
- Num<Vector<double>>.Multiply = (a, b) => a * b;
- Num<Vector<double>>.Divide = (a, b) => a / b;
- Num<Vector<double>>.Rate = (a, b) => a * b;
- }
- //用保存的模块数据片段,测试陀螺仪校准,排查aot编译导致底层函数出错
- IEnumerator TestCalibrateGyrBy9AxisData() {
- while (!AimHandler.ins) yield return null;
- Debug.Log("start-Test9AxisData");
- AimHandler.ins.CalibrateGyr(true);
- string dataText = Resources.Load<TextAsset>("test-data").text;
- int a = 0;
- foreach (var dataLine in dataText.Split('\n'))
- {
- AimHandler.ins.OnDataReceived(ToBytes(dataLine));
- a++;
- if (a == 100) AimHandler.ins.CalibrateGyr(false);
- }
- Debug.Log("end-Test9AxisData");
- }
- byte[] ToBytes(string msg) {
- return Array.ConvertAll<string, byte>(msg.Split(','), s => byte.Parse(s));
- }
- }
|