daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Jul 19th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     // Load modules
  2.     FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked<FAssetRegistryModule>("AssetRegistry");
  3.     FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
  4.  
  5.     // Get current sequencer asset
  6.     FAssetData XAssetData = AssetRegistryModule.Get().GetAssetByObjectPath(TEXT("/Game/NewLevelSequence.NewLevelSequence"));
  7.     UObject* LevelSequencerAsset = XAssetData.GetAsset();
  8.    
  9.  
  10.     if (LevelSequencerAsset != nullptr)
  11.     {
  12.         const FString PackagePath = FPackageName::GetLongPackagePath(LevelSequencerAsset->GetOutermost()->GetName());
  13.         if (!PackagePath.IsEmpty())
  14.         {
  15.             // Duplicate current level sequencer
  16.             UObject * ClonedLevelSequencer = AssetToolsModule.Get().DuplicateAsset(
  17.                 FString("StupidClone"),
  18.                 PackagePath,
  19.                 LevelSequencerAsset
  20.             );
  21.  
  22.             if (ClonedLevelSequencer != nullptr)
  23.             {
  24.                 // Update engine registry
  25.                 FAssetRegistryModule::AssetCreated(ClonedLevelSequencer);
  26.                 ClonedLevelSequencer->MarkPackageDirty();
  27.  
  28.                 // Save cloned sequencer
  29.                 FString PackagePath = FString("/Game/StupidClone");
  30.                 UPackage* ClonePackage = CreatePackage(NULL, *PackagePath);
  31.                 if (ClonePackage != nullptr && ClonePackage->IsValidLowLevel())
  32.                 {
  33.                     FString PackageFileName = FPackageName::LongPackageNameToFilename(PackagePath, FPackageName::GetAssetPackageExtension());
  34.  
  35.                     if (UPackage::SavePackage(ClonePackage, ClonedLevelSequencer, RF_Public | RF_Standalone, *PackageFileName, GError, nullptr, false, true, SAVE_NoError))
  36.                     {
  37.                         ClonePackage->PostEditChange();
  38.                         ClonePackage->MarkAsFullyLoaded();
  39.                     }
  40.  
  41.                 }
  42.            
  43.             }
  44.        
  45.         }
  46.  
  47.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top