UiCanvasAssetRefComponent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <AzCore/Component/Component.h>
  10. #include <LyShine/Bus/UiCanvasManagerBus.h>
  11. #include <LyShine/Bus/World/UiCanvasRefBus.h>
  12. #include <LyShine/UiAssetTypes.h>
  13. ////////////////////////////////////////////////////////////////////////////////////////////////////
  14. class UiCanvasAssetRefComponent
  15. : public AZ::Component
  16. , public UiCanvasRefBus::Handler
  17. , public UiCanvasAssetRefBus::Handler
  18. , public UiCanvasManagerNotificationBus::Handler
  19. {
  20. public: // member functions
  21. AZ_COMPONENT(UiCanvasAssetRefComponent, "{05BED4D7-E331-4020-9C17-BD3F4CE4DE85}");
  22. UiCanvasAssetRefComponent();
  23. // UiCanvasRefInterface
  24. AZ::EntityId GetCanvas() override;
  25. // ~UiCanvasRefInterface
  26. // UiCanvasAssetRefInterface
  27. AZStd::string GetCanvasPathname() override;
  28. void SetCanvasPathname(const AZStd::string& pathname) override;
  29. bool GetIsAutoLoad() override;
  30. void SetIsAutoLoad(bool isAutoLoad) override;
  31. bool GetShouldLoadDisabled() override;
  32. void SetShouldLoadDisabled(bool shouldLoadDisabled) override;
  33. AZ::EntityId LoadCanvas() override;
  34. void UnloadCanvas() override;
  35. // ~UiCanvasAssetRefInterface
  36. // UiCanvasManagerNotification
  37. void OnCanvasUnloaded(AZ::EntityId canvasEntityId) override;
  38. // ~UiCanvasManagerNotification
  39. public: // static member functions
  40. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  41. {
  42. provided.push_back(AZ_CRC("UiCanvasRefService", 0xb4cb5ef4));
  43. }
  44. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  45. {
  46. incompatible.push_back(AZ_CRC("UiCanvasRefService", 0xb4cb5ef4));
  47. }
  48. static void GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
  49. {
  50. }
  51. static void Reflect(AZ::ReflectContext* context);
  52. protected: // member functions
  53. void LaunchUIEditor(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType&);
  54. // AZ::Component
  55. void Activate() override;
  56. void Deactivate() override;
  57. // ~AZ::Component
  58. AZ_DISABLE_COPY_MOVE(UiCanvasAssetRefComponent);
  59. protected: // data
  60. //! Persistent properties
  61. AzFramework::SimpleAssetReference<LyShine::CanvasAsset> m_canvasAssetRef;
  62. bool m_isAutoLoad;
  63. bool m_shouldLoadDisabled;
  64. //! The UI Canvas that is associated with this component entity
  65. AZ::EntityId m_canvasEntityId;
  66. };