Spawning a Widget from an Object Class

I am trying to spawn a widget from a class that derives from object, when I compile I get the message: “Pin World Context object must have a connection” however the create widget node has no such pin and I am unable to expand it like with other nodes.

Is there any way around this? If needs be I can rework part of my code but I’d like to avoid that if possible.

Cheers!

Screen shot?

Here it’s this node causing the problem, error message is at the bottom.

Hmm, never tried making a widget like that. Seems you can’t create a widget from the object base class. Looks like you need to reparent this BP to an actor class.

World Context Object is a hidden pin. It’s required for nodes, which do need a world to work, and evidently, Create Widget is one of these, meaning you can’t use it from any class, that provides no world (and UObject does not).

Create C++ parent for your UObject and override GetWorld() fund in it.
Implementation would be like:

UWorld* UUiManager::GetWorld() const
{
	if (GetOuter())
	{
		return GetOuter()->GetWorld();
	}
	return nullptr;
}