Bevy 内置模块列表
本页列举的是 Bevy 内置提供的所有重要功能的简略表。
- SystemParams
- Assets
- Bundles
- Resources (Configuration)
- Resources (Engine User)
- Resources (Input)
- Events (Input)
- Events (System/Control)
- Components
- GLTF Asset Labels
- Stages
SystemParams
这些都是可以作为 system 参数使用的特殊类型。
Commands
: 使用 commands 来操作 ECSRes<T>
: 对某个 resource 的共享访问ResMut<T>
: 对某个 resource 的独占访问(可写)Option<Res<T>>
: 对一个可能不存在资源的共享访问Option<ResMut<T>>
: 对一个可能不存在资源的独占访问(可写)Query<T, F = ()>
(可以包含最多 15 种类型的元组): 访问 entities and componentsQuerySet
(最多包含4个查询): 解决 冲突的查询Local<T>
: 本地 system 数据EventReader<T>
: 接收 事件EventWriter<T>
: 发送 事件RemovedComponents<T>
: Component 移除检测NonSend<T>
: 对 Non-Send
(限主线程) 数据的共享访问NonSendMut<T>
: 对 Non-Send
(限主线程) 数据的可写访问Entities
: 底层 ECS 元数据:所有 EntitiesComponents
: 底层 ECS 元数据:所有 ComponentsBundles
: 底层 ECS 元数据: 所有 BundlesArchetypes
: 底层 ECS 元数据: 所有 ArchetypesSystemChangeTick
: 底层 ECS 元数据: 用于监测变化的时钟- 包含以上类型中任何一种的元组,元组成员最多不超过 16 个
你的 system 函数总共最多可以有 16 个参数,如果你需要更多参数,用元组把它们包起来解决这个限制。单个元组最多可以包含 16 个成员,但可以无限地嵌套。
Assets
这些是 Bevy 默认注入的 Assets 类型。
Image
: Pixel data, used as a texture for 2D and 3D rendering; also contains theSamplerDescriptor
for texture filtering settingsTextureAtlas
: 2D "Sprite Sheet" defining sub-images within a single larger imageMesh
: 3D Mesh (geometry data), contains vertex attributes (like position, UVs, normals)Shader
: Raw GPU shader source code, in one of the supported languages (WGSL or SPIR-V)ColorMaterial
: Basic "2D material": contains color, optionally an imageStandardMaterial
: "3D material" with support for Physically-Based RenderingFont
: Font data used for text renderingScene
: Scene composed of literal ECS entities to instantiateDynamicScene
: Scene composed with dynamic typing and reflectionGltf
: GLTF Master Asset: index of the entire contents of a GLTF fileGltfNode
: Logical GLTF object in a sceneGltfMesh
: Logical GLTF 3D model, consisting of multipleGltfPrimitive
sGltfPrimitive
: Single unit to be rendered, contains the Mesh and Material to useAudioSource
: Raw audio data forbevy_audio
FontAtlasSet
: (internal use for text rendering)
Bundles
Bevy 内置的 bundle 类型,用于 spawning 不同种类的普通实体。
Any tuples of up to 15 Component
types are valid bundles.
Bevy 3D:
PerspectiveCameraBundle
: 3D camera with a perspective projectionOrthographicCameraBundle
: Camera with an orthographic projection, 2D or 3DMaterialMeshBundle
: 3D Object/Primitive: a Mesh and the Material to draw it withPbrBundle
: 3D object with the standard Physically-Based Material (MaterialMeshBundle<StandardMaterial>
)DirectionalLightBundle
: 3D directional light (like the sun)PointLightBundle
: 3D point light (like a lamp or candle)
Bevy 2D:
OrthographicCameraBundle
: Camera with an orthographic projection, 2D or 3DSpriteBundle
: 2D sprite, using a whole image (Image
asset)SpriteSheetBundle
: 2D sprite, using a sub-rectangle in a larger image (TextureAtlas
asset)MaterialMesh2dBundle
: 2D shape, with custom Mesh and Material (similar to 3D objects)Text2dBundle
: Text to be drawn in the 2D world (not the UI)
Bevy UI:
UiCameraBundle
: The UI CameraNodeBundle
: Empty node element (like HTML<div>
)ButtonBundle
: Button elementImageBundle
: Image elementTextBundle
: Text element
Resources
Configuration Resources
这些设置资源允许你改变 Bevy 各部分的工作方式。
其中一些会影响引擎的低级初始化,所以必须从一开始初始化时就存在才能生效。你需要在你的 app builder 开始时注入这些资源:
LogSettings
: Configure what messages get logged to the consoleWindowDescriptor
: Settings for the primary application windowWgpuOptions
: Low-level settings for the GPU API and backendsAssetServerSettings
: Advanced configuration of theAssetServer
这些可以在开始初始化时注入,但在运行时(从 system 中)改变也是可以的。
ClearColor
: Global renderer background color to clear the window at the start of each frameAmbientLight
: Global renderer "fake lighting", so that shadows don't look too dark / blackMsaa
: Global renderer setting for Multi-Sample Anti-Aliasing (some platforms might only support the values 1 and 4)GamepadSettings
: Gamepad input device settings, like joystick deadzones and button sensitivities
Engine Resources
这些资源在游戏运行时提供对游戏引擎不同功能的访问。
如果你需要它们的状态,或者控制 Bevy 的各个部分,就可以从你的 systems 中访问它们。
FixedTimesteps
: The state of all registeredFixedTimestep
driversTime
: Global time-related information (current frame delta time, time since startup, etc.)AssetServer
: Control the asset system: Load assets, check load status, etc.Gamepads
: List of IDs for all currently-detected (connected) gamepad devicesWindows
: All the open windows (the primary window + any additional windows in a multi-window gui app)WinitWindows
: Raw state of thewinit
backend for each windowAudio
: Use this to play sounds viabevy_audio
AsyncComputeTaskPool
: Task pool for running background CPU tasksComputeTaskPool
: Task pool where the main app schedule (all the systems) runsIoTaskPool
: Task pool where background i/o tasks run (like asset loading)Diagnostics
: Diagnostic data collected by the engine (like frame times)SceneSpawner
: Direct control over spawning Scenes into the main app World
Input Handling Resources
这些资源代表了不同输入设备的当前状态。从你的 systems 中读取它们来 [处理用户输入][cb::input]。
Input<KeyCode>
: Keyboard key state, as a binary Input valueInput<MouseButton>
: Mouse button state, as a binary Input valueInput<GamepadButton>
: Gamepad buttons, as a binary Input valueAxis<GamepadAxis>
: Analog Axis gamepad inputs (joysticks and triggers)Axis<GamepadButton>
: Gamepad buttons, represented as an analog Axis valueTouches
: The state of all fingers currently touching the touchscreen
Events
Input Events
这些 events 在有设备产生输入时发生。把它们读到 [处理用户输入][cb::input]。
MouseButtonInput
: Changes in the state of mouse buttonsMouseWheel
: Scrolling by a number of pixels or lines (MouseScrollUnit
)MouseMotion
: Relative movement of the mouse (pixels from previous frame), regardless of the OS pointer/cursorCursorMoved
: New position of the OS mouse pointer/cursorKeyboardInput
: Changes in the state of keyboard keys (keypresses, not text)ReceivedCharacter
: Unicode text input from the OS (correct handling of the user's language and layout)TouchInput
: Change in the state of a finger touching the touchscreenGamepadEvent
: Changes in the state of a gamepad or any of its buttons or axesGamepadEventRaw
: Gamepad events unaffected byGamepadSettings
System and Control Events
来自操作系统/窗口系统、或用于控制 Bevy 的事件。
AppExit
: Tell Bevy to shut downCloseWindow
: Tell Bevy to close a windowCreateWindow
: Tell Bevy to open a new windowFileDragAndDrop
: The user drag-and-dropped a file into our appCursorEntered
: OS mouse pointer/cursor entered one of our windowsCursorLeft
: OS mouse pointer/cursor exited one of our windowsWindowCloseRequested
: OS wants to close one of our windowsWindowCreated
: New application window openedWindowFocused
: One of our windows is now focusedWindowMoved
: OS/user moved one of our windowsWindowResized
: OS/user resized one of our windowsWindowScaleFactorChanged
: One of our windows has changed its DPI scaling factorWindowBackendScaleFactorChanged
: OS reports change in DPI scaling factor for a window
Components
太具体地在此列出各个 Component 类型的完整清单用外有限。
请直接查看:(List in API Docs)
以下列出个人认为最重要的内置 Component 类型:
Transform
: Local transform (relative to parent, if any)GlobalTransform
: Global transform (in the world)Parent
: Entity's parent, if in a hierarchyChildren
: Entity's children, if in a hierarchyTimer
: Track if a time interval has elapsedStopwatch
: Track how much time has passedHandle<T>
: Reference to an asset of specific typeVisibility
: Manually control visibility, whether to display the entity (hide/show)RenderLayers
: Group entities into "layers" and control which "layers" a camera should displayCamera
: Camera used for renderingOrthographicProjection
: Orthographic projection for a cameraPerspectiveProjection
: Perspective projection for a cameraSprite
: (2D) Properties of a sprite, using a whole imageTextureAtlasSprite
: (2D) Properties of a sprite, using a sprite sheetPointLight
: (3D) Properties of a point lightDirectionalLight
: (3D) Properties of a directional lightNotShadowCaster
: (3D) Disable entity from producing dynamic shadowsNotShadowReceiver
: (3D) Disable entity from having dynamic shadows of other entitiesWireframe
: (3D) Draw object in wireframe modeNode
: (UI) Mark entity as being controlled by the UI layout systemStyle
: (UI) Layout properties of the nodeButton
: (UI) Marker for a pressable buttonInteraction
: (UI) Track interaction/selection state: if the node is clicked or hovered overText
: Text to be displayed
GLTF Asset Labels
Asset path labels to refer to GLTF sub-assets.
支持以下资产标签({}
是数字索引)。
Scene{}
: 获取 GLTF 场景,作为 Bevy场景
Node{}
: 获取 GLTF Node,作为GltfNode
Mesh{}
: 获取 GLTF Mesh,作为GltfMesh
Mesh{}/Primitive{}
: 获取 GLTF Primitive,作为 BevyMesh
Texture{}
: 获取 GLTF 纹理,作为 BevyImage
Material{}
: 获取 GLTF 材质,作为 BevyStandardMaterial
DefaultMaterial
: 同上一个,如果 GLTF 文件中包含一个没有索引的默认材质,则直接获取该材质。
Stages
在内部,Bevy 至少有这些内置的阶段:
- 在主应用程序(
CoreStage
)中:First
、PreUpdate
、Update
、PostUpdate
、Last
- 在渲染子程序(
RenderStage
)中:Extract
、Prepare
、Queue
、PhaseSort
、Render
、Cleanup