File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed 
crates/bevy_mod_scripting_core/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,20 @@ impl<P: IntoScriptPluginParams> Command for DeleteScript<P> {
5656        // we demote to weak from here on out, so as not to hold the asset hostage 
5757        self . context_key  = self . context_key . into_weak ( ) ; 
5858
59-         // first apply unload callback 
59+         // first check the script exists, if it does not it could have been deleted by another command 
60+         { 
61+             let  script_contexts = world. get_resource_or_init :: < ScriptContext < P > > ( ) ; 
62+             if  !script_contexts. contains ( & self . context_key )  { 
63+                 debug ! ( 
64+                     "{}: No context found for {}, not deleting." , 
65+                     P :: LANGUAGE , 
66+                     self . context_key
67+                 ) ; 
68+                 return ; 
69+             } 
70+         } 
71+ 
72+         // apply unload callback 
6073        Command :: apply ( 
6174            RunScriptCallback :: < P > :: new ( 
6275                self . context_key . clone ( ) , 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments