123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #include "AkRoomComponentDetailsCustomization.h"
- #include "AkRoomComponent.h"
- #include "DetailLayoutBuilder.h"
- #include "DetailCategoryBuilder.h"
- #define LOCTEXT_NAMESPACE "AudiokineticTools"
- FAkRoomComponentDetailsCustomization::FAkRoomComponentDetailsCustomization()
- {
- }
- TSharedRef<IDetailCustomization> FAkRoomComponentDetailsCustomization::MakeInstance()
- {
- return MakeShareable(new FAkRoomComponentDetailsCustomization());
- }
- void FAkRoomComponentDetailsCustomization::CustomizeDetails(const TSharedPtr<IDetailLayoutBuilder>& InDetailBuilder)
- {
- InDetailBuilder->EditCategory("Toggle", FText::GetEmpty(), ECategoryPriority::Important);
- InDetailBuilder->EditCategory("Room", FText::GetEmpty(), ECategoryPriority::TypeSpecific);
- InDetailBuilder->EditCategory("AkEvent", FText::GetEmpty(), ECategoryPriority::TypeSpecific);
- DetailBuilder = InDetailBuilder;
- CustomizeDetails(*InDetailBuilder);
- }
- void FAkRoomComponentDetailsCustomization::CustomizeDetails(IDetailLayoutBuilder& InDetailBuilder)
- {
- TArray<TWeakObjectPtr<UObject>> ObjectsBeingCustomized;
- InDetailBuilder.GetObjectsBeingCustomized(ObjectsBeingCustomized);
- for (TWeakObjectPtr<UObject>& Object : ObjectsBeingCustomized)
- {
- UAkRoomComponent* RoomBeingCustomized = Cast<UAkRoomComponent>(Object.Get());
- if (RoomBeingCustomized)
- {
- UObject* OuterObj = RoomBeingCustomized->GetOuter();
- UActorComponent* OuterComponent = Cast<UActorComponent>(OuterObj);
- AActor* OuterActor = Cast<AActor>(OuterObj);
-
-
- if (OuterComponent == nullptr && OuterActor == nullptr)
- {
- IDetailCategoryBuilder& TransformCategory = InDetailBuilder.EditCategory("TransformCommon", LOCTEXT("TransformCommonCategory", "Transform"), ECategoryPriority::Transform);
- TransformCategory.SetCategoryVisibility(false);
- break;
- }
- }
- }
- if (ObjectsBeingCustomized.Num() != 1)
- {
- return;
- }
- UAkRoomComponent* RoomBeingCustomized = Cast<UAkRoomComponent>(ObjectsBeingCustomized[0].Get());
- if (RoomBeingCustomized)
- {
- IDetailCategoryBuilder& ToggleDetailCategory = InDetailBuilder.EditCategory("Toggle");
- auto EnableHandle = InDetailBuilder.GetProperty("bEnable");
- EnableHandle->SetOnPropertyValueChanged(FSimpleDelegate::CreateSP(this, &FAkRoomComponentDetailsCustomization::OnEnableValueChanged));
- if (!RoomBeingCustomized->bEnable)
- {
- InDetailBuilder.HideCategory("Room");
- }
- }
- }
- void FAkRoomComponentDetailsCustomization::OnEnableValueChanged()
- {
- if (DetailBuilder.IsValid())
- {
- IDetailLayoutBuilder* Layout = nullptr;
- if (auto LockedDetailBuilder = DetailBuilder.Pin())
- {
- Layout = LockedDetailBuilder.Get();
- }
- if (LIKELY(Layout))
- {
- Layout->ForceRefreshDetails();
- }
- }
- }
- #undef LOCTEXT_NAMESPACE
|