MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Reload

Method Reload

Source/Engine/Content/Asset.cpp:411–448  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411void Asset::Reload()
412{
413 // Virtual assets are memory-only so reloading them makes no sense
414 if (IsVirtual())
415 return;
416 PROFILE_CPU_NAMED("Asset.Reload");
417
418 // It's better to call it from the main thread
419 if (IsInMainThread())
420 {
421 LOG(Info, "Reloading asset {0}", ToString());
422
423 WaitForLoaded();
424
425 // Fire event
426 if (!IsInternalType())
427 Content::AssetReloading(this);
428 OnReloading(this);
429
430 ScopeLock lock(Locker);
431
432 if (IsLoaded())
433 {
434 // Unload current data
435 unload(true);
436 Platform::AtomicStore(&_loadState, (int64)LoadState::Unloaded);
437 }
438
439 // Start reloading process
440 startLoading();
441 }
442 else
443 {
444 Function<void()> action;
445 action.Bind<Asset, &Asset::Reload>(this);
446 Task::StartNew(New<MainThreadActionTask>(action, this));
447 }
448}
449
450bool Asset::WaitForLoaded(double timeoutInMilliseconds) const
451{

Callers 4

ApplyChangesMethod · 0.45
CreateMethod · 0.45
CloneAssetFileMethod · 0.45
saveSceneMethod · 0.45

Calls 6

IsVirtualFunction · 0.85
IsInMainThreadFunction · 0.85
StartNewFunction · 0.85
IsLoadedFunction · 0.70
ToStringFunction · 0.50
AtomicStoreFunction · 0.50

Tested by

no test coverage detected