si-m1-face-package/Documentation~/SDK_QuickStart.zh-CN.md

81 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SDK 快速开始
English documentation: [SDK_QuickStart.md](SDK_QuickStart.md).
公开 UPM 包以编译后的 DLL 形式发布,不包含 SDK 源码、Demo 源码、测试源码或调试符号。
## 1. 安装
通过 Unity Package Manager 添加 Git URL
```text
https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2
```
或写入 `Packages/manifest.json`
```json
"xin.aisu.si-m1.face": "https://git.aisu.xin/aisu-sdk/si-m1-face-package.git#v0.1.2"
```
## 2. 创建配置
打开 Unity 菜单:
```text
AISU/SI-M1 Face SDK/Settings
```
工具会在导入该包的 Unity 项目中创建或加载配置资产:
```text
Assets/AISU/SI-M1 Face SDK/FaceSdkSettings.asset
```
配置串口号、波特率、Mock 模式和日志选项。
## 3. 创建 Manager
打开 Unity 菜单:
```text
AISU/SI-M1 Face SDK/Create Manager GameObject
```
每个场景建议只保留一个 `FaceModuleManager`,避免重复打开串口和重复派发事件。
## 4. 最小代码
```csharp
using Aisu.SIM1.Face.Core;
using UnityEngine;
public sealed class FaceExample : MonoBehaviour
{
[SerializeField] private FaceModuleManager manager;
private async void Start()
{
manager.Open();
await manager.WaitReadyAsync();
var version = await manager.Basic.GetVersionAsync();
Debug.Log("SI-M1 version: " + version);
}
}
```
## 5. 运行模式
| 场景 | 推荐配置 |
|---|---|
| Editor 中无硬件联调 | `Use Mock In Editor = true` |
| Editor 中连接真实串口硬件 | `Use Mock In Editor = false`,并配置 Editor 串口参数 |
| Windows Player | `Transport Mode = SerialPort``Auto`,并配置运行时串口参数 |
## 注意事项
- Unity 对 Git URL 包可能显示为 `xin.aisu.si-m1.face@<commit-hash>`,这是正常行为。
- DLL-only 公开版本不包含可导入 Demo 示例。
- Demo 源码和 EditMode 测试源码保留在私有开发 SDK 仓库中。