void UAssetObjectProperty::ExportTextItem( FString& ValueStr, const void* PropertyValue, const void* DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope ) const { FAssetPtr& AssetPtr = *(FAssetPtr*)PropertyValue; FStringAssetReference ID; UObject *Object = AssetPtr.Get(); if (Object) { // Use object in case name has changed. ID = FStringAssetReference(Object); } else { ID = AssetPtr.GetUniqueID(); } if (!ID.ToString().IsEmpty()) { ValueStr += ID.ToString(); } else { ValueStr += TEXT("None"); } }
void UAssetObjectProperty::ExportTextItem( FString& ValueStr, const void* PropertyValue, const void* DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope ) const { FAssetPtr& AssetPtr = *(FAssetPtr*)PropertyValue; FStringAssetReference ID; UObject *Object = AssetPtr.Get(); if (Object) { // Use object in case name has changed. ID = FStringAssetReference(Object); } else { ID = AssetPtr.GetUniqueID(); } if (0 != (PortFlags & PPF_ExportCpp)) { ValueStr += FString::Printf(TEXT("FStringAssetReference(TEXT(\"%s\"))"), *ID.ToString().ReplaceCharWithEscapedChar()); return; } if (!ID.ToString().IsEmpty()) { ValueStr += ID.ToString(); } else { ValueStr += TEXT("None"); } }
AUTDomGameMode::AUTDomGameMode(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { GameStateClass = AUTDomGameState::StaticClass(); TeamClass = AUTDomTeamInfo::StaticClass(); SquadType = AUTDomSquadAI::StaticClass(); HUDClass = AUTHUD_DOM::StaticClass(); GameMessageClass = UUTDomGameMessage::StaticClass(); MapPrefix = TEXT("DOM"); bAllowOvertime = false; bUseTeamStarts = false; //bAllowURLTeamCountOverride = true; NumTeams = 2; MaxSquadSize = 2; MaxControlPoints = 3; bAllowTranslocator = true; bHideInUI = false; //Add the translocator static ConstructorHelpers::FObjectFinder<UClass> WeapTranslocator(TEXT("BlueprintGeneratedClass'/Game/RestrictedAssets/Weapons/Translocator/BP_Translocator.BP_Translocator_C'")); DefaultInventory.Add(WeapTranslocator.Object); TranslocatorObject = FStringAssetReference(TEXT("/Game/RestrictedAssets/Weapons/Translocator/BP_Translocator.BP_Translocator_C")); TeamColors[0] = FLinearColor(1.15f, 0.0f, 0.0f, 0.72f); TeamColors[1] = FLinearColor(0.0f, 0.0f, 1.2f, 0.72f); TeamColors[2] = FLinearColor(0.0f, 1.20f, 0.0f, 0.72f); TeamColors[3] = FLinearColor(1.15f, 1.15f, 0.0f, 0.72f); }
UResMgr::UResMgr() : Super() { mAssetLoader = new FStreamableManager(); //¼ÓÔØUResDataBaseÀ¶Í¼Àà UObject* obj = mAssetLoader->SynchronousLoad(FStringAssetReference(TEXT("/Game/TopDownCPP/Blueprints/Data/ResDataBaseBp"))); mResDB = Cast<UResDataBase>(obj); if ( mResDB != nullptr) { UE_LOG(ResLogger, Warning, TEXT("--- UResMgr::UResMgr, load ResDataBaseBp success")); } }
ULevelEditorViewportSettings::ULevelEditorViewportSettings( const FObjectInitializer& ObjectInitializer ) : Super(ObjectInitializer) { bLevelStreamingVolumePrevis = false; BillboardScale = 1.0f; TransformWidgetSizeAdjustment = 0.0f; MeasuringToolUnits = MeasureUnits_Centimeters; // Set a default preview mesh PreviewMeshes.Add(FStringAssetReference("/Engine/EditorMeshes/ColorCalibrator/SM_ColorCalibrator.SM_ColorCalibrator")); }
FStringAssetReference UBlueprintFunctionLibrary::Generic_MakeStringAssetReference(FFrame& Stack, const FString& AssetLongPathname) { FStringAssetReference Ref(AssetLongPathname); if (!AssetLongPathname.IsEmpty() && !Ref.IsValid()) { FBlueprintExceptionInfo Info(EBlueprintExceptionType::FatalError, NSLOCTEXT("BlueprintFunctionLibrary", "AssetStringInvalid", "Asset path not valid. Only long path name is allowed.")); FBlueprintCoreDelegates::ThrowScriptException(Stack.Object, Stack, Info); return FStringAssetReference(); } return Ref; }
void FBlueprintNativeCodeGenModule::ReadConfig() { GConfig->GetArray(TEXT("BlueprintNativizationSettings"), TEXT("ExcludedAssetTypes"), ExcludedAssetTypes, GEditorIni); { TArray<FString> ExcludedBlueprintTypesPath; GConfig->GetArray(TEXT("BlueprintNativizationSettings"), TEXT("ExcludedBlueprintTypes"), ExcludedBlueprintTypesPath, GEditorIni); for (FString& Path : ExcludedBlueprintTypesPath) { TAssetSubclassOf<UBlueprint> ClassPtr; ClassPtr = FStringAssetReference(Path); ClassPtr.LoadSynchronous(); ExcludedBlueprintTypes.Add(ClassPtr); } } TArray<FString> ExcludedAssetPaths; GConfig->GetArray(TEXT("BlueprintNativizationSettings"), TEXT("ExcludedAssets"), ExcludedAssetPaths, GEditorIni); for (FString& Path : ExcludedAssetPaths) { ExcludedAssets.Add(FStringAssetReference(Path)); } }
FArchive& FLinkerSave::operator<<( FAssetPtr& AssetPtr) { FStringAssetReference ID; UObject *Object = AssetPtr.Get(); if (Object) { // Use object in case name has changed. ID = FStringAssetReference(Object); } else { ID = AssetPtr.GetUniqueID(); } ID.Serialize(*this); return *this; }
FStringAssetReference FStringAssetReference::GetOrCreateIDForObject(const class UObject *Object) { check(Object); return FStringAssetReference(Object); }
void ADA2UE4Creature::InitDefaultMeshes(int32 HEDID, int32 ARMID, int32 BOOID, int32 GLVID, int32 HARID, int32 EYEID) { LoadedMeshesDatabase = NewObject<UDA2UE4MeshDataAsset>(); //head LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[0].MeshID = 0; LoadedMeshesDatabase->MeshList[0].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_uhm_basa_0.hm_uhm_basa_0"); LoadedMeshesDatabase->MeshList[0].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/uh_hed_masa_Mat.uh_hed_masa_Mat"); //arm LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[1].MeshID = 1; LoadedMeshesDatabase->MeshList[1].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_arm_lgtd_0.hm_arm_lgtd_0"); LoadedMeshesDatabase->MeshList[1].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/pm_arm_lgtd_Mat.pm_arm_lgtd_Mat"); //boots LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[2].MeshID = 2; LoadedMeshesDatabase->MeshList[2].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_boo_lgtd_0.hm_boo_lgtd_0"); LoadedMeshesDatabase->MeshList[2].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/pn_boo_lgtd_Mat.pn_boo_lgtd_Mat"); //gloves LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[3].MeshID = 3; LoadedMeshesDatabase->MeshList[3].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_glv_lgtd_0.hm_glv_lgtd_0"); LoadedMeshesDatabase->MeshList[3].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/pn_glv_lgtd_Mat.pn_glv_lgtd_Mat"); //hair LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[4].MeshID = 4; LoadedMeshesDatabase->MeshList[4].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_har_ha1a_0.hm_har_ha1a_0"); LoadedMeshesDatabase->MeshList[4].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/pn_har_blda_Mat.pn_har_blda_Mat"); //eyes LoadedMeshesDatabase->MeshList.Add(FMeshInfo()); LoadedMeshesDatabase->MeshList[5].MeshID = 5; LoadedMeshesDatabase->MeshList[5].MeshResource = FStringAssetReference("/Game/Data/Art/Meshes/UTC/hm_uem_basa_0.hm_uem_basa_0"); LoadedMeshesDatabase->MeshList[5].MeshMat = FStringAssetReference("/Game/Data/Art/Textures/UTC/pn_eye_nrma_Mat.pn_eye_nrma_Mat"); // Registers the loading requests ChangeHEDMeshByID(HEDID); ChangeARMMeshByID(ARMID); ChangeBOOMeshByID(BOOID); ChangeGLVMeshByID(GLVID); ChangeHARMeshByID(HARID); ChangeEYEMeshByID(EYEID); ChangeHEDMatByID(HEDID); ChangeARMMatByID(ARMID); ChangeBOOMatByID(BOOID); ChangeGLVMatByID(GLVID); ChangeHARMatByID(HARID); ChangeEYEMatByID(EYEID); }
/** * Runs compile-on-load test against all unloaded, and optionally loaded, blueprints * See the TestAllBlueprints config key in the [Automation.Blueprint] config sections */ bool FBlueprintCompileOnLoadTest::RunTest(const FString& BlueprintAssetPath) { FCompilerResultsLog Results; UBlueprint* ExistingBP = nullptr; // if this blueprint was already loaded, then these tests are invalidated // (because dependencies have already been loaded) if (FBlueprintAutomationTestUtilities::IsBlueprintLoaded(BlueprintAssetPath, &ExistingBP)) { if (FBlueprintAutomationTestUtilities::IsAssetUnsaved(BlueprintAssetPath)) { AddError(FString::Printf(TEXT("You have unsaved changes made to '%s', please save them before running this test."), *BlueprintAssetPath)); return false; } else { AddWarning(FString::Printf(TEXT("Test may be invalid (the blueprint is already loaded): '%s'"), *BlueprintAssetPath)); FBlueprintAutomationTestUtilities::UnloadBlueprint(ExistingBP); } } // tracks blueprints that were already loaded (and cleans up any that were // loaded in its lifetime, once it is destroyed) FScopedBlueprintUnloader NewBlueprintUnloader(/*bAutoOpenScope =*/true, /*bRunGCOnCloseIn =*/true); // We load the blueprint twice and compare the two for discrepancies. This is // to bring dependency load issues to light (among other things). If a blueprint's // dependencies are loaded too late, then this first object is the degenerate one. UBlueprint* InitialBlueprint = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath)); // if we failed to load it the first time, then there is no need to make a // second attempt, leave them to fix up this issue first if (InitialBlueprint == NULL) { AddError(*FString::Printf(TEXT("Unable to load blueprint for: '%s'"), *BlueprintAssetPath)); return false; } if (!InitialBlueprint->SkeletonGeneratedClass || !InitialBlueprint->GeneratedClass) { AddError(*FString::Printf(TEXT("Unable to load blueprint for: '%s'. Probably it derives from an invalid class."), *BlueprintAssetPath)); return false; } // GATHER SUBOBJECTS TArray<TWeakObjectPtr<UObject>> InitialBlueprintSubobjects; { TArray<UObject*> InitialBlueprintSubobjectsPtr; GetObjectsWithOuter(InitialBlueprint, InitialBlueprintSubobjectsPtr); for (auto Obj : InitialBlueprintSubobjectsPtr) { InitialBlueprintSubobjects.Add(Obj); } } // GATHER DEPENDENCIES TSet<TWeakObjectPtr<UBlueprint>> BlueprintDependencies; { TArray<UBlueprint*> DependentBlueprints; FBlueprintEditorUtils::GetDependentBlueprints(InitialBlueprint, DependentBlueprints); for (auto BP : DependentBlueprints) { BlueprintDependencies.Add(BP); } } BlueprintDependencies.Add(InitialBlueprint); // GATHER DEPENDENCIES PERSISTENT DATA struct FReplaceInnerData { TWeakObjectPtr<UClass> Class; FStringAssetReference BlueprintAsset; }; TArray<FReplaceInnerData> ReplaceInnerData; for (auto BPToUnloadWP : BlueprintDependencies) { auto BPToUnload = BPToUnloadWP.Get(); auto OldClass = BPToUnload ? *BPToUnload->GeneratedClass : NULL; if (OldClass) { FReplaceInnerData Data; Data.Class = OldClass; Data.BlueprintAsset = FStringAssetReference(BPToUnload); ReplaceInnerData.Add(Data); } } // store off data for the initial blueprint so we can unload it (and reconstruct // later to compare it with a second one) TArray<uint8> InitialLoadData; FObjectWriter(InitialBlueprint, InitialLoadData); // grab the name before we unload the blueprint FName const BlueprintName = InitialBlueprint->GetFName(); // unload the blueprint so we can reload it (to catch any differences, now // that all its dependencies should be loaded as well) //UNLOAD DEPENDENCIES, all circular dependencies will be loaded again // unload the blueprint so we can reload it (to catch any differences, now // that all its dependencies should be loaded as well) for (auto BPToUnloadWP : BlueprintDependencies) { if (auto BPToUnload = BPToUnloadWP.Get()) { FBlueprintAutomationTestUtilities::UnloadBlueprint(BPToUnload); } } // this blueprint is now dead (will be destroyed next garbage-collection pass) UBlueprint* UnloadedBlueprint = InitialBlueprint; InitialBlueprint = NULL; // load the blueprint a second time; if the two separately loaded blueprints // are different, then this one is most likely the choice one (it has all its // dependencies loaded) UBlueprint* ReloadedBlueprint = Cast<UBlueprint>(StaticLoadObject(UBlueprint::StaticClass(), NULL, *BlueprintAssetPath)); UPackage* TransientPackage = GetTransientPackage(); FName ReconstructedName = MakeUniqueObjectName(TransientPackage, UBlueprint::StaticClass(), BlueprintName); // reconstruct the initial blueprint (using the serialized data from its initial load) EObjectFlags const StandardBlueprintFlags = RF_Public | RF_Standalone | RF_Transactional; InitialBlueprint = ConstructObject<UBlueprint>(UBlueprint::StaticClass(), TransientPackage, ReconstructedName, StandardBlueprintFlags | RF_Transient); FObjectReader(InitialBlueprint, InitialLoadData); { TMap<UObject*, UObject*> ClassRedirects; for (auto& Data : ReplaceInnerData) { UClass* OriginalClass = Data.Class.Get(); UBlueprint* NewBlueprint = Cast<UBlueprint>(Data.BlueprintAsset.ResolveObject()); UClass* NewClass = NewBlueprint ? *NewBlueprint->GeneratedClass : NULL; if (OriginalClass && NewClass) { ClassRedirects.Add(OriginalClass, NewClass); } } // REPLACE OLD DATA FArchiveReplaceObjectRef<UObject>(InitialBlueprint, ClassRedirects, /*bNullPrivateRefs=*/false, /*bIgnoreOuterRef=*/true, /*bIgnoreArchetypeRef=*/false); for (auto SubobjWP : InitialBlueprintSubobjects) { if (auto Subobj = SubobjWP.Get()) { FArchiveReplaceObjectRef<UObject>(Subobj, ClassRedirects, /*bNullPrivateRefs=*/false, /*bIgnoreOuterRef=*/true, /*bIgnoreArchetypeRef=*/false); } } UPackage* AssetPackage = ReloadedBlueprint->GetOutermost(); bool bHasUnsavedChanges = AssetPackage->IsDirty(); FBlueprintEditorUtils::RefreshAllNodes(ReloadedBlueprint); AssetPackage->SetDirtyFlag(bHasUnsavedChanges); } // look for diffs between subsequent loads and log them as errors TArray<FDiffSingleResult> BlueprintDiffs; bool bDiffsFound = FBlueprintAutomationTestUtilities::DiffBlueprints(InitialBlueprint, ReloadedBlueprint, BlueprintDiffs); if (bDiffsFound) { FBlueprintAutomationTestUtilities::ResolveCircularDependencyDiffs(ReloadedBlueprint, BlueprintDiffs); // if there are still diffs after resolving any the could have been from unloaded circular dependencies if (BlueprintDiffs.Num() > 0) { AddError(FString::Printf(TEXT("Inconsistencies between subsequent blueprint loads for: '%s' (was a dependency not preloaded?)"), *BlueprintAssetPath)); } else { bDiffsFound = false; } // list all the differences (so as to help identify what dependency was missing) for (auto DiffIt(BlueprintDiffs.CreateIterator()); DiffIt; ++DiffIt) { // will be presented in the context of "what changed between the initial load and the second?" FString DiffDescription = DiffIt->ToolTip; if (DiffDescription != DiffIt->DisplayString) { DiffDescription = FString::Printf(TEXT("%s (%s)"), *DiffDescription, *DiffIt->DisplayString); } const UEdGraphNode* NodeFromPin = DiffIt->Pin1 ? Cast<const UEdGraphNode>(DiffIt->Pin1->GetOuter()) : NULL; const UEdGraphNode* Node = DiffIt->Node1 ? DiffIt->Node1 : NodeFromPin; const UEdGraph* Graph = Node ? Node->GetGraph() : NULL; const FString GraphName = Graph ? Graph->GetName() : FString(TEXT("Unknown Graph")); AddError(FString::Printf(TEXT("%s.%s differs between subsequent loads: %s"), *BlueprintName.ToString(), *GraphName, *DiffDescription)); } } // At the close of this function, the FScopedBlueprintUnloader should prep // for following tests by unloading any blueprint dependencies that were // loaded for this one (should catch InitialBlueprint and ReloadedBlueprint) // // The FScopedBlueprintUnloader should also run garbage-collection after, // in hopes that the imports for this blueprint get destroyed so that they // don't invalidate other tests that share the same dependencies return !bDiffsFound; }