BsEditorResourceLoader.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsEditorResourceLoader.h"
  4. #include "BsProjectLibrary.h"
  5. #include "BsResources.h"
  6. #include "BsProjectResourceMeta.h"
  7. #include "BsDebug.h"
  8. namespace BansheeEngine
  9. {
  10. HResource EditorResourceLoader::load(const Path& path, bool keepLoaded) const
  11. {
  12. ProjectLibrary::LibraryEntry* entry = gProjectLibrary().findEntry(path);
  13. if (entry == nullptr || entry->type == ProjectLibrary::LibraryEntryType::Directory)
  14. return HResource();
  15. ProjectLibrary::ResourceEntry* resEntry = static_cast<ProjectLibrary::ResourceEntry*>(entry);
  16. if (resEntry->meta == nullptr)
  17. {
  18. LOGWRN("Missing .meta file for resource at path: \"" + path.toString() + "\".");
  19. return HResource();
  20. }
  21. String resUUID = resEntry->meta->getUUID();
  22. if (resEntry->meta->getIncludeInBuild())
  23. {
  24. LOGWRN("Dynamically loading a resource at path: \"" + path.toString() + "\" but the resource \
  25. isn't flagged to be included in the build. It may not be available outside of the editor.");
  26. }
  27. return gResources().loadFromUUID(resUUID, false, true, keepLoaded);
  28. }
  29. }