FAssetData对象的创建
见#480
FAssetData ShadowCaptureActorAssetData( TEXT("/SURAPlugin/ARShadow/ShadowGenerator/BluePrints/ShadowCapture"), TEXT("/SURAPlugin/ARShadow/ShadowGenerator/BluePrints"), TEXT("ShadowCapture"), TEXT("Blueprint") ); // asset路径在编辑器里通过Reference Viewer可以获得
UE5.1版的新API形式:
// Run test on a single TestPlan asset FName PackageName = FName(FPaths::GetBaseFilename(Path, false)); FName PackagePath = FName(FPaths::GetPath(Path)); FName AssetName = FName(FPaths::GetBaseFilename(Path, true)); FTopLevelAssetPath ClassName = UInterchangeImportTestPlan::StaticClass()->GetClassPathName(); FInterchangeImportTestData& TP = TestPlans.AddDefaulted_GetRef(); TP.AssetData = FAssetData(PackageName, PackagePath, AssetName, ClassName);
UObject类型获取其Asset Path
FTopLevelAssetPath ClassName = UObject::StaticClass()->GetClassPathName(); // // 注意这里UObject类型的AssetPath都是【/Script/Package.Class】的固定格式 // 之所以是这个固定格式,是因为其.generated.h里有DECLARE_CLASS宏调用,其注册的该UObject的PackagePath就是【/Script/Package】的格式 // 例如:/Script/Engine.Blueprint表示Engine模块的UBlueprint // UClass* USuraControlPanelCommonBPLibrary::LoadCppClass( const FString& AssetPath ) { return ::StaticLoadClass(UObject::StaticClass(), nullptr, *AssetPath); }
UObject Paths
Every Asset and Actor that the Unreal Editor has loaded in memory has a path that uniquely identifies it.
In general, these object paths follow the format:
/path/PackageName.ObjectName:SubObjectName.SubObject
Programmers who work with the Engine in C++ may recognize this format as the same one accepted by functions like FindObject() and StaticFindObject().
For example, to deconstruct an Actor path shown in the request examples above:
For example, to deconstruct an Actor path shown in the request examples above:
/Game/ThirdPersonBP/Maps/ | The path to the Asset in the Content Browser. |
ThirdPersonExampleMap.ThirdPersonExampleMap: | The name of the package and the object it contains (for many Assets, these will be the same). |
PersistentLevel.CubeMesh_5.StaticMeshComponent0 | The path through a hierarchy of sub-objects to the object you want to affect. |