@@ -174,6 +174,7 @@ impl ReflectReferencePrinter {
174
174
}
175
175
id if id == TypeId :: of :: < char > ( ) => downcast_case ! ( v, output, char ) ,
176
176
id if id == TypeId :: of :: < bool > ( ) => downcast_case ! ( v, output, bool ) ,
177
+ id if id == TypeId :: of :: < ScriptValue > ( ) => downcast_case ! ( v, output, ScriptValue ) ,
177
178
_ => {
178
179
output. push_str (
179
180
v. get_represented_type_info ( )
@@ -654,7 +655,7 @@ impl<K: DisplayWithWorld + 'static, V: DisplayWithWorld + 'static> DisplayWithWo
654
655
655
656
#[ cfg( test) ]
656
657
mod test {
657
- use bevy:: prelude:: AppTypeRegistry ;
658
+ use bevy:: { prelude:: AppTypeRegistry , reflect :: Reflect } ;
658
659
659
660
use crate :: bindings:: {
660
661
function:: script_function:: AppScriptFunctionRegistry , AppReflectAllocator ,
@@ -778,4 +779,29 @@ mod test {
778
779
779
780
assert_eq ! ( map. display_value_with_world( world. clone( ) ) , "{hello: true}" ) ;
780
781
}
782
+
783
+ #[ test]
784
+ fn test_script_value_in_reference ( ) {
785
+ let mut world = setup_world ( ) ;
786
+ let world = WorldGuard :: new_exclusive ( & mut world) ;
787
+
788
+ #[ derive( Reflect ) ]
789
+ struct Test {
790
+ val : ScriptValue ,
791
+ }
792
+
793
+ let test = Test {
794
+ val : ScriptValue :: Bool ( true ) ,
795
+ } ;
796
+
797
+ let allocator = world. allocator ( ) ;
798
+ let mut allocator_write = allocator. write ( ) ;
799
+
800
+ let reflect_reference = ReflectReference :: new_allocated ( test, & mut allocator_write) ;
801
+ drop ( allocator_write) ;
802
+ assert_eq ! (
803
+ reflect_reference. display_value_with_world( world. clone( ) ) ,
804
+ "{val: Reflect(ScriptValue(Bool(true)))}"
805
+ ) ;
806
+ }
781
807
}
0 commit comments