Page 1 of 1

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

Posted: 15 Apr 2024, 22:23
by warmadon
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

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

Posted: 16 Apr 2024, 09:29
by hcpizzi
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

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

Posted: 29 Apr 2024, 05:56
by nevayeshirazi
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

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

Posted: 29 Apr 2024, 15:19
by jsantos
Thanks, please next time do not reopen closed threads.