用途:在 Unity 场景中把对象放到另一个对象之上、旁边、前后或指定距离处时,用真实包围盒而非猜测尺寸来计算位置,适用于 Meta VR 与 Horizon OS 项目。
主要能力:识别“放在…上/旁边/左/右/前/后/上方/下方/附近”等相对摆放意图并自动触发;读取 Renderer.bounds 或 Collider.bounds 等世界空间包围盒;按“顶部对齐、水平相邻、前后偏移、指定距离”等公式计算目标位置;支持无 Renderer 时回退到 Collider,父对象无 Renderer 时合并子对象包围盒。
使用方式:通过 unity-cli 读写场景,而非直接编辑 .unity YAML。先确认状态:unity status --format json(state 为 ready)。查找对象:unity command find_gameobjects --name Cube --format json。bounds 是计算属性,需用脚本读取,例如 unity command run_script --file AgentScripts/GetBounds.cs --entry GetBounds.Run --args '[["Cube","Table"]]' --format json。设置位置:unity command set_transform --target Cube --position "[0,1.05,2]" --format json,随后 unity command save_scene --format json。注意 set_transform 写入的是 localPosition,父对象存在时需先转换或改用脚本设置 transform.position。
适用场景:把多个对象摆到桌面上、把杯子放到桌上、把灯放在钟旁、按“左移 0.5 米”等距离摆放、导入模型后相对已有对象定位。
限制:包围盒是轴对齐 AABB,旋转或非盒状物体会比可见轮廓大,可能产生间隙;无 Renderer 与 Collider 时无法确定尺寸,只能警告或按零尺寸处理;本地包围盒忽略旋转,摆放应优先使用世界空间包围盒。资料未提供收费、价格与平台支持细节。