本文整理汇总了C++中UPackage::SetDirtyFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ UPackage::SetDirtyFlag方法的具体用法?C++ UPackage::SetDirtyFlag怎么用?C++ UPackage::SetDirtyFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPackage
的用法示例。
在下文中一共展示了UPackage::SetDirtyFlag方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
bool FEditTextureLatentCommand::Update()
{
// make a minor edit to the texture in the package we are passed
UPackage* Package = LoadPackage(NULL, *PackageName, LOAD_None);
if(Package != NULL)
{
UTexture2D* Texture = FindObject<UTexture2D>(Package, TEXT("SourceControlTest"));
check(Texture);
Texture->AdjustBrightness = FMath::FRand();
Package->SetDirtyFlag(true);
if(!UPackage::SavePackage(Package, NULL, RF_Standalone, *FPackageName::LongPackageNameToFilename(PackageName, FPackageName::GetAssetPackageExtension())))
{
UE_LOG(LogSourceControl, Error, TEXT("Could not save package: '%s'"), *PackageName);
}
TArray<UPackage*> Packages;
Packages.Add(Package);
PackageTools::UnloadPackages(Packages);
}
else
{
UE_LOG(LogSourceControl, Error, TEXT("Could not find package for edit: '%s'"), *PackageName);
}
return true;
}
示例2: SaveDuplicatedAsset
/**
* Saves the duplicated asset
*/
void SaveDuplicatedAsset()
{
if (DuplicatedPackage && DuplicatedAsset)
{
DuplicatedPackage->SetDirtyFlag(true);
const FString PackagePath = FString::Printf(TEXT("%s/%s_Copy"), *GetGamePath(), *AssetName);
if (UPackage::SavePackage(DuplicatedPackage, NULL, RF_Standalone, *FPackageName::LongPackageNameToFilename(PackagePath, FPackageName::GetAssetPackageExtension()), GError, nullptr, false, true, SAVE_NoError))
{
TestStats->NumDuplicatesSaved++;
UE_LOG(LogEditorAssetAutomationTests, Display, TEXT("Saved asset %s (%s)"), *DuplicatedAsset->GetName(), *Class->GetName());
}
else
{
UE_LOG(LogEditorAssetAutomationTests, Display, TEXT("Unable to save asset %s (%s)"), *DuplicatedAsset->GetName(), *Class->GetName());
}
}
}
示例3: PrivateRemoveLevelFromWorld
/**
* Removes a level from the world. Returns true if the level was removed successfully.
*
* @param Level The level to remove from the world.
* @return true if the level was removed successfully, false otherwise.
*/
bool PrivateRemoveLevelFromWorld(ULevel* Level)
{
if ( !Level || Level->IsPersistentLevel() )
{
return false;
}
if ( FLevelUtils::IsLevelLocked(Level) )
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "Error_OperationDisallowedOnLockedLevelRemoveLevelFromWorld", "RemoveLevelFromWorld: The requested operation could not be completed because the level is locked.") );
return false;
}
int32 StreamingLevelIndex = INDEX_NONE;
for( int32 LevelIndex = 0 ; LevelIndex < Level->OwningWorld->StreamingLevels.Num() ; ++LevelIndex )
{
ULevelStreaming* StreamingLevel = Level->OwningWorld->StreamingLevels[ LevelIndex ];
if( StreamingLevel && StreamingLevel->GetLoadedLevel() == Level )
{
StreamingLevelIndex = LevelIndex;
break;
}
}
if (StreamingLevelIndex != INDEX_NONE)
{
Level->OwningWorld->StreamingLevels[StreamingLevelIndex]->MarkPendingKill();
Level->OwningWorld->StreamingLevels.RemoveAt( StreamingLevelIndex );
Level->OwningWorld->RefreshStreamingLevels();
}
else if (Level->bIsVisible)
{
Level->OwningWorld->RemoveFromWorld(Level);
check(Level->bIsVisible == false);
}
const bool bSuccess = EditorDestroyLevel(Level);
// Since we just removed all the actors from this package, we do not want it to be saved out now
// and the user was warned they would lose any changes from before removing, so we're good to clear
// the dirty flag
UPackage* LevelPackage = Level->GetOutermost();
LevelPackage->SetDirtyFlag(false);
return bSuccess;
}
示例4: MarkPackageDirty
/**
* Finds the outermost package and marks it dirty
*/
bool UObjectBaseUtility::MarkPackageDirty() const
{
// since transient objects will never be saved into a package, there is no need to mark a package dirty
// if we're transient
if ( !HasAnyFlags(RF_Transient) )
{
UPackage* Package = GetOutermost();
if( Package != NULL )
{
// It is against policy to dirty a map or package during load in the Editor, to enforce this policy
// we explicitly disable the ability to dirty a package or map during load. Commandlets can still
// set the dirty state on load.
if( IsRunningCommandlet() ||
(GIsEditor && !GIsEditorLoadingPackage && !GIsPlayInEditorWorld && !IsInAsyncLoadingThread()
#if WITH_HOT_RELOAD
&& !GIsHotReload
#endif // WITH_HOT_RELOAD
#if WITH_EDITORONLY_DATA
&& !Package->bIsCookedForEditor // Cooked packages can't be modified nor marked as dirty
#endif
))
{
const bool bIsDirty = Package->IsDirty();
// We prevent needless re-dirtying as this can be an expensive operation.
if( !bIsDirty )
{
Package->SetDirtyFlag(true);
}
// Always call PackageMarkedDirtyEvent, even when the package is already dirty
Package->PackageMarkedDirtyEvent.Broadcast(Package, bIsDirty);
return true;
}
else
{
// notify the caller that the request to mark the package as dirty was suppressed
return false;
}
}
}
return true;
}
示例5: DeleteAsset
/**
* Deletes the asset
*/
void DeleteAsset()
{
if (CreatedAsset)
{
bool bSuccessful = false;
bSuccessful = ObjectTools::DeleteSingleObject(CreatedAsset, false);
//If we failed to delete this object manually clear any references and try again
if (!bSuccessful)
{
//Clear references to the object so we can delete it
AutomationEditorCommonUtils::NullReferencesToObject(CreatedAsset);
bSuccessful = ObjectTools::DeleteSingleObject(CreatedAsset, false);
}
//Delete the package
if (bSuccessful)
{
FString PackageFilename;
if (FPackageName::DoesPackageExist(AssetPackage->GetName(), NULL, &PackageFilename))
{
TArray<UPackage*> PackagesToDelete;
PackagesToDelete.Add(AssetPackage);
// Let the package auto-saver know that it needs to ignore the deleted packages
GUnrealEd->GetPackageAutoSaver().OnPackagesDeleted(PackagesToDelete);
AssetPackage->SetDirtyFlag(false);
// Unload the packages and collect garbage.
PackageTools::UnloadPackages(PackagesToDelete);
IFileManager::Get().Delete(*PackageFilename);
TestStats->NumDeleted++;
UE_LOG(LogEditorAssetAutomationTests, Display, TEXT("Deleted asset %s (%s)"), *AssetName, *Class->GetName());
}
}
else
{
UE_LOG(LogEditorAssetAutomationTests, Error, TEXT("Unable to delete asset: %s (%s)"), *AssetName, *Class->GetName());
}
}
}
示例6: RebuildGraph
void USoundClassGraph::RebuildGraph()
{
check(RootSoundClass);
// Don't allow initial graph rebuild to affect package dirty state; remember current state...
UPackage* Package = GetOutermost();
const bool bIsDirty = Package->IsDirty();
Modify();
RemoveAllNodes();
ConstructNodes(RootSoundClass, 0, 0);
NotifyGraphChanged();
// ...and restore it
Package->SetDirtyFlag(bIsDirty);
}
示例7: MarkPackageDirty
/**
* Finds the outermost package and marks it dirty
*/
void UObjectBaseUtility::MarkPackageDirty() const
{
// since transient objects will never be saved into a package, there is no need to mark a package dirty
// if we're transient
if ( !HasAnyFlags(RF_Transient) )
{
UPackage* Package = GetOutermost();
if( Package != NULL )
{
// It is against policy to dirty a map or package during load in the Editor, to enforce this policy
// we explicitly disable the ability to dirty a package or map during load. Commandlets can still
// set the dirty state on load.
// We also prevent needless re-dirtying as this can be an expensive operation.
if( !Package->IsDirty() &&
(!GIsEditor || IsRunningCommandlet() ||
(GIsEditor && !GIsEditorLoadingPackage)))
{
Package->SetDirtyFlag(true);
}
}
}
}
示例8: TEXT
UTexture* UnFbx::FFbxImporter::ImportTexture( FbxFileTexture* FbxTexture, bool bSetupAsNormalMap )
{
// create an unreal texture asset
UTexture* UnrealTexture = NULL;
FString Filename1 = ANSI_TO_TCHAR(FbxTexture->GetFileName());
FString Extension = FPaths::GetExtension(Filename1).ToLower();
// name the texture with file name
FString TextureName = FPaths::GetBaseFilename(Filename1);
TextureName = ObjectTools::SanitizeObjectName(TextureName);
// set where to place the textures
FString NewPackageName = FPackageName::GetLongPackagePath(Parent->GetOutermost()->GetName()) + TEXT("/") + TextureName;
NewPackageName = PackageTools::SanitizePackageName(NewPackageName);
UPackage* Package = CreatePackage(NULL, *NewPackageName);
bool AlreadyExistTexture = (FindObject<UTexture>(Package,*TextureName/*textureName.GetName()*/) != NULL);
// try opening from absolute path
FString Filename = Filename1;
TArray<uint8> DataBinary;
if ( ! FFileHelper::LoadFileToArray( DataBinary, *Filename ))
{
// try fbx file base path + relative path
FString Filename2 = FileBasePath / ANSI_TO_TCHAR(FbxTexture->GetRelativeFileName());
Filename = Filename2;
if ( ! FFileHelper::LoadFileToArray( DataBinary, *Filename ))
{
// try fbx file base path + texture file name (no path)
FString Filename3 = ANSI_TO_TCHAR(FbxTexture->GetRelativeFileName());
FString FileOnly = FPaths::GetCleanFilename(Filename3);
Filename3 = FileBasePath / FileOnly;
Filename = Filename3;
if ( ! FFileHelper::LoadFileToArray( DataBinary, *Filename ))
{
UE_LOG(LogFbxMaterialImport, Warning,TEXT("Unable to find TEXTure file %s. Tried:\n - %s\n - %s\n - %s"),*FileOnly,*Filename1,*Filename2,*Filename3);
}
}
}
if (DataBinary.Num()>0)
{
UE_LOG(LogFbxMaterialImport, Warning, TEXT("Loading texture file %s"),*Filename);
const uint8* PtrTexture = DataBinary.GetTypedData();
UTextureFactory* TextureFact = new UTextureFactory(FPostConstructInitializeProperties());
// save texture settings if texture exist
TextureFact->SuppressImportOverwriteDialog();
const TCHAR* TextureType = *Extension;
// Unless the normal map setting is used during import,
// the user has to manually hit "reimport" then "recompress now" button
if ( bSetupAsNormalMap )
{
if (!AlreadyExistTexture)
{
TextureFact->LODGroup = TEXTUREGROUP_WorldNormalMap;
TextureFact->CompressionSettings = TC_Normalmap;
}
else
{
UE_LOG(LogFbxMaterialImport, Warning, TEXT("Manual texture reimport and recompression may be needed for %s"), *TextureName);
}
}
UnrealTexture = (UTexture*)TextureFact->FactoryCreateBinary(
UTexture2D::StaticClass(), Package, *TextureName,
RF_Standalone|RF_Public, NULL, TextureType,
PtrTexture, PtrTexture+DataBinary.Num(), GWarn );
if ( UnrealTexture != NULL )
{
// Notify the asset registry
FAssetRegistryModule::AssetCreated(UnrealTexture);
// Set the dirty flag so this package will get saved later
Package->SetDirtyFlag(true);
}
}
return UnrealTexture;
}
示例9: RunTest
//.........这里部分代码省略.........
// 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;
}
示例10: FactoryCreateBinary
//.........这里部分代码省略.........
}
else
{
FString TexturePackageName;
FString BasePackageName = FPackageName::GetLongPackagePath(InParent->GetOutermost()->GetName()) / TextureName;
AssetToolsModule.Get().CreateUniqueAssetName(BasePackageName, TEXT(""), TexturePackageName, TextureName);
TexturePackage = CreatePackage(NULL, *TexturePackageName);
}
const uint8* BufferBegin = Data.GetData();
const uint8* BufferEnd = BufferBegin + Data.Num();
UTexture2D* NewTexture = (UTexture2D*)TextureFact->FactoryCreateBinary(
UTexture2D::StaticClass(),
TexturePackage,
FName(*TextureName),
Flags,
NULL,
*FPaths::GetExtension(ImagePaths[i]),
BufferBegin, BufferEnd,
Warn
);
if(NewTexture)
{
if(ImportSettings->bOverwriteMipGenSettings)
{
NewTexture->MipGenSettings = TMGS_NoMipmaps;
}
if(ImportSettings->bOverwriteTextureGroup)
{
NewTexture->LODGroup = ImportSettings->TextureGroup;
}
if(ImportSettings->bOverwriteCompressionSettings)
{
NewTexture->CompressionSettings = TextureCompressionSettings::TC_EditorIcon;
}
if(ImportSettings->bOverwriteTilingMethodFromSspj)
{
switch(ImageWrapModes[i])
{
case SsTexWrapMode::Clamp:
{
NewTexture->AddressX = NewTexture->AddressY = TA_Clamp;
} break;
case SsTexWrapMode::Repeat:
{
NewTexture->AddressX = NewTexture->AddressY = TA_Wrap;
} break;
case SsTexWrapMode::Mirror:
{
NewTexture->AddressX = NewTexture->AddressY = TA_Mirror;
} break;
}
}
if(ImportSettings->bOverwriteNeverStream)
{
NewTexture->NeverStream = true;
}
if(ImportSettings->bOverwriteFilterFromSspj)
{
switch(ImageFilterModes[i])
{
case SsTexFilterMode::Nearest:
{
NewTexture->Filter = TF_Nearest;
} break;
case SsTexFilterMode::Linear:
{
NewTexture->Filter = TF_Bilinear;
} break;
}
}
NewTexture->UpdateResource();
FAssetRegistryModule::AssetCreated(NewTexture);
TexturePackage->SetDirtyFlag(true);
TextureFact->RemoveFromRoot();
ImportedTexture = NewTexture;
}
}
if(ImportedTexture)
{
for(int ii = 0; ii < NewProject->CellmapList.Num(); ++ii)
{
if(NewProject->CellmapList[ii].ImagePath == ImagePaths[i])
{
NewProject->CellmapList[ii].Texture = ImportedTexture;
}
}
}
}
}
// インポート終了
FEditorDelegates::OnAssetPostImport.Broadcast(this, NewProject);
return NewProject;
}