I want to create different UObject with a FName, like ‘tree’ → ‘UTreeData’, ‘sword’ → USwordData.
so, NewObject can create UObject, right?
I think if I make(hardcode) a map that store information from a name to a UObject class ?
base on this idea, I create a TMap<FName, TSubclassOf<UObject>>, and do some hardcode.
TMap<FName, TSubclassOf<UObject>> map;
map.Add("Tree", UTreeData::StaticClass())
map.Add("Sword", USwordData::StaticClass())
...
and then, I think I can create a UObject by a FName.
UObject* createObject(FName name) {
auto type = map[name];
return NewObject<type>(this);
}
But compile error, how to fix it?
by the way, I also try to use
TMap<FName, UClass*> // not work
TMap<FName, T> // not work