You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: crates/bevy_mod_scripting_bindings/src/globals/core.rs
+42-11Lines changed: 42 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ use ::{
7
7
bevy_reflect::TypeRegistration,
8
8
};
9
9
use bevy_app::App;
10
+
use bevy_log::warn;
10
11
use bevy_mod_scripting_asset::ScriptAsset;
11
12
use bevy_mod_scripting_derive::script_globals;
12
13
use bevy_platform::collections::HashMap;
@@ -63,6 +64,7 @@ impl Plugin for CoreScriptGlobalsPlugin {
63
64
register_core_globals(app.world_mut());
64
65
}
65
66
}
67
+
constMSG_DUPLICATE_GLOBAL:&str = "This can cause confusing issues for script users, use `CoreScriptGlobalsPlugin.filter` to filter out uneeded duplicate types.";
"Duplicate global registration for type: '{}'. {MSG_DUPLICATE_GLOBAL}",
98
+
type_info.type_path_table().short_path()
99
+
)
100
+
};
91
101
}
92
102
}
93
103
94
104
// register basic globals
95
-
global_registry.register_dummy::<World>("world","The current ECS world.");
96
-
global_registry
97
-
.register_dummy::<Entity>("entity","The entity this script is attached to if any.");
98
-
global_registry.register_dummy_typed::<Val<Handle<ScriptAsset>>>("script_asset","the asset handle for this script. If the asset is ever unloaded, the handle will be less useful.");
105
+
if global_registry
106
+
.register_dummy::<World>("world","The current ECS world.")
107
+
.is_some()
108
+
{
109
+
warn!("existing `world` global was replaced by the core `world` dummy type.")
110
+
};
111
+
112
+
if global_registry
113
+
.register_dummy::<Entity>("entity","The entity this script is attached to if any.")
114
+
.is_some()
115
+
{
116
+
warn!("existing `entity` global was replaced by the core `entity` dummy type.")
117
+
}
118
+
119
+
if global_registry.register_dummy_typed::<Val<Handle<ScriptAsset>>>("script_asset","the asset handle for this script. If the asset is ever unloaded, the handle will be less useful.").is_some(){
120
+
warn!("existing `script_asset` global was replaced by the core `script_asset` dummy type.")
121
+
};
99
122
}
100
123
101
124
#[script_globals(bms_bindings_path = "crate", name = "core_globals")]
@@ -128,7 +151,15 @@ impl CoreGlobals {
128
151
let registration = guard.clone().get_type_registration(registration)?;
Copy file name to clipboardExpand all lines: crates/bevy_mod_scripting_derive/src/derive/script_globals.rs
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -42,8 +42,11 @@ pub fn script_globals(
42
42
let registry = world.get_resource_or_init::<#bms_bindings_path::globals::AppScriptGlobalsRegistry>();
43
43
letmut registry = registry.write();
44
44
45
-
registry
46
-
#(#function_registrations)*;
45
+
#(
46
+
if(registry #function_registrations).is_some(){
47
+
warn!("conflicting global registration under name: {}. This might cause confusing problems, use `CoreScriptGlobalsPlugin.filter` to filter out uneeded duplicate types.", stringify!(#function_name))
0 commit comments