PrefabImporter.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <Atomic/Resource/ResourceCache.h>
  2. #include <Atomic/Resource/Image.h>
  3. #include <Atomic/Scene/Scene.h>
  4. #include "Asset.h"
  5. #include "AssetDatabase.h"
  6. #include "PrefabImporter.h"
  7. namespace ToolCore
  8. {
  9. PrefabImporter::PrefabImporter(Context* context, Asset* asset) : AssetImporter(context, asset)
  10. {
  11. requiresCacheFile_ = false;
  12. }
  13. PrefabImporter::~PrefabImporter()
  14. {
  15. }
  16. void PrefabImporter::SetDefaults()
  17. {
  18. AssetImporter::SetDefaults();
  19. }
  20. bool PrefabImporter::Preload()
  21. {
  22. if (!asset_)
  23. return false;
  24. preloadResourceScene_ = new Scene(context_);
  25. SharedPtr<File> file(new File(context_, asset_->GetPath()));
  26. preloadResourceScene_->LoadAsyncXML(file, LOAD_RESOURCES_ONLY);
  27. return true;
  28. }
  29. bool PrefabImporter::Import(const String& guid)
  30. {
  31. AssetDatabase* db = GetSubsystem<AssetDatabase>();
  32. Asset* asset = db->GetAssetByGUID(guid);
  33. if (!asset)
  34. return false;
  35. return true;
  36. }
  37. bool PrefabImporter::LoadSettingsInternal()
  38. {
  39. if (!AssetImporter::LoadSettingsInternal())
  40. return false;
  41. JSONValue import = jsonRoot_.GetChild("PrefabImporter", JSON_OBJECT);
  42. return true;
  43. }
  44. bool PrefabImporter::SaveSettingsInternal()
  45. {
  46. if (!AssetImporter::SaveSettingsInternal())
  47. return false;
  48. JSONValue import = jsonRoot_.CreateChild("PrefabImporter");
  49. return true;
  50. }
  51. }