//------------------------------------------------------------------------------ static bool ContextMenuTargetProfileImpl::HasAnyExposedComponents(UClass* TargetClass) { for (TFieldIterator<UObjectProperty> PropertyIt(TargetClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UObjectProperty* ObjectProperty = *PropertyIt; if (!ObjectProperty->HasAnyPropertyFlags(CPF_BlueprintVisible) || !ObjectProperty->PropertyClass->IsChildOf<UActorComponent>()) { continue; } return true; } return false; }
void GetEditableComponents( const AActor* InActor, TArray<UActorComponent*>& OutEditableComponents ) { for( TFieldIterator<UObjectProperty> PropIt(InActor->GetClass(), EFieldIteratorFlags::IncludeSuper); PropIt; ++PropIt ) { UObjectProperty* ObjectProp = *PropIt; if( ObjectProp->HasAnyPropertyFlags(CPF_Edit) ) { UObject* ObjPtr = ObjectProp->GetObjectPropertyValue(ObjectProp->ContainerPtrToValuePtr<void>(InActor)); if( ObjPtr && ObjPtr->IsA<UActorComponent>() ) { OutEditableComponents.Add( CastChecked<UActorComponent>( ObjPtr ) ); } } } }
//------------------------------------------------------------------------------ static FBlueprintActionFilter BlueprintActionMenuUtilsImpl::MakeCallOnMemberFilter(FBlueprintActionFilter const& MainMenuFilter) { FBlueprintActionFilter CallOnMemberFilter; CallOnMemberFilter.Context = MainMenuFilter.Context; CallOnMemberFilter.PermittedNodeTypes.Add(UK2Node_CallFunction::StaticClass()); CallOnMemberFilter.AddRejectionTest(FBlueprintActionFilter::FRejectionTestDelegate::CreateStatic(IsUnBoundSpawner)); const UBlueprintEditorSettings* BlueprintSettings = GetDefault<UBlueprintEditorSettings>(); // instead of looking for "ExposeFunctionCategories" on component properties, // we just expose functions for all components, but we still need to check // for "ExposeFunctionCategories" on any non-component properties... if (BlueprintSettings->bExposeAllMemberComponentFunctions) { CallOnMemberFilter.AddRejectionTest(FBlueprintActionFilter::FRejectionTestDelegate::CreateStatic(IsUnexposedNonComponentAction)); } else { CallOnMemberFilter.AddRejectionTest(FBlueprintActionFilter::FRejectionTestDelegate::CreateStatic(IsUnexposedMemberAction)); } for (UClass const* TargetClass : MainMenuFilter.TargetClasses) { for (TFieldIterator<UObjectProperty> PropertyIt(TargetClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt) { UObjectProperty* ObjectProperty = *PropertyIt; if (!ObjectProperty->HasAnyPropertyFlags(CPF_BlueprintVisible) || !(ObjectProperty->PropertyClass->IsChildOf<UActorComponent>() || ObjectProperty->HasMetaData(FBlueprintMetadata::MD_ExposeFunctionCategories))) { continue; } CallOnMemberFilter.Context.SelectedObjects.Add(ObjectProperty); } } return CallOnMemberFilter; }