Ivan3z
(Ivan3z)
July 12, 2023, 4:25pm
1
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!!
Ivan3z
(Ivan3z)
July 12, 2023, 6:30pm
2
I think the problem can be related to this.
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.
Ivan3z
(Ivan3z)
July 12, 2023, 7:23pm
4
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!!
Ivan3z
(Ivan3z)
July 12, 2023, 7:26pm
5
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!!
1 Like
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
Ivan3z
(Ivan3z)
July 12, 2023, 9:56pm
7
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
Ivan3z
(Ivan3z)
August 12, 2023, 1:09pm
9
I will try it. Thank you so much for your help!!
1 Like
system
(system)
Closed
September 11, 2023, 1:10pm
10
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.