PrefabTestComponent.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <Prefab/PrefabTestComponent.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. namespace UnitTest
  11. {
  12. void PrefabTestComponent::Reflect(AZ::ReflectContext* reflection)
  13. {
  14. AZ::SerializeContext* serializeContext = AZ::RttiCast<AZ::SerializeContext*>(reflection);
  15. if (serializeContext)
  16. {
  17. serializeContext->Class<PrefabTestComponent, AzToolsFramework::Components::EditorComponentBase>()->
  18. Field("BoolProperty", &PrefabTestComponent::m_boolProperty)->
  19. Field("IntProperty", &PrefabTestComponent::m_intProperty)->
  20. Field("EntityReferenceProperty", &PrefabTestComponent::m_entityIdProperty);
  21. }
  22. }
  23. PrefabTestComponent::PrefabTestComponent(bool boolProperty)
  24. : m_boolProperty(boolProperty)
  25. {
  26. }
  27. void PrefabTestComponentWithUnReflectedTypeMember::Reflect(AZ::ReflectContext* reflection)
  28. {
  29. AZ::SerializeContext* serializeContext = AZ::RttiCast<AZ::SerializeContext*>(reflection);
  30. // We reflect our member but not its type this will result in missing reflection data
  31. // when we try to store or load this field
  32. if (serializeContext)
  33. {
  34. serializeContext->Class<PrefabTestComponentWithUnReflectedTypeMember, AzToolsFramework::Components::EditorComponentBase>()
  35. ->Field("UnReflectedType", &PrefabTestComponentWithUnReflectedTypeMember::m_unReflectedType)
  36. ->Field("ReflectedType", &PrefabTestComponentWithUnReflectedTypeMember::m_reflectedType);
  37. }
  38. }
  39. void PrefabNonEditorComponent::Reflect(AZ::ReflectContext* reflection)
  40. {
  41. AZ::SerializeContext* serializeContext = AZ::RttiCast<AZ::SerializeContext*>(reflection);
  42. if (serializeContext)
  43. {
  44. serializeContext->Class<PrefabNonEditorComponent, AZ::Component>()
  45. ->Field("IntProperty", &PrefabNonEditorComponent::m_intProperty);
  46. }
  47. }
  48. void PrefabNonEditorComponent::Activate()
  49. {
  50. }
  51. void PrefabNonEditorComponent::Deactivate()
  52. {
  53. }
  54. }