GetWorld identifier not found

Hello again,
I have this function (called by a button) but it doesn’t works (GetWorld identifier not found) maybe becase I’m using it in a slate class:

FReply SMyUIWidget::Clicked()
{
	for (TActorIterator<AColorchange> ActorItr(GetWorld()); ActorItr; ++ActorItr){
		ActorItr->carica();
	}
	return FReply::Handled();
}

I’m also not sure about the code inside (since I can’t test it), the function should iterate through the AColorchange actor and call carica() (external function).

Please, can someone give me at least an hint on how to solve my problem? thanks

Hi,

the GetWorld() method can be inherited from AActor or UActorComponent,

so that’s why your class doesn’t know the GetWorld() method.

I would recommend reading this documentation page to understand how properties work, you could get the world member from the currently edited object, or try to get it another way:

Hope this helps.

I missed some logic while i was trying to be fast. You helped me enough to deserve the the “correct answer” (you are also the only one who did it). thanks

How do you make the GetWorld method work in a slate context ?