bevy_magic_fx::animated_material

Function build_animated_material

Source
pub fn build_animated_material(
    shader_variant_manifest: &ShaderVariantManifest,
    texture_handles_map: &HashMap<String, Handle<Image>>,
) -> Result<AnimatedMaterial, String>
Examples found in repository?
examples/preview.rs (lines 313-316)
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
fn update_loading_shader_variant_manifest(
    
     

    mut asset_loading_resource: ResMut<AssetLoadingResource>,
    mut animated_materials: ResMut<Assets<AnimatedMaterial>>,


    shader_variant_manifest_resource: Res<Assets<ShaderVariantManifest>>,

    asset_server: ResMut<AssetServer>,

     mut next_state: ResMut<NextState<LoadingState>>,
) {
     
                //once the shader variant loads, we can start loading our magic fx

                for (file_path, shader_manifest_handle) in asset_loading_resource.shader_variants_map.clone().iter() {
             

                     let shader_variant_manifest: &ShaderVariantManifest = shader_variant_manifest_resource
                        .get( shader_manifest_handle.id())
                        .unwrap();

                    //finish loading and building the shader variant and add it to the map 
                    let texture_handles_map = &asset_loading_resource.texture_handles_map;
                    

                        let file_path_clone = file_path.clone();
                    let shadvar_name = AssetPath::parse(file_path_clone.as_str()).path().file_stem().unwrap().to_str().unwrap().to_string()  ;

                    let shader_material_handle = animated_materials.add( build_animated_material(
                        shader_variant_manifest,
                        &texture_handles_map
                        ).expect(format!("Could not load {:?}", &shadvar_name).as_str())
                    ); 
                    println!("adding shadvar_name {:?}",&shadvar_name);

                    asset_loading_resource.animated_material_map.insert( 
                         shadvar_name , 
                        shader_material_handle );

                  // 

                  if asset_loading_resource.animated_material_map.len() 
                     >= asset_loading_resource.shader_variants_map.len() {
                        info!("shaders load ");
                                next_state.set(LoadingState::ShadersLoad);
                   }
                    

                  /* if asset_loading_resource.animated_material_map.clone().into_values().len()   >= 1 {
                       asset_handles_resource.magic_fx_variant_manifest_handle =
                          asset_server.load("magic_fx_variants/waterfall.magicfx.ron");

                   }*/
                        //now that our shadvar materials are built and loaded, we load the magic fx 
                    
                   
                }
       
}