mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Getting started with Unreal - lots of confusion

25 Jan 2024, 19:34

I have spent the last couple days looking through the docs and I found information in regards to the usage with Unreal quite scattershot. There is for example the "First steps with Unreal" doc, but it is actually not really a list of first steps but more of a reference to features in no particular order. My issue is that architecturally I still don't quite understand how this is all supposed to be implemented, even though I have quite a bit of experience with UMG and Slate.

There are the samples, so for example something that should be simple like this:
https://github.com/Noesis/Tutorials/tre ... Menu3D/UE4

This does not explain why the UI is implemented in a separate module altogether or whether this is necessary at all. It then refers to "MainWindow.h" which is actually nowhere to be found and produces a 404. In any case, MainMenu.h, MainMenu.cpp, SettingsMenu.h, SettingsMenu.cpp, StartMenu.h and StartMenu.cpp are all created and contain InitializeComponent() and LoadComponent() calls even though the only element that actually contains functionality is OptionSelector. I don't really understand why this is or whether it is necessary.

Then, in BP screenshots I frequently see an Initialize function being called on Views, but I have no idea where that comes from and I don't see it in the overrides for View BPs either.

So to sum it up I am quite confused. I've layouted a quick placeholder HUD UI with two buttons and I'd like to start figuring Noesis out by calling a function when one of the buttons is clicked (maybe opening another Noesis Widget). At this point I do not even know whether this is supposed to happen through a delegate/BP event, this "Command" Binding I have seen and/or something else.

I can handle Slate in C++ just fine yet I still have no idea how to go about this even after all the docs and samples. Any pointers? Thanks!
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

Re: Getting started with Unreal - lots of confusion

25 Jan 2024, 20:26

The examples from GitHub are sometimes very outdated. I just recommend learning with the examples that come with the plugin, starting with the simple ones like the HelloWorld and then moving to Buttons that basically showcases how to react to button clicks with a BP.

We know first time experience with Noesis can be overwhelming sometimes, and we are working on this, but I can assure you that in a few weeks you will start to feel more comfortable with the architecture.

I also recommend reading all the tutorials, not only the Unreal one. They are very important concepts like Data Contexts, Bindings, Converter, Commands that are key to Noesis.
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

26 Jan 2024, 07:32

Just also realized that the plugin does indeed come with its own version of the Samples different from what is on Github and these are much clearer indeed, thanks.
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

27 Jan 2024, 11:33

Okay I think I am getting a decent handle on things, just one thing that I am still not totally clear about - I can bind content properties to BP variables and Command properties to BP functions, but is it correct that any other intrinsic properties of controls (e. g. enabled/disabled state etc) are not directly exposed via BP (like they would be in UMG) and I will need to do this in C++? I tried binding IsEnabled on a button to a bool in my View BP, just like the text/value properties, but that does not work and I get
[2024.01.27-12.57.45:298][737]LogNoesis: Error: 'Converter<BaseComponent>' binding converter failed to convert value '/Engine/Transient.UnrealEdEngine_0:GameInstance_4.N_MainHUDView_C_0' (type 'UI.N_MainHUDView')
[2024.01.27-12.57.45:298][737]LogNoesis: Error: Binding failed: Path=Self, Source=UI.N_MainHUDView(''), Target=Button(''), TargetProperty=UIElement.IsEnabled
Besides this I am currently facing one issue: I am generating a heightmap texture at runtime which is then set to a BP Texture2D variable and then this is bound to a Image Source property in Noesis. However after the initial texture generation, when I overwrite the same texture with new data, the Noesis image does not actually update again even with On Notify Changed - I suspect this is because On Notify only compares the internal runtime name/path, and because this does not change after the texture is redrawn, Noesis does not update anything.
heightmapBP.png
I assume here I am forced to use the TextureSource wrapper via C++?
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Getting started with Unreal - lots of confusion

31 Jan 2024, 21:15

I tried binding IsEnabled on a button to a bool in my View BP, just like the text/value properties, but that does not work
Hi, you should be able to bind to a boolean property. I just tried a simple example like this:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
    <Button Content="Some Button" IsEnabled="{Binding Active}"/>
    <Button Content="Other Button" Margin="10"/>
  </StackPanel>
</Grid>
And then I created a variable named "Active" of type Boolean in the View (which it is set as DataContext by default). If I set the default value of the Active variable to false, then the first Button will be disabled. Setting that variable to true will enable the first Button.

From the error messages it seems that you are trying to bind the whole view object to the IsEnabled property (as shown below), is that what is happening?
<Button IsEnabled="{Binding}"/>
However after the initial texture generation, when I overwrite the same texture with new data, the Noesis image does not actually update again even with On Notify Changed
This could be a bug in our plugin. It is possible that when you update your texture, the internal representation (the TextureRHI) is a new object, and our texture wrapper is not aware of that change and is still rendering the old texture data. Could you please report this in our bugtracker and we will investigate it?
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

01 Feb 2024, 08:04

For 1) the Boolean, I managed to fix this - it seems that Noesis does not like a BP variable starting with a number (understandable, though a warning about this would be helpful) - so e.g. 2XButton does not bind correctly, but X2Button does.

For 2) Thanks, yes I agree something like that is probably happening. If I force the generator to redraw to a new texture every time instead (via CreateTransient()), so that the name of the texture also changes (as UE auto-appends a number), Noesis correctly catches the change. Will figure out how to file this in the bug tracker.
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

03 Feb 2024, 19:15

So (besides the above Texture2D issue) I have nearly fully ported my old UMG/Slate based UI to Noesis now, but one of the last (and biggest) remaining puzzle pieces is the particular text decorator functionality I require. Essentially, similar to e. g. Paradox games, I want to be able to (on a global level) print a string like this to the UI:

"<char id="4"\> <img id="FactionSymbol"> has attacked"

And the tags would be replaced inline by the respective functionality, i.e. with "char" this would link to a character, be replaced with the name, and retrieve some information about them as a tooltip when hovered over, while the img tag could be a arbitrarily specified inline image or a variable.

The UMG RichText class makes this quite simple with decorator classes in C++, which are also very well documented, unfortunately I am struggling to piece this together for Noesis. Buried here I can find that a RichText class with a img markup is already implemented and then there is also a hyperlink tag (which I am not sure whether it can be used for this purpose). However, regarding trying the img markup, I do not really understand how to specifically bind to the Noesis:RichText.Text property as doing it with a simple BP string does not seem to work -
[2024.02.03-17.53.07:805][298]LogNoesis: Error: Binding failed: Path=String, Source=Boxed<String>(''), Target=TextBlock(''), TargetProperty=NoesisGUIExtensions.RichText.Text
And when it comes to the custom "character" decorator I am really not sure how to approach this at all and can't find any relevant examples or documentation, so any help or examples would be appreciated. Thanks.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Getting started with Unreal - lots of confusion

08 Feb 2024, 16:55

The RichText exposed in Noesis is based on the use of Styles as explained in the tutorial you linked.

So each of the tags you specify in the text, like <char>, is mapped to a Style defined in your xaml resources. In the upcoming 3.2.3 version we improved the RichText extension to support not only styles for Inline elements, but any UI element type. This means you will be able to define complex objects like Controls that would be inlined in the text, for example:
<Style x:Key="char" TargetType="Control">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="Control">
        <Grid Background="Transparent" ToolTip="{Binding Character.Description}">
          <TextBlock Text="{Binding Character.Name}"/>
        </Grid>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>
I do not really understand how to specifically bind to the Noesis:RichText.Text property as doing it with a simple BP string does not seem to work
For example, I defined this xaml:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
  <Grid.Resources>
    <Style x:Key="BlueText" TargetType="Span">
      <Setter Property="Foreground" Value="DodgerBlue"/>
    </Style>
  </Grid.Resources>
  <TextBlock noesis:RichText.Text="{Binding ComplexText}" Foreground="White" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
Then exposed a variable named ComplexText in the View that had this default value: "This uses <BlueText>RichText</> to create complex texts."
Hitting play shows the text using the defined style as expected.
·
richtext.png
·
Please let me know if you need more help with this.
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

09 Feb 2024, 20:35

Thanks, I see the new version just came out with this so great timing! Really impressed by the level of support and attention. Seems that styles and templates were the missing key here so I will try to get this to work with the new version and report back with specifics if I still encounter any issues - thanks!
 
mprey
Topic Author
Posts: 10
Joined: 22 Jan 2024, 09:58

Re: Getting started with Unreal - lots of confusion

14 Mar 2024, 09:16

Finally taking another stab at this but unfortunately still can't quite wrap my head around how it's all supposed to come together so I'll first lay out my specific setup:

First I have an internal array of log strings that look like this:
"Day 1, 4h: <char id="552"/> has spawned"

I also have a BP-exposed function that can retrieve information (name etc) about characters via the ID.

Now in my XAML I have a listbox:
<!-- Game log entries -->
<ListBox Grid.Column="0" Height="128" Background="#802E2929" ItemsSource="{Binding LogBoxItems}">
 
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="HorizontalAlignment" Value="Left"/>
        </Style>
    </ListBox.ItemContainerStyle>

    <ListBox.Template>
        <ControlTemplate TargetType="ListBox">
                <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
                    <ItemsPresenter />
                </ScrollViewer>
        </ControlTemplate>
    </ListBox.Template>
</ListBox>
I then have a custom event OnLogAdded in my Main UI Noesis View blueprint, which currently triggers a AddUnique (w/ NotifyChanged) for a bound BP array LogBoxItems, and which should take the newly added log item string and add it to the listbox, but with the char tag replaced by the previously discussed RichText decorator.

And now at this point I am still confused, 1) how do I even make it so that a Listbox item uses RichText? Do I need to do something with ListBox.ItemTemplate/DataTemplate? I cannot find any documentation for this. 2) In the given example with the style definition, wouldn't this mean that for each use of the char tag I would need a separate BP variable binding for a different character? Because if I just update the BP variable when a new log item is added, it would update the content for all the previously added log items too?

The C++ example (SetTryCreateInlineCallback) given in the previously mentioned link makes more sense to me because I imagine I could just retrieve the character data within an "if (Noesis::StrEquals(tagName, "id"))" statement and return the name and other data as a run? But I do not really understand how I would set that up to be used. I assume I have to create a UserControl class in C++ and then somehow set this to be used as the ListBox ItemTemplate?

I hope this all makes sense.

Who is online

Users browsing this forum: No registered users and 3 guests