After pakage animation not work

i use blueprint animation for skeletal mesh

template <typename ObjClass>
	static FORCEINLINE ObjClass* LoadObjFromPath(const FName& Path)
	{
		if (Path == NAME_None) return NULL;
		//~

		return Cast<ObjClass>(StaticLoadObject(ObjClass::StaticClass(), NULL, *Path.ToString()));
	}

static FORCEINLINE UAnimBlueprint* LoadAnimBlueprintFromPath(const FName& Path)
	{
		if (Path == NAME_None) return NULL;
		//~

		return LoadObjFromPath<UAnimBlueprint>(Path);
	}
		UAnimBlueprint* bP = LoadAnimBlueprintFromPath(FName(*Name));
		if (bP.Object && SkeletalMesh)
		{

			SkeletalMesh->SetAnimationMode(EAnimationMode::AnimationBlueprint);
			
			SkeletalMesh->SetAnimInstanceClass(bP->GetAnimBlueprintGeneratedClass());	
		}

in editor it works fine, after pakage it not working …what am I doing wrong?

You may try this,it`s work for me.

UClass* UMyBlueprintFunctionLibrary::getAnimInstanceByName(const FString& Name){

UClass* fAnimBlueprint = StaticLoadClass(UAnimInstance::StaticClass(), nullptr, *Name);
if (fAnimBlueprint != NULL)
	return fAnimBlueprint;
return nullptr;

}

UAnimBlueprint* bP = getAnimInstanceByName(Name);

SkeletalMesh->SetAnimInstanceClass(bP);

and “Name” have to be “/Path/AnimBlueprint.AnimBlueprint_C”