User avatar
ttermeer-reboundcg
Topic Author
Posts: 19
Joined: 13 Sep 2019, 11:10
Contact:

UE5: How to write converters?

29 Jul 2024, 18:11

I am trying to write converters for UE5 but I am having a hard time finding examples.
So far Noesis is unable to find my class and I have no idea why

here what I wrote so far
#pragma once

#include "CoreMinimal.h"
#include <NsCore/Noesis.h>
#include <NsGui/BaseValueConverter.h>

class StringToUpper final : public Noesis::BaseValueConverter
{
public:
	bool TryConvert(Noesis::BaseComponent* value, const Noesis::Type* targetType,
		Noesis::BaseComponent* parameter, Noesis::Ptr<Noesis::BaseComponent>& result) override;

	NS_DECLARE_REFLECTION(StringToUpper, Noesis::BaseValueConverter)
};
#include "StringToUpper.h"

using namespace Noesis;


////////////////////////////////////////////////////////////////////////////////////////////////////
bool StringToUpper::TryConvert(BaseComponent* value, const Type* targetType,
    BaseComponent* parameter, Noesis::Ptr<BaseComponent>& result)
{
    UE_LOG(LogTemp, Warning, TEXT("StringToUpper::TryConvert"));

    return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
NS_BEGIN_COLD_REGION

NS_IMPLEMENT_REFLECTION_(StringToUpper, "BB2UE5.StringToUpper")
And it is called like this in the XAML:
<UserControl 
...
xmlns:local="clr-namespace:BB2UE5"
...
/>
    <UserControl.Resources>
        <ResourceDictionary>
		<local:StringToUpper x:Key="StringToUpper" />
        </ResourceDictionary>
    </UserControl.Resources>
In the logs it says it unable to find the class:
LogNoesis: Warning: Unknown element type 'local:StringToUpper' (BB2UE5.StringToUpper)
LogNoesis: Warning: StaticResource 'StringToUpper' not found
Any help is appreciated.
 
User avatar
hcpizzi
Site Admin
Posts: 342
Joined: 09 Feb 2012, 12:40

Re: UE5: How to write converters?

29 Jul 2024, 20:22

Hi,

Are you registering your converter? You can see how we do it in our DataBinding sample. We register them in the Game module's StartupModule function and unregister them in the ShutdownModule function.

Please, let us know if that helps.
 
User avatar
ttermeer-reboundcg
Topic Author
Posts: 19
Joined: 13 Sep 2019, 11:10
Contact:

Re: UE5: How to write converters?

30 Jul 2024, 10:39

Thanks! This is what I was missing. It works now :)

Who is online

Users browsing this forum: Bing [Bot] and 1 guest