# Adding an Editor Actor Picker via Slate

**URL:** <https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643>\
**Category:** UI\
**Tags:** unreal-engine, slate, question\
**Created:** [August 28, 2018, 3:44pm UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643 "2018-08-28T15:44:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e0f6c45a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e0f6c45a](https://forums.unrealengine.com/u/anonymous_user_e0f6c45a)\
**Post date:** [August 28, 2018, 3:44pm UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643/1 "2018-08-28T15:44:11Z")

</div>

I am using the following Slate pattern to create a drop down editor menu where I can pick an actor in the scene. While I am able to pick the actor from the dropdown menu, the tooltip on the dropdown menu claims it cannot find the selected object.

```
SNew(SObjectPropertyEntryBox)
.AllowedClass(AActor::StaticClass())
.ObjectPath(this, &SMapSnapper::GetFixedMapString)
.OnObjectChanged(this, &SMapSnapper::FixedMapOnChanged)

```

- SMapSnapper::FixedMapOnChanged  
sets a member variable to the selected actor. This member variable **gets set correctly** even with the displayed error.

- 

I don’t receive the error if the AllowedClass is something other than AActor, i.e., assets, materials, things that are not in the scene.

Perhaps SObjectPropertyEntryBox is not the right tool for this. Also, the broken path SObjectPropertyEntryBox claims is `Game/FirstPersonCpp/Maps/FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.ObjectName`  
which looks like a perfectly reasonable path to me.

 ![251841-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/a/6da4c869f9f8b493aaaf2c8e5d9f2162b153f713.png)

**TLDR: Basically I need a slate version of**

```
UPROPERTY(EditAnywhere)
	AActor* ObjectName;

```

---

<div class="post-metadata">

**Author:** ![unrealsumon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@unrealsumon](https://forums.unrealengine.com/u/unrealsumon)\
**Post date:** [September 26, 2019, 9:41pm UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643/2 "2019-09-26T21:41:16Z")

</div>

Hey, have you found anything yet? If yes then could you please share your solution?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Ungalyant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ungalyant](https://forums.unrealengine.com/u/Ungalyant)\
**Post date:** [September 24, 2020, 11:12am UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643/3 "2020-09-24T11:12:02Z")

</div>

If this is tied to an existing actor property a simple thing you can do is use the property editor module to create a single property entry e.g

```
static FName propertyEditorName("PropertyEditor");
FPropertyEditorModule& propertyModule = FModuleManager::GetModuleChecked<FPropertyEditorModule(propertyEditorName);

FSinglePropertyParams propParams;

TSharedRef<SVerticalBox> box = SNew(SVerticalBox)
						+ SVerticalBox::Slot().AutoHeight().HAlign(HAlign_Fill).Padding(2)
						[
							propertyModule.CreateSingleProperty(YOUR_OBJECT_INSTANCE, GET_MEMBER_NAME_CHECKED(YOUR_CLASS_NAME,
								YOUR_VARIABLE_NAME), propParams).ToSharedRef()
						]

```

Alternatively there’s the PropertyCustomizationHelpers class (where you already found SObjectPropertyEntryBox I suspect) and it has the functions MakeActorPickerWithMenu for example, which I think more directly suit what you seem to need.

Just remember both of these examples need you to include the PropertyEditor in your editorbuild.cs

---

<div class="post-metadata">

**Author:** ![Shen\_Yuju](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shen\_Yuju](https://forums.unrealengine.com/u/Shen_Yuju)\
**Post date:** [November 16, 2023, 7:03pm UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643/4 "2023-11-16T19:03:22Z")

</div>

```auto
// in YourWindow.h
class xxx YourWindow : public SCompoundWidget
{

// other code...

FString ActorPath;
FString HandleActorPath() const {return ActorPath;}
void OnActorChanged(const FAssetData& InAsset) {ActorPath = InAsset.GetObjectPathString();}
}

// in YourWindow.cpp
SNew(SObjectPropertyEntryBox)
		.AllowedClass(AActor::StaticClass())
		.AllowClear(true)
		.DisplayBrowse(true)
		.DisplayUseSelected(true)
		.ObjectPath(this, &YourWindow::HandleActorPath)
		.OnObjectChanged(this, &YourWindow::OnActorChanged);

```

---

<div class="post-metadata">

**Author:** ![CodeWeaver](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/codeweaver/32/1148501_2.png) [@CodeWeaver](https://forums.unrealengine.com/u/CodeWeaver)\
**Post date:** [October 18, 2024, 6:15pm UTC](https://forums.unrealengine.com/t/adding-an-editor-actor-picker-via-slate/432643/5 "2024-10-18T18:15:30Z")

</div>

This helped lead me to the solution to my problem. I was trying to make an Actor Picker that filtered on whether the actor had a specific _ **ActorComponent** _.

I found a guide on filtering here: [Creating Filtered Object Pickers](https://dev.epicgames.com/community/learning/knowledge-base/R8jv/unreal-engine-creating-filtered-object-pickers). But that didn’t allow me to pick _actors_ in the scene.

Using the code posted by @Shen_Yuju, I was able to modify it to get what I needed:

```cpp
void FMyWrapperStructCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> StructPropertyHandle, class FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& StructCustomizationUtils)
{
	TSharedPtr<IPropertyHandle> MyProperty = StructPropertyHandle->GetChildHandle(TEXT("MyPropertyName"));

	HeaderRow.NameContent()
		[
			StructPropertyHandle->CreatePropertyNameWidget()
		]
		.ValueContent()
		[
			SNew(SObjectPropertyEntryBox)
				.AllowedClass(AActor::StaticClass())
				.AllowClear(true)
				.DisplayBrowse(true)
				.DisplayUseSelected(true)
				.PropertyHandle(MyProperty)
				.OnShouldFilterActor(FOnShouldFilterActor::CreateRaw(this, &FMyWrapperStructCustomization::OnShouldFilterActor))
		];
}

bool FMyWrapperStructCustomization::OnShouldFilterActor(const AActor* InActor)
{
	auto Component = InActor->GetComponentByClass(UMyActorComponent::StaticClass());
	return Component != nullptr;
}

```

Thanks @Shen_Yuju! Hope this helps someone in the future!
