| 409 | } |
| 410 | |
| 411 | void 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 | |
| 450 | bool Asset::WaitForLoaded(double timeoutInMilliseconds) const |
| 451 | { |
no test coverage detected