123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #include <AzCore/Serialization/SerializeContext.h>
- #include <AzCore/std/smart_ptr/make_shared.h>
- #include <SceneAPI/SceneCore/Containers/Scene.h>
- #include <SceneAPI/SceneCore/Containers/SceneManifest.h>
- #include <SceneAPI/SceneCore/Containers/Utilities/Filters.h>
- #include <SceneAPI/SceneCore/Utilities/Reporting.h>
- #include <Behaviors/LoggingGroupBehavior.h>
- #include <Groups/LoggingGroup.h>
- namespace SceneLoggingExample
- {
-
-
-
- void LoggingGroupBehavior::Reflect(AZ::ReflectContext* context)
- {
-
-
-
-
- LoggingGroup::Reflect(context);
- AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
- if (serializeContext)
- {
- serializeContext->Class<LoggingGroupBehavior, AZ::SceneAPI::SceneCore::BehaviorComponent>()->Version(1);
- }
- }
-
-
-
- void LoggingGroupBehavior::Activate()
- {
- AZ::SceneAPI::Events::ManifestMetaInfoBus::Handler::BusConnect();
- AZ::SceneAPI::Events::AssetImportRequestBus::Handler::BusConnect();
- }
-
- void LoggingGroupBehavior::Deactivate()
- {
- AZ::SceneAPI::Events::ManifestMetaInfoBus::Handler::BusDisconnect();
- AZ::SceneAPI::Events::AssetImportRequestBus::Handler::BusDisconnect();
- }
-
-
-
-
-
-
-
-
- void LoggingGroupBehavior::GetCategoryAssignments(CategoryRegistrationList& categories, [[maybe_unused]] const AZ::SceneAPI::Containers::Scene& scene)
- {
- categories.emplace_back("Logging", LoggingGroup::TYPEINFO_Uuid(), s_loggingPreferredTabOrder);
- }
-
-
-
-
-
-
-
- AZ::SceneAPI::Events::ProcessingResult LoggingGroupBehavior::UpdateManifest(AZ::SceneAPI::Containers::Scene& scene,
- ManifestAction action, [[maybe_unused]] RequestingApplication requester)
- {
- if (action == ManifestAction::ConstructDefault)
- {
- AZStd::shared_ptr<LoggingGroup> group = AZStd::make_shared<LoggingGroup>();
-
-
-
-
-
- AZ::SceneAPI::Events::ManifestMetaInfoBus::Broadcast(
- &AZ::SceneAPI::Events::ManifestMetaInfoBus::Events::InitializeObject, scene, *group);
- if (scene.GetManifest().AddEntry(AZStd::move(group)))
- {
-
- return AZ::SceneAPI::Events::ProcessingResult::Success;
- }
- else
- {
-
-
-
- AZ_TracePrintf(AZ::SceneAPI::Utilities::ErrorWindow, "Unable to add a new logging group.");
- return AZ::SceneAPI::Events::ProcessingResult::Failure;
- }
- }
-
- return AZ::SceneAPI::Events::ProcessingResult::Ignored;
- }
-
-
-
-
-
-
-
-
- void LoggingGroupBehavior::InitializeObject(const AZ::SceneAPI::Containers::Scene& scene, AZ::SceneAPI::DataTypes::IManifestObject& target)
- {
-
- if (!target.RTTI_IsTypeOf(LoggingGroup::TYPEINFO_Uuid()))
- {
- return;
- }
- LoggingGroup* newGroup = azrtti_cast<LoggingGroup*>(&target);
- AZ_Assert(newGroup, "Manifest object has been identified as LoggingGroup, but failed to cast to it.");
-
-
-
- auto values = scene.GetManifest().GetValueStorage();
- auto view = AZ::SceneAPI::Containers::MakeExactFilterView<LoggingGroup>(values);
-
-
- auto last = view.begin();
- while (AZStd::next(last) != view.end())
- {
- ++last;
- }
-
- if (last != view.end())
- {
- newGroup->ShouldLogProcessingEvents(!last->DoesLogProcessingEvents());
- }
-
-
-
- const size_t size = AZStd::distance(view.begin(), view.end());
- newGroup->SetName(AZStd::string::format("Logger_%zu", size));
- }
- }
|