How to save textures in Developer Settings?

It seems that I am not doing this correctly because the texture map is constantly being erased.

i tried like this too but it does not work neither:

UPROPERTY(EditAnywhere)
TMap<EWeaponType, UTexture*> TargetPointTexture;|

I can’t find any example to do this.

Someone knows how to do it?

Thank you so much!!

I think the problem can be related to this.

3

Is it not possible to load images here in any way?

Thank you very much!!

I don’t think you can use a TMap as a config setting. Change it to a TArray of Struct.

The map works correctly… I have used it on other occasions and there is no problem. I’m pretty sure it’s the texture pointer’s fault. In fact, I just found that wrapping that pointer fixes the problem. I am now going to post the solution I have found. Thank you very much for your answer!!

For some reason if I wrap the pointer everything works fine.

I feel like an idiot. I think I have the solution but I have no idea what is really happening.

-Why (UTexture *Texture) works in a blueprint and doesn’t work in UDeveloperSettings?

-Why wrapping the pointer fixed the problem?

-And most importantly… Why isn’t there anything in the documentation about this?

Any answer to one of these questions. Or a better solution to this problem will be very welcome.

Thank you very much for your help!!

Sorry, you’re right about TMaps. They can be used. There was a time when they didn’t work with UProperties.

Looking at the source code, the header parser complains about raw pointers when they are used, and this is the code for it in HeaderParser.cpp:

if ( VarProperty.IsObjectOrInterface() && VarProperty.Type != CPT_SoftObjectReference && VarProperty.MetaClassDef == nullptr && (VarProperty.PropertyFlags&CPF_Config) != 0 )
	{
		Throwf(TEXT("Not allowed to use 'config' with object variables"));
	}

It looks like it’s a design restriction for anything that uses the config flag.

As for documentation, this is one of the biggest problems with Unreal Engine…

1 Like

Thanks for looking into the problem.

Now that I know this, I have the impression that I am doing something forbidden.

Although everything seems to work fine I’m not sure I’ll continue to use this like this.

It may be that sooner or later something starts to go wrong. Maybe go back to the bluprint and upload the images from there.

Thank you very much for your help!!
Very appreciated!!

1 Like

I’ve been thinking about this for a bit, and I think you can get around this issue by using TSoftObjectPtr<UTexture> tex; in your header file.

Just make sure that you call LoadSynchronous on it when you use it. Ie.:

auto myTex = GetDefault<UGamePlayHUDSettings>()->tex.LoadSynchronous();

1 Like

I will try it. Thank you so much for your help!! :heart:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.