跳转到内容

快速开始

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 跟随最新提交。

第一个界面

  1. 优先使用 Window → SUS → Setup Project —— 会创建 sus.config.json,并复制一份 预烤好的 starterHomeScreen.sharq + 已经生成的 Generated/HomeScreen.g.cs + SusApp 入口)。不需要先做一次生成 —— 开箱即可编译(避免鸡生蛋问题)。
  2. 或者按完整的 集成指南 操作(入口点、overlay 与 world-space 的区别、生成顺序)。
  3. 没有生成好的 .g.csMount 某个界面的代码就无法编译 —— 而且被破坏的 domain 可能会阻止 Sharq 重新生成自己。详情见该指南的 Critical 一节。

最小化的 .sharqApp.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
RouterRouter 文档
组件目录
价格Kit & Game