MaterialRule.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <AzCore/RTTI/ReflectContext.h>
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. #include <AzCore/Serialization/EditContext.h>
  12. #include <SceneAPI/SceneData/Rules/MaterialRule.h>
  13. namespace AZ
  14. {
  15. namespace SceneAPI
  16. {
  17. namespace SceneData
  18. {
  19. AZ_CLASS_ALLOCATOR_IMPL(MaterialRule, SystemAllocator);
  20. MaterialRule::MaterialRule()
  21. : m_removeMaterials(false)
  22. , m_updateMaterials(false)
  23. {
  24. }
  25. bool MaterialRule::RemoveUnusedMaterials() const
  26. {
  27. return m_removeMaterials;
  28. }
  29. bool MaterialRule::UpdateMaterials() const
  30. {
  31. return m_updateMaterials;
  32. }
  33. void MaterialRule::Reflect(ReflectContext* context)
  34. {
  35. SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context);
  36. if (!serializeContext)
  37. {
  38. return;
  39. }
  40. serializeContext->Class<MaterialRule, DataTypes::IMaterialRule>()->Version(2)
  41. ->Field("updateMaterials", &MaterialRule::m_updateMaterials)
  42. ->Field("removeMaterials", &MaterialRule::m_removeMaterials);
  43. EditContext* editContext = serializeContext->GetEditContext();
  44. if (editContext)
  45. {
  46. editContext->Class<MaterialRule>("Material", "Determine whether to accept material updates from the source files.")
  47. ->ClassElement(Edit::ClassElements::EditorData, "")
  48. ->Attribute("AutoExpand", true)
  49. ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "")
  50. ->DataElement(Edit::UIHandlers::Default, &MaterialRule::m_updateMaterials, "Update materials", "Checking this box will accept changes made in the source file into the Open 3D Engine asset.")
  51. ->DataElement(Edit::UIHandlers::Default, &MaterialRule::m_removeMaterials, "Remove unused materials","Detects and removes material files from the game project that are not present in the source file.");
  52. }
  53. }
  54. } // namespace SceneData
  55. } // namespace SceneAPI
  56. } // namespace AZ