Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use bevy::asset::AssetServerSettings;
use bevy::prelude::*;
use bevy::window::PresentMode;
use crate::system::camera::{spawn_orthographic_camera, spawn_ui_camera};
pub mod assets;
pub mod splash_screen;
pub mod system;
#[cfg(target_arch = "wasm32")]
pub fn get_asset_path_string() -> String {
String::from("assets")
}
#[cfg(not(target_arch = "wasm32"))]
pub fn get_asset_path_string() -> String {
std::env::current_dir()
.unwrap()
.join("assets")
.to_str()
.unwrap()
.to_string()
}
pub struct DefaultResourcesPlugin;
impl Plugin for DefaultResourcesPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(WindowDescriptor {
width: 1280.0,
height: 720.0,
resizable: true,
title: String::from("Bevy 2D Template"),
present_mode: PresentMode::Mailbox,
..Default::default()
})
.insert_resource(Msaa { samples: 1 })
.insert_resource(ClearColor(Color::hex("040720").unwrap()))
.insert_resource(AssetServerSettings {
asset_folder: get_asset_path_string(),
watch_for_changes: false,
})
.add_startup_system(spawn_orthographic_camera)
.add_startup_system(spawn_ui_camera);
}
}