Dear Friends at Epic,
What is the best / memory efficient way to dynamically load objects from a supplied path?
I can use the object finder to create an object, but when I try to use the same object finder again it still contains the previously found object, ignoring the new supplied path:
//create a JoySMA class to cover these types of functions for maaaaaany future classes
void AJoySMA::OnRep_SetMaterial()
{
if (MaterialPath == "") return;
//~~~~~~~~~~~~~~~~~~~~~~~
//testing only
if (VictoryPC) VictoryPC->Optimize(MaterialPath);
//the path is the correct new path here
//Load Asset From Path
static ConstructorHelpers::FObjectFinder OnRep_SetMaterialOb(*MaterialPath);
//Asset not found?
if (!OnRep_SetMaterialOb.Object) return;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//testing only
if (VictoryPC) VictoryPC->Optimize("GOT PAST OBJECT FINDER");
if (VictoryPC) VictoryPC->Optimize(VictoryPC->GetObjectPath(OnRep_SetMaterialOb.Object));
//path is still whichever the first constructed object path was
StaticMeshComponent->SetMaterial(0,OnRep_SetMaterialOb.Object);
}
UObjectGlobals.h
I see these functions, but I want to make sure I am not using these functions in a way that would be inefficient
COREUOBJECT_API UObject* StaticLoadObject( UClass* Class, UObject* InOuter, const TCHAR* Name, const TCHAR* Filename = NULL, uint32 LoadFlags = LOAD_None, UPackageMap* Sandbox = NULL, bool bAllowObjectReconciliation = true );
COREUOBJECT_API UClass* StaticLoadClass( UClass* BaseClass, UObject* InOuter, const TCHAR* Name, const TCHAR* Filename, uint32 LoadFlags, UPackageMap* Sandbox );
COREUOBJECT_API UObject* StaticConstructObject( UClass* Class, UObject* InOuter=(UObject*)GetTransientPackage(), FName Name=NAME_None, EObjectFlags SetFlags=RF_NoFlags, UObject* Template=NULL, bool bCopyTransientsFromClassDefaults=false, struct FObjectInstancingGraph* InstanceGraph=NULL );
Thanks!
Rama