ImportContextRegistryComponent.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "ImportContextRegistryComponent.h"
  9. #include "ImportContexts/AssImpImportContextProvider.h"
  10. #include <AzCore/Serialization/EditContext.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. #include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
  13. namespace AZ
  14. {
  15. namespace SceneAPI
  16. {
  17. namespace SceneBuilder
  18. {
  19. void ImportContextRegistryComponent::Activate()
  20. {
  21. // Get the import context registy
  22. if (auto* registry = ImportContextRegistryInterface::Get())
  23. {
  24. // Create and register the ImportContextProvider for AssImp
  25. // It should be always present and be used as a fallback if no specialized provider is available
  26. auto assImpContextProvider = aznew AssImpImportContextProvider();
  27. registry->RegisterContextProvider(assImpContextProvider);
  28. AZ_Info("SceneAPI", "AssImp Import Context was registered.\n");
  29. }
  30. else
  31. {
  32. AZ_Error("SceneAPI", false, "ImportContextRegistryInterface not found. AssImp Import Context was not registered.");
  33. }
  34. }
  35. void ImportContextRegistryComponent::Deactivate()
  36. {
  37. }
  38. void ImportContextRegistryComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  39. {
  40. provided.push_back(AZ_CRC_CE("ImportContextRegistryService"));
  41. }
  42. void ImportContextRegistryComponent::Reflect(ReflectContext* context)
  43. {
  44. SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
  45. if (serializeContext)
  46. {
  47. serializeContext->Class<ImportContextRegistryComponent, SceneCore::SceneSystemComponent>()->Version(1)->Attribute(
  48. Edit::Attributes::SystemComponentTags,
  49. AZStd::vector<Crc32>({ Events::AssetImportRequest::GetAssetImportRequestComponentTag() }));
  50. }
  51. }
  52. } // namespace SceneBuilder
  53. } // namespace SceneAPI
  54. } // namespace AZ