Files
ichni_Creator_Studio/Document/console.md
2025-10-18 15:58:55 +08:00

294 lines
6.3 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.
# Editor Console 方法文档
## 概述
Editor Console 是游戏编辑器中的命令行系统,用于执行各种便捷操作。按 **`~`** 键Esc下方打开控制台支持历史记录和参数自动补全。
## 基础操作
### `tp(Vector3 pos)`
将场景相机移动到指定坐标
**示例**:
```csharp
tp [10,5,0] // 移动到坐标(10,5,0)
tp [0,2,-3] // 移动到坐标(0,2,-3)
tp(0, 0, 15) // 使用括号格式
```
### `tp()`
将场景相机移动到当前选中对象的位置
**示例**:
```csharp
tp // 直接传送到选中对象位置
```
> **要求**: Inspector中必须选中对象
### `ReName(string message)`
重命名当前选中对象
**示例**:
```csharp
ReName "NewTrackName"
ReName "PlayerSpawnPoint"
ReName("EnemyPath_01") // 括号格式
```
## 路径生成
### `Lgp(int loop, Vector3 start, Vector3 end, bool Clear = false, bool offsetOrigin = false)`
在选中的Track上生成线性路径节点
**参数**:
- `loop`: 节点数量必须大于1
- `start`: 起始坐标
- `end`: 结束坐标
- `Clear`: 是否清除现有节点
- `offsetOrigin`: 是否基于原节点变换偏移
**示例**:
```csharp
Lgp 10 [0,0,0] [5,0,5] // 生成10个节点的直线
Lgp 5 [1,2,3] [10,2,3] true // 清除旧节点后生成新路径
Lgp 8 [0,0,0] [0,10,0] false true // 保留并偏移原有节点
```
### `Spiral` 螺旋路径生成
#### 主轴方向螺旋
```csharp
Spiral(int loop, Vector3 center, float r, float h, int pointsPerTurn, string axis = "y")
```
#### 自定义方向螺旋
```csharp
Spiral(int loop, Vector3 center, float r, float h, int pointsPerTurn, Vector3 dir)
```
**示例**:
```csharp
// Y轴螺旋默认
Spiral 20 [0,0,0] 3 10 8
// Z轴螺旋
Spiral 20 [0,0,0] 3 10 8 "z"
// 自定义方向螺旋
Spiral 15 [1,2,3] 2 5 6 [1,1,0]
// 复杂螺旋路径
Spiral(30, [5,0,5], 4.0, 15.0, 10, [0,1,1])
```
## 数据处理
### `SamplerImport(string inputData)`
导入采样器格式的音符数据
**数据格式**: `(动作类型, 轨道ID, 时间戳, X值, [Hold持续时间])`
**支持的动作类型**:
- `Tap`: 点击音符
- `Stay`: 停留音符
- `Hold`: 长按音符(需要持续时间)
- `Flick`: 滑动音符
**示例**:
```csharp
// 单个音符导入
SamplerImport "(Tap, Track1, 12.5, 3.2)"
// 多个音符批量导入
SamplerImport "(Tap, MainTrack, 10.0, 1.5)\n(Hold, SideTrack, 15.0, -2.1, 3.5)"
// 复杂序列
SamplerImport "
(Tap, RedTrack, 5.2, 0.0)
(Stay, BlueTrack, 7.8, 2.5)
(Hold, GreenTrack, 12.3, -1.0, 4.2)
(Flick, YellowTrack, 18.6, 3.0)
"
```
### `ExportNotesFromTrack()`
导出当前Track下所有音符为正则格式文本
**示例**:
```csharp
ExportNotesFromTrack // 自动复制到剪贴板
```
> **输出示例**:
> ```
> (Tap, MainTrack, 5.200, 0.000)
> (Stay, MainTrack, 7.800, 2.500)
> (Hold, MainTrack, 12.300, -1.000, 4.200)
> ```
## 音符操作
### `SetNoteHLInGame(bool forceSetOff = false, bool SameTheme = false)`
全局高亮重复时间点的音符
**示例**:
```csharp
SetNoteHLInGame // 高亮所有重复时间点音符
SetNoteHLInGame true // 先关闭所有高亮再重新高亮
SetNoteHLInGame false true // 只高亮同类型重复音符
```
### `SetNoteHLInElement(bool forceSetOff = false, bool SameTheme = false)`
在当前元素内高亮重复时间点的音符
**示例**:
```csharp
SetNoteHLInElement // 在当前选中的Track内高亮
SetNoteHLInElement true // 重置后高亮
```
### `AttachNoteInNearestTrail()`
将轨道上的音符吸附到最近的轨迹线
**示例**:
```csharp
AttachNoteInNearestTrail // 自动吸附所有音符到最近轨迹
```
> **要求**: 必须选中Track对象
## 动画操作
### `swapDisplacement()`
反转位移动画方向(正负值互换)
**示例**:
```csharp
swapDisplacement // 将选中的位移动画反向
```
> **要求**: 选中Displacement元素
### `swapSwirl()`
反转旋转动画方向
**示例**:
```csharp
swapSwirl // 反转旋转动画
```
> **要求**: 选中Swirl元素
### `swapScale()`
反转缩放动画方向
**示例**:
```csharp
swapScale // 反转缩放动画
```
> **要求**: 选中Scale元素
### `FloorAnim()`
为动画属性添加0时刻关键帧
**示例**:
```csharp
FloorAnim // 确保所有动画从时间0开始
```
## 对象管理
### `DelSameInParent()`
删除父对象中所有同类型的兄弟元素(包括自身)
**示例**:
```csharp
DelSameInParent // 删除当前选中类型的所有同级对象
```
### `AdjustPathnodeZ(float OriginZpoint, float scale)`
调整PathNode的Z坐标缩放
**示例**:
```csharp
AdjustPathnodeZ 0 2.0 // 以Z=0为原点2倍缩放
AdjustPathnodeZ 5 0.5 // 以Z=5为原点缩小一半
```
## 高级功能
### `SplitHoldToTrack(int PathnodesCount)`
将选中的Hold音符分割为带路径的新Track
**示例**:
```csharp
SplitHoldToTrack 5 // 分割为5个路径节点的Track
SplitHoldToTrack 10 // 更精细的分割
```
> **要求**: 选中Hold对象父Track为Movable类型
### `SplitAllHoldToTrack(int PathnodesCount)`
将Track下所有Hold音符分割
**示例**:
```csharp
SplitAllHoldToTrack 5 // 分割当前Track下所有Hold音符
```
> **要求**: 选中Track对象
### `Rebuild()`
强制刷新所有游戏元素和轨道路径
**示例**:
```csharp
Rebuild // 完全重建场景,解决显示问题
```
## 使用技巧
### 参数格式
```csharp
// 空格分隔格式
func "abc" 1 2 [0,1,2]
// 括号分隔格式
func("abc", 1, 2, [0,1,2])
// 混合使用
Lgp 10 [0,0,0] [5,5,5] true
```
### 常用工作流示例
**快速创建路径**:
```csharp
// 1. 选择Track
// 2. 生成直线路径
Lgp 8 [0,0,0] [10,0,5]
// 3. 生成螺旋补充
Spiral 12 [5,2,2] 2 6 4
```
**批量处理音符**:
```csharp
// 1. 导入数据
SamplerImport "(Tap, Track1, 5.0, 1.0)"
// 2. 检查重复音符
SetNoteHLInGame
// 3. 吸附到轨迹
AttachNoteInNearestTrail
// 4. 导出验证
ExportNotesFromTrack
```
## 故障排除
- **对象未选中**: "Please select a Track first!"
- **参数错误**: "Loop must be greater than 1!"
- **类型不匹配**: "Please select a Displacement first!"
- **功能未启用**: "Please enable 'Note Prefab' in EditorManager"
使用前请确认:
1. 正确选中目标对象
2. 参数类型和数量匹配
3. 相关功能已启用如Note Prefab
4. 操作前建议保存工程