warmadon
Topic Author
Posts: 1
Joined: 05 Apr 2024, 23:07

Seeking Assistance with C++ Binding in Unreal Engine 5 to NoesisGui

15 Apr 2024, 22:23

Hello NoesisGui Community,

I am currently in the process of experimenting with NoesisGui within my Unreal Engine 5 project. While I have managed to grasp the basics of binding within the Blend project, I am facing difficulties in implementing bindings directly from C++ code to my NoesisGui UI.

Specifically, I am seeking guidance on how to establish bindings from my C++ code in Unreal Engine 5 to my NoesisGui UI. For instance, I am struggling to figure out how to pass variables such as a PlayerName from my game logic to the NoesisGui UI.

Any insights, tips, or resources on how to achieve this would be greatly appreciated. Thank you in advance for your assistance.

Best regards,
Warmadon
 
User avatar
hcpizzi
Site Admin
Posts: 322
Joined: 09 Feb 2012, 12:40

Re: Seeking Assistance with C++ Binding in Unreal Engine 5 to NoesisGui

16 Apr 2024, 09:29

Hi,

You can go one of two ways. You can use our class and reflection code to create your view model clases and expose the data you want, or you can use UObjects and Unreal's reflection markers.

You probably want the second option. You can find the relevant documentation here: https://www.noesisengine.com/docs/Gui.C ... ty-binding

Let us know if you need further clarification.

Regards,
Juan
 
nevayeshirazi
Posts: 1
Joined: 26 Apr 2024, 03:50

Re: Seeking Assistance with C++ Binding in Unreal Engine 5 to NoesisGui

Today, 05:56

Hello,

I am facing a similar problem.

How should we go for first approach even If we use Unreal? We are not using blueprints at all.

What I have in mind is,
-Loading the Xaml file with unreal as UNoesisXaml object,
-Creating a view in C++ from the Xaml asset,
-Settings the datacontext of view via SetDataContext,
- And finally adding view to viewport.

However, i stuck at creating the the view which should be UUserWidget, i guess?

Thanks for the help in advance.

EDIT:

Ok, I was able to create the widget using UNoesisInstance which inherits from UUserWidget. Then I set the BaseXaml to NXaml which is async loaded when needed.
The widget appears now.
// Create custom UObject DataContext
TestDataContext* DataContext = NewObject<TestDataContext>();
// UNoesisInstance is UUserWidget. Create and add to viewport/screen like regular UMG widgets.
UNoesisInstance* WidgetInst = CreateWidget<UNoesisInstance>(GetWorld(), UNoesisInstance::StaticClass());
WidgetInst ->BaseXaml = Cast<UNoesisXaml>(NXaml.Get());
Widget->SetDataContext(DataContext);
WidgetInst->AddToPlayerScreen();

....
.... 
// This will update the Name UProperty on UObject DataContext and change will be reflected to View.
// Set name must call  NoesisNotifyPropertyChanged(this, "PropertyName");
DataContext->SetName(TEXT("TEST EMRE"));

Best,
Emre
 
User avatar
jsantos
Site Admin
Posts: 3931
Joined: 20 Jan 2012, 17:18
Contact:

Re: Seeking Assistance with C++ Binding in Unreal Engine 5 to NoesisGui

Today, 15:19

Thanks, please next time do not reopen closed threads.

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests