# GetAllActorsOfClass and GetSelectedActors in Editor Utility Widget seems to returns actors data differently

**URL:** <https://forums.unrealengine.com/t/getallactorsofclass-and-getselectedactors-in-editor-utility-widget-seems-to-returns-actors-data-differently/1867359>\
**Category:** C++\
**Tags:** editor-utility-widge, Code-Plugins, unreal-engine, editor, question, CPP\
**Created:** [May 22, 2024, 7:58am UTC](https://forums.unrealengine.com/t/getallactorsofclass-and-getselectedactors-in-editor-utility-widget-seems-to-returns-actors-data-differently/1867359 "2024-05-22T07:58:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LsMat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lsmat/32/940915_2.png) [@LsMat](https://forums.unrealengine.com/u/LsMat)\
**Post date:** [May 22, 2024, 7:58am UTC](https://forums.unrealengine.com/t/getallactorsofclass-and-getselectedactors-in-editor-utility-widget-seems-to-returns-actors-data-differently/1867359/1 "2024-05-22T07:58:52Z")

</div>

Hi everyone,

I’m creating an Editor Utility Widget to display a list of actors of a specific class or implementing a specific interface, and show some information related to them (the actual implementation is not important).

The problem comes when I need to read that information. To get access to the actors, I’m currently using this:

```auto
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AActor::StaticClass(), FoundActors);

```

But I retrieve no information.

 ![Result with GetAllActorsOfClass](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/d/84d3fee8b41a33d7e4a92d3ce392e781ed848166.png)  
The blue is the list of objects I want to read the information, but it’s empty. The Red are some variables I exposed to better some of the info I need.

However, if I use the selected actor method with this code:

```auto
C++USelection* SelectedActors = GEditor->GetSelectedActors();
TArray<AActor*> Actors;
TArray<ULevel*> UniqueLevels;
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter)
{
	AActor* Actor = Cast<AActor>(*Iter);
	if (Actor)
	{
		FoundActors.Add(Actor);
	}
}

```

I get all the info I want.

 ![Resut with GetSelectedActors](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/9/c19c596c22beb1cd8fda24b46429fa347918c1b8.png)  
I used the same workflow as before, but here I have everything I want.

Honestly, I can’t figure out why this is happening. For more context, I’m executing an Editor Utility Widget from a Toolbar button in a PIE session since it’s during game time that the information I need is available.

Do you know why this is happening and how I can fix it? I basically need a way to get all the actors I need in the level.

Thank you in advance to everyone 👍.

---

<div class="post-metadata">

**Author:** ![LsMat](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/lsmat/32/940915_2.png) [@LsMat](https://forums.unrealengine.com/u/LsMat)\
**Post date:** [May 23, 2024, 12:10pm UTC](https://forums.unrealengine.com/t/getallactorsofclass-and-getselectedactors-in-editor-utility-widget-seems-to-returns-actors-data-differently/1867359/2 "2024-05-23T12:10:48Z")

</div>

**Problem solved!**

I was digging around the `GEditor` pointer when I came across a variable called `TObjectPtr<class UWorld> PlayWorld`. When I checked it out in debug mode, I found all my actors there, with all the right info.

So, I updated my code to this:

```auto
TArray<AActor*> FoundActors;
UGameplayStatics::GetAllActorsOfClass(GEditor->PlayWorld, AActor::StaticClass(), FoundActors);

```

I have some ideas about why `GetWorld()` doesn’t give back as much info as `GEditor->PlayWorld` when used in an Editor Utility Widget window, but I’m not 100% sure.

If anyone knows more about this, I’d love to hear their thoughts. 👍

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 22, 2024, 12:11pm UTC](https://forums.unrealengine.com/t/getallactorsofclass-and-getselectedactors-in-editor-utility-widget-seems-to-returns-actors-data-differently/1867359/3 "2024-06-22T12:11:07Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
