1.9 KiB
1.9 KiB
trigger
| trigger |
|---|
| always_on |
MCP Bridge Development Rules
1. Critical Workflow
- Reload Required: Any changes to
main.js,package.json,scene-script.js, orpanel/MUST be followed by reloading the plugin ("Reload Package") or restarting the editor. Hot reload does not apply to main process scripts. - Test-Driven: Always create a standalone test script in
test/(e.g.,test/test_feature.js) for new features. Tests must direct HTTP requests to verify functionality.
2. Architecture & IPC
- Process Isolation:
scene-script.js(Renderer Process) CANNOT accessEditor.assetdborEditor.FileSystem.main.js(Main Process) CANNOT accesscc(Cocos Engine) directly.- Rule: Resolve asset paths (URL -> UUID) in
main.jsusingEditor.assetdb.urlToUuid()BEFORE callingcallSceneScript. Pass UUIDs to the scene script.
- Logging:
- Use
addLog(type, message)inmain.jsinstead ofconsole.logto ensure logs are captured by theread_consoletool and visible in the panel.
- Use
3. Coding Standards
- Safe Editing: Be extremely careful when editing
main.jsto avoid duplicate code blocks or closing braces. Useview_fileto verify context. - Undo/Redo:
- All scene-modifying actions (node transform, property changes) SHOULD support Undo/Redo.
- Use
Editor.Ipc.sendToMain('scene:undo-record', ...)if modifying via scene script, or wrap operations inmanage_undogroups.
4. Feature Specifics
- Particle Systems (VFX):
- Always set
particleSystem.custom = truewhen modifying properties via script. - Ensure a valid
textureis set (or load a default one likedb://internal/image/default_sprite_splash.png) to avoid invisible particles.
- Always set
- Resource Loading:
- Built-in assets (
db://internal/...) may need specific extensions (.png,.jpg) depending on the editor version. Try multiple paths if lookup fails.
- Built-in assets (