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

Method LoadScene

Source/Engine/Level/Level.cpp:1633–1678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1631}
1632
1633bool Level::LoadScene(const Guid& id)
1634{
1635 // Check ID
1636 if (!id.IsValid())
1637 {
1638 Log::ArgumentException();
1639 return true;
1640 }
1641
1642 // Skip is that scene is already loaded
1643 if (FindScene(id) != nullptr)
1644 {
1645 LOG(Info, "Scene {0} is already loaded.", id);
1646 return false;
1647 }
1648
1649 // Now to deserialize scene in a proper way we need to load scripting
1650 if (!Scripting::IsEveryAssemblyLoaded())
1651 {
1652#if USE_EDITOR
1653 LOG(Error, "Scripts must be compiled without any errors in order to load a scene. Please fix it.");
1654#else
1655 LOG(Warning, "Scripts must be compiled without any errors in order to load a scene.");
1656#endif
1657 return true;
1658 }
1659
1660 // Preload scene asset
1661 const auto sceneAsset = Content::LoadAsync<JsonAsset>(id);
1662 if (sceneAsset == nullptr)
1663 {
1664 LOG(Error, "Cannot load scene asset.");
1665 return true;
1666 }
1667
1668 // Load scene
1669 ScopeLock lock(ScenesLock);
1670 SceneLoader loader;
1671 if (loadScene(loader, sceneAsset) != SceneResult::Success)
1672 {
1673 LOG(Error, "Failed to deserialize scene {0}", id);
1674 CallSceneEvent(SceneEventType::OnSceneLoadError, nullptr, id);
1675 return true;
1676 }
1677 return false;
1678}
1679
1680Scene* Level::LoadSceneFromBytes(const BytesContainer& data)
1681{

Callers

nothing calls this directly

Calls 2

ArgumentExceptionClass · 0.85
IsValidMethod · 0.45

Tested by

no test coverage detected