ScriptProcessorRuleBehavior.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #pragma once
  9. #include <SceneAPI/SceneData/SceneDataConfiguration.h>
  10. #include <AzCore/std/string/string.h>
  11. #include <SceneAPI/SceneCore/Components/BehaviorComponent.h>
  12. #include <SceneAPI/SceneCore/Events/AssetImportRequest.h>
  13. #include <SceneAPI/SceneCore/Components/ExportingComponent.h>
  14. #include <SceneAPI/SceneCore/Events/ExportEventContext.h>
  15. namespace AzToolsFramework
  16. {
  17. class EditorPythonEventsInterface;
  18. }
  19. namespace AZ::SceneAPI::Events
  20. {
  21. class PreExportEventContext;
  22. }
  23. namespace AZ::SceneAPI::Containers
  24. {
  25. class Scene;
  26. }
  27. namespace AZ::SceneAPI::Behaviors
  28. {
  29. class SCENE_DATA_CLASS ScriptProcessorRuleBehavior
  30. : public SceneCore::BehaviorComponent
  31. , public Events::AssetImportRequestBus::Handler
  32. {
  33. public:
  34. AZ_COMPONENT(ScriptProcessorRuleBehavior, "{24054E73-1B92-43B0-AC13-174B2F0E3F66}", SceneCore::BehaviorComponent);
  35. ~ScriptProcessorRuleBehavior() override = default;
  36. SCENE_DATA_API void Activate() override;
  37. SCENE_DATA_API void Deactivate() override;
  38. static void Reflect(ReflectContext* context);
  39. // AssetImportRequestBus::Handler
  40. SCENE_DATA_API Events::ProcessingResult UpdateManifest(
  41. Containers::Scene& scene,
  42. ManifestAction action,
  43. RequestingApplication requester) override;
  44. SCENE_DATA_API void GetManifestDependencyPaths(AZStd::vector<AZStd::string>& paths) override;
  45. protected:
  46. bool LoadPython(const AZ::SceneAPI::Containers::Scene& scene, AZStd::string& scriptPath);
  47. void UnloadPython();
  48. bool DoPrepareForExport(Events::PreExportEventContext& context);
  49. private:
  50. AzToolsFramework::EditorPythonEventsInterface* m_editorPythonEventsInterface = nullptr;
  51. struct ExportEventHandler;
  52. AZStd::shared_ptr<ExportEventHandler> m_exportEventHandler;
  53. };
  54. } // namespace AZ::SceneAPI::Behaviors