问题描述
在 Amethyst 或许多其他游戏引擎中, for fname in t['files']:
dt = ...
if dt.weekday()==5 and task_id==f'{rg}_file1':
continue
用于逻辑和 update
用于渲染。
Bevy 0.4 引入了状态,但只有 fixed_update
、enter
和 update
生命周期挂钩。
可以使用 exit
模块中的常量创建自定义阶段,但它只会添加 stage
和 POST_UPDATE
。
我的问题在标题中,但此外,如果没有等效项,是否有运行处理渲染的系统的最佳实践?
一个可行的解决方案是制作第二个更新系统(例如称为渲染),但是如果有更好的方法,我的目标是提高性能。
解决方法
我不知道这对您的用例是否有帮助,但在 bevy 0.4 announcement 中的示例表明可以使用 FixedTimestep
创建舞台。
因此使用 0.4 公告中的示例作为基础:
use bevy::prelude::*;
use bevy::core::FixedTimestep;
fn main() {
let target_rate = 60.0;
App::build()
// Add the default plugins to open a window
.add_plugins(DefaultPlugins)
.add_stage_after(
stage::UPDATE,"fixed_update",SystemStage::parallel()
// Set the stage criteria to run the system at the target
// rate per seconds
.with_run_criteria(FixedTimestep::steps_per_second(target_rate))
.with_system(my_system.system()),)
.run();
}
也许这种方法没有优化(我不完全知道 FixedTimestep
标准在内部是如何工作的),但在大多数情况下应该足够了。
编辑
我发现可以使用 render App stages 作为舞台名称,这应该更符合您的需求:
use bevy::prelude::*;
fn main() {
App::build()
// Add the default plugins to open a window
.add_plugins(DefaultPlugins)
.add_system_to_stage(bevy::render::stage::RENDER,my_system.system())
.run();
}