快速开始
SUS 是一套 Unity 包。先从免费的 Core + Router 开始,需要组件库时再加上 Kit / Game。
环境要求
- Unity 6000.3+ (UI Toolkit)
- Git(用于 UPM git 依赖)
安装免费包(git UPM)
在你的 Unity 项目 Packages/manifest.json 中:
json
{
"dependencies": {
"com.sharq-it.sus.core": "https://github.com/antaresdk/sus-core.git#v1.0.29",
"com.sharq-it.sus.router": "https://github.com/antaresdk/sus-router.git#v1.0.16"
}
}想要可复现的安装,优先使用发布 tag;
#main跟随最新提交。
第一个界面
- 优先使用
Window → SUS → Setup Project—— 会创建sus.config.json,并复制一份 预烤好的 starter(HomeScreen.sharq+ 已经生成的Generated/HomeScreen.g.cs+SusApp入口)。不需要先做一次生成 —— 开箱即可编译(避免鸡生蛋问题)。 - 或者按完整的 集成指南 操作(入口点、overlay 与 world-space 的区别、生成顺序)。
- 没有生成好的
.g.cs,Mount某个界面的代码就无法编译 —— 而且被破坏的 domain 可能会阻止 Sharq 重新生成自己。详情见该指南的 Critical 一节。
最小化的 .sharq(App.sharq —— 下面的 Mount<App>() 引用的正是它):
xml
<!-- App.sharq -->
<template>
<ui:Label $MainElement :text="Message" class="greeting" />
</template>
<script>
public string Message = "Hello SUS!";
</script>
<style>
.greeting {
font-size: 24px;
color: white;
-unity-text-align: middle-center;
}
</style>布局和外观都写在
<style>(USS)里。优先使用 class,而不是 C# 的element.style.*。详见:.sharq 格式 · 完整指南。
csharp
public class AppEntry : MonoBehaviour
{
public UIDocument uiDocument;
void Start() =>
Sharq.Core.SusApp.Create(uiDocument)
.UseTheme(SusTheme.Dark)
.Mount<App>(); // creates OverlayHost + world panel
}接下来
| 主题 | 链接 |
|---|---|
| SUS 是什么? | 概览 |
VS Code 中的 .sharq 高亮 | 编辑器设置 |
| 完整的 core 指南 | Guide |
.sharq + <style> | 格式 · CSS scoping |
| 响应式 | Prop / Computed / Watch |
| Router | Router 文档 |
| 组件 | 目录 |
| 价格 | Kit & Game |