Why the Dynamic material is always returning NULL in switch case?

Without wasting your time, I am explaining quickly the problem.
1: I have the texture in the data table.
2: I want to grab that texture and set it to the Param2D in the material with the parameter texture name is MaskShirt2D
3: Next I will post the code currently I am trying to achieve this.

Struct


Data Table

Dynamic Material: Material_BodyRef is not null here.

Getting Datas from Data table by ID

Enum
03

Switch: Material_BodyRef is returning null here.

Note: Doing this without changing the texture parameters works fine. The problem is the Material_BodyRef is null only in this switch case statement,

Blueprint Example of what I want to achieve. Doing this with blueprints works fine.

Thank You in advance for helping in my study progress. If You need any additional information just let me know.

Hi Alexa, are you setting the dynamic material in the default constructor or OnConstruction?
Please provide this information I will try to solve, Thanks

Hello, I have a seperate function for this void AMyharacter::InitSkeletalMesh(); and I am calling this function in the default construction once.

your dynamic material will always be nulled while it calls only once on runtime, you have to call InitSkeletalMesh(); under OnConstruciton or call it after you check for case.

How? Please give me a small example. Thank You Sir for Help

void APUBGCharacter::OnConstruction(const FTransform& Transform)
{ //Call Super and then InitSkeletalMesh();}

or


case EFashionType::E_Jacket:
{
			InitSkeletalMesh(); //Calling this here will always return **Material_BodyRef** `!null`
			if (::IsValid(Material_BodyRef))
            {//Logic}
}

cheers.

Working like a Charm :smiley: )
Thank You Sir for Help, really appreciated and I actually learned something big , Thank U for helping me in my Studies.

Calling that function only when it need to be called will save performance, don’t call in tick , you don’t need that to be called every second, only if in EFashionType::E_Jacket: you wil need to call it and in other conditions as I can see in you Enum , you have other cases too.
cheers.

Yes right, I got that Idea, Thank You for the help )