UActorFactory* FPlacementMode::FindLastUsedFactoryForAssetType( UObject* Asset ) const { if ( Asset == NULL ) { return NULL; } UActorFactory* LastUsedFactory = NULL; UClass* CurrentClass = Cast<UClass>( Asset ); if ( CurrentClass == NULL ) { CurrentClass = Asset->GetClass(); } while ( LastUsedFactory == NULL && CurrentClass != NULL && CurrentClass != UClass::StaticClass() ) { const TWeakObjectPtr< UActorFactory >* FoundFactory = AssetTypeToFactory.Find( *CurrentClass->GetPathName() ); if ( FoundFactory != NULL && FoundFactory->IsValid() ) { LastUsedFactory = FoundFactory->Get(); } else { CurrentClass = CurrentClass->GetSuperClass(); } } return LastUsedFactory; }
void FBlueprintNativeCodeGenModule::GenerateSingleStub(UBlueprint* BP, const TCHAR* PlatformName) { if (!ensure(BP)) { return; } UClass* Class = BP->GeneratedClass; if (!ensure(Class)) { return; } // no PCHFilename should be necessary const IAssetRegistry& Registry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry").Get(); FAssetData AssetInfo = Registry.GetAssetByObjectPath(*Class->GetPathName()); FString FileContents; TUniquePtr<IBlueprintCompilerCppBackend> Backend_CPP(IBlueprintCompilerCppBackendModuleInterface::Get().Create()); // Apparently we can only generate wrappers for classes, so any logic that results in non classes requesting // wrappers will fail here: FileContents = Backend_CPP->GenerateWrapperForClass(Class); if (!FileContents.IsEmpty()) { FFileHelper::SaveStringToFile(FileContents , *(GetManifest(PlatformName).CreateUnconvertedDependencyRecord(AssetInfo.PackageName, AssetInfo).GeneratedWrapperPath) , ForcedEncoding()); } // The stub we generate still may have dependencies on other modules, so make sure the module dependencies are // still recorded so that the .build.cs is generated correctly. Without this you'll get include related errors // (or possibly linker errors) in stub headers: GetManifest(PlatformName).GatherModuleDependencies(BP->GetOutermost()); }
virtual bool FixupObject(const FName& InObjectPath, FName& OutNewObjectPath) override { OutNewObjectPath = NAME_None; if (InObjectPath.ToString().StartsWith(TEXT("/Script/"))) { // We can't use FindObject while we're saving if (!GIsSavingPackage) { const FString ClassPathStr = InObjectPath.ToString(); UClass* FoundClass = FindObject<UClass>(ANY_PACKAGE, *ClassPathStr); if (!FoundClass) { // Use the linker to search for class name redirects (from the loaded ActiveClassRedirects) const FString ClassName = FPackageName::ObjectPathToObjectName(ClassPathStr); const FName NewClassName = FLinkerLoad::FindNewNameForClass(*ClassName, false); if (!NewClassName.IsNone()) { // Our new class name might be lacking the path, so try and find it so we can use the full path in the collection FoundClass = FindObject<UClass>(ANY_PACKAGE, *NewClassName.ToString()); if (FoundClass) { OutNewObjectPath = *FoundClass->GetPathName(); } } } } } else { // Keep track of visted redirectors in case we loop. TSet<FName> VisitedRedirectors; // Use the asset registry to avoid loading the object FAssetData ObjectAssetData = AssetRegistryModule.Get().GetAssetByObjectPath(InObjectPath); while (ObjectAssetData.IsValid() && ObjectAssetData.IsRedirector()) { // Check to see if we've already seen this path before, it's possible we might have found a redirector loop. if ( VisitedRedirectors.Contains(ObjectAssetData.ObjectPath) ) { UE_LOG(LogContentBrowser, Error, TEXT("Redirector Loop Found!")); for ( FName Redirector : VisitedRedirectors ) { UE_LOG(LogContentBrowser, Error, TEXT("Redirector: %s"), *Redirector.ToString()); } ObjectAssetData = FAssetData(); break; } VisitedRedirectors.Add(ObjectAssetData.ObjectPath); // Get the destination object from the meta-data rather than load the redirector object, as // loading a redirector will also load the object it points to, which could cause a large hitch FString DestinationObjectPath; if (ObjectAssetData.GetTagValue("DestinationObject", DestinationObjectPath)) { ConstructorHelpers::StripObjectClass(DestinationObjectPath); ObjectAssetData = AssetRegistryModule.Get().GetAssetByObjectPath(*DestinationObjectPath); } else { ObjectAssetData = FAssetData(); } } OutNewObjectPath = ObjectAssetData.ObjectPath; } return OutNewObjectPath != NAME_None && InObjectPath != OutNewObjectPath; }