Unity 视频会议接入
下载地址
https://www.zhengdianxue.com/wp-content/uploads/skills/org-b6kzcl68--unity.zip将提示词发送给你的 AI 安装该 skills
请根据 https://skillhub.cn/install/skillhub.md,安装 @org-b6kzcl68/unity。Zoom Video SDK 在 Unity 环境下的封装集成工作流,提供从入门文档、生命周期与架构概念、会话加入示例、典型场景说明、参考索引映射、环境变量、版本兼容性到常见问题排查的分层阅读路径,并汇总官方开发文档与 API 参考入口及 5 分钟预检调试清单,用于指导构建基于 Unity 的自定义视频会话体验、把 Unity 场景与 UI 状态映射到 Video SDK 事件。
Use when the user 需要在 Unity 项目中集成 Zoom Video SDK、封装自定义视频会议体验、处理 Unity 场景状态与 SDK 事件的映射,或提到 video sdk unity、unity 自定义视频等场景。Triggers include Zoom视频SDK、Unity视频会议、视频会话封装、SDK事件映射。
如需知识管理完整工作流套件,淘宝搜索「AI灵匣」店铺获取完整版。
阅读全文 (展开查看完整说明)
概述
Lifecycle Order
AwakebeforeStart— use Awake for self-init, Start for cross-referencesOnEnablecalled beforeStart— but afterAwake- Order between scripts not guaranteed — use Script Execution Order if needed
Awakecalled even if disabled —Startonly when enabled
GetComponent Performance
GetComponentevery frame is slow — cache inAwakeorStartGetComponentInChildrensearches recursively — expensive on deep hierarchiesTryGetComponentreturns bool — avoids null check, slightly faster- Use
RequireComponentattribute — ensures dependency, documents requirement
Physics Timing
- Physics in
FixedUpdate, notUpdate— consistent regardless of framerate FixedUpdatecan run 0 or multiple times per frame — don't assume 1:1Rigidbody.MovePositionin FixedUpdate —transform.positionbypasses physicsTime.deltaTimein Update,Time.fixedDeltaTimein FixedUpdate — or just use deltaTime
Unity's Fake Null
- Destroyed objects aren't truly null —
== nullreturns true, but object exists - Null-conditional
?.doesn't work properly — use== nullorboolconversion Destroydoesn't happen immediately — object gone next frame- Use
DestroyImmediateonly in editor — causes issues in builds
Coroutines
StartCoroutineneeds MonoBehaviour active — disabled/destroyed stops coroutinesyield return nullwaits one frame —yield return new WaitForSeconds(1)for timeStopCoroutineneeds same method or Coroutine reference — string overload unreliable- Can't return values — use callbacks or set field in coroutine
Instantiate and Pooling
Instantiateis expensive — pool frequently created/destroyed objectsInstantiate(prefab, parent)sets parent — avoids extra SetParent callSetActive(false)before returning to pool — not Destroy- Pool inactive objects under a parent — keeps hierarchy clean
Serialization
[SerializeField]for private fields in inspector — prefer over publicpublicfields auto-serialize — but exposes API you may not want[HideInInspector]hides but still serializes —[NonSerialized]to skip entirely- Serialized fields keep inspector values — code defaults ignored after first serialize
ScriptableObjects
- Data containers that live as assets — share between scenes/prefabs
CreateAssetMenuattribute for easy creation — right-click → Create- Don't modify at runtime in builds — changes not saved (except in editor)
- Great for config, item databases — reduces prefab duplication
Common Mistakes
Findmethods every frame — cache references- String comparisons for tags — use
CompareTag("Enemy"), nottag == "Enemy" - Physics queries allocate — use
NonAllocvariants:RaycastNonAlloc - UI anchors wrong — stretches unexpectedly on different resolutions
async/awaitwithout context — use UniTask or careful error handling