EditorEntityReferenceComponent.cpp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <Scripting/EditorEntityReferenceComponent.h>
  9. namespace AZ
  10. {
  11. namespace Render
  12. {
  13. void EditorEntityReferenceComponent::Reflect(AZ::ReflectContext* context)
  14. {
  15. BaseClass::Reflect(context);
  16. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  17. {
  18. serializeContext->Class<EditorEntityReferenceComponent, BaseClass>()
  19. ->Version(0);
  20. if (AZ::EditContext* editContext = serializeContext->GetEditContext())
  21. {
  22. editContext->Class<EditorEntityReferenceComponent>(
  23. "Entity Reference", "Contains a reference list to other entities")
  24. ->ClassElement(Edit::ClassElements::EditorData, "")
  25. ->Attribute(Edit::Attributes::Category, "Miscellaneous")
  26. ->Attribute(AZ::Edit::Attributes::Icon, "Icons/Components/Component_Placeholder.svg")
  27. ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/Components/Viewport/Component_Placeholder.svg")
  28. ->Attribute(Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
  29. ->Attribute(Edit::Attributes::AutoExpand, true)
  30. ->Attribute(Edit::Attributes::HelpPageURL, "https://o3de.org/docs/user-guide/components/reference/atom/entity-reference/")
  31. ;
  32. editContext->Class<EntityReferenceComponentController>("EntityReferenceComponentController", "")
  33. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  34. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  35. ->DataElement(AZ::Edit::UIHandlers::Default, &EntityReferenceComponentController::m_configuration, "Configuration", "")
  36. ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly)
  37. ;
  38. editContext->Class<EntityReferenceComponentConfig>("EntityReferenceComponentConfig", "")
  39. ->DataElement(AZ::Edit::UIHandlers::Default, &EntityReferenceComponentConfig::m_entityIdReferences, "EntityIdReferences", "List of references to other entities.")
  40. ;
  41. ;
  42. }
  43. }
  44. if (auto behaviorContext = azrtti_cast<BehaviorContext*>(context))
  45. {
  46. behaviorContext->Class<EditorEntityReferenceComponent>()->RequestBus("EntityReferenceRequestBus");
  47. behaviorContext->ConstantProperty("EditorEntityReferenceComponentTypeId", BehaviorConstant(Uuid(EditorEntityReferenceComponentTypeId)))
  48. ->Attribute(AZ::Script::Attributes::Module, "render")
  49. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation);
  50. }
  51. }
  52. EditorEntityReferenceComponent::EditorEntityReferenceComponent(const EntityReferenceComponentConfig& config)
  53. : BaseClass(config)
  54. {
  55. }
  56. AZ::u32 EditorEntityReferenceComponent::OnConfigurationChanged()
  57. {
  58. return Edit::PropertyRefreshLevels::AttributesAndValues;
  59. }
  60. }
  61. }