Space Editor 使用教程
space_editor bevy prefab editor 项目地址: https://gitcode.com/gh_mirrors/spa/space_editor
1. 项目介绍
Space Editor 是一款为 Bevy 游戏引擎设计的场景/预制体/原型编辑工具。它允许用户以快速且直观的 GUI 方式创建和修改等级/场景/预制体。该项目旨在成为 Bevy 引擎的编辑器,因为在 Bevy 中并没有官方的编辑器。
Space Editor 的主要特点包括:
- 直观的场景和预制体管理
- 与 bevy_xpbd_3d 兼容
- 基于 Gizmo 的操作
- 组件值编辑
- 无缝编辑器-游戏切换
- 预制体可重用性
- 许多自定义组件
- 易于定制的 API
- 事件调度
- API 用于添加标签
2. 项目快速启动
在开始之前,请确保你已经安装了 Rust 和 Cargo。
克隆项目
git clone https://github.com/rewin123/space_editor.git
cd space_editor
运行编辑器
cargo run
运行示例游戏
cargo run --example platformer --features bevy_xpbd_3d
请注意,示例游戏和编辑器的逻辑都位于 game/
文件夹中。
3. 应用案例和最佳实践
集成 Space Editor 作为游戏插件
要在你的游戏中使用 Space Editor 创建的预制体,你可以按照以下步骤进行:
首先,在你的 Cargo.toml
文件中添加以下依赖:
[dependencies]
space_editor = { git = "https://github.com/rewin123/space_editor.git" }
然后,在你的游戏应用中添加 Space Editor 插件:
App::build()
.add_plugins(DefaultPlugins)
.add_plugins(PrefabPlugin)
.add_startup_system(startup.system())
.run();
对于预制体的生成,使用 PrefabBundle
:
commands.spawn(PrefabBundle::new("cube.scn.ron")).insert(Name::new("Prefab"));
定制化
更详细的定制化信息可以在 docs/README.md
中找到。你可以通过以下方式向编辑器 GUI 和预制体生成系统中添加自定义类型:
use editor::prelude::EditorRegistryExt;
app.editor_registry::<Name>();
事件
你可以通过以下方式向编辑器 UI 添加自定义事件:
#[derive(Event, Default, Resource, Reflect, Clone)]
pub struct Name;
use editor::prelude::EditorRegistryExt;
app.editor_registry_event::<Name>();
4. 典型生态项目
目前,Space Editor 作为一个开源项目,已经在 GitHub 上积累了一定的关注者和贡献者。一些典型的生态项目可能包括集成 Space Editor 的游戏项目,或者是对 Space Editor 进行扩展和定制的项目。由于项目是开源的,社区成员可以自由地分享他们基于 Space Editor 开发的新特性和改进。
space_editor bevy prefab editor 项目地址: https://gitcode.com/gh_mirrors/spa/space_editor
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考