You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #lockdown Nick.Penwarden ============================ MAJOR FEATURES & CHANGES ============================ Change 4073383 by Patrick.Boutot [AJA] Set base timecode for AJA TimecodeProvider Change 4075631 by Patrick.Boutot Change icon for TimecodeSynchronizer. Update TimecodeSynchronizer with the new AJA delayed open sources. Add TimecodeProvider to TimecodeSynchronizer. Can now sync with TimecodeProvider or a master. Make sure the source are ready before viewing them. Remove PreRoll command. Change 4077328 by JeanMichel.Dignard Fixed SoftObjectPtr/Paths becoming invalid when saving a new world since it's being moved from /Temp/Untitled to its own package. #jira UEENT-1423 Change 4077338 by Rex.Hill USD plugin updated to v8.4 with python support Change 4079063 by Rex.Hill USD sdk recompiled as vs2015 targeting older version of CRT, also dependency added for PythonScriptPlugin Change 4079911 by Rex.Hill USD pyd files recompiled Change 4080058 by Rex.Hill Fix usd plugin loading, added missing libtrace.dll Change 4080376 by Matt.Hoffman Improvements to Sequence Recorder's public API to expose more functionality for third parties. Change 4084984 by Matt.Hoffman Sequence Recorder can now set a global time dilation when recording starts, optionally ignoring the dilation when recording keys. This is useful for recording objects in your scene that move too fast to track with a camera but still ending up with the same length recording in the end. #jira UESP-670 Change 4086688 by Matt.Hoffman Exposes getting and setting keys from sequencer sections via the scripting layer. Examples for how to work with Python and key data can be found in /Plugins/MovieScene/SequencerScripting/Content/Python in the form of "sequencer_examples.py" and "sequencer_key_examples.py". Documentation on how to use these examples is included in the python file. #jira UESP-547 Change 4088904 by Max.Chen Sequence Recorder: Set actor tags as unique Change 4089176 by Max.Chen Sequence Recorder: Add option to record to the target level sequence playback range length. Change 4089180 by Max.Chen Sequence Recorder: Add protection agains null movie scene sections Change 4089205 by Max.Chen Sequence Recorder: Save recorded audio files if auto save is on. #jira UESP-660 Change 4089206 by Max.Chen Sequencer: When importing fbx, if a camera is created, force mapping to be by name matching only so that other nodes in the fbx file do not get mapped onto the newly created camera. #jira UE-59347 Change 4089214 by Max.Chen Sequence Recorder: Add support for looping/rolling takes #jira UESP-658 Change 4089280 by Max.Chen Sequence Recorder: Added support to specify properties from actor classes (camera rig rail - current position on rail) Change 4093824 by Andrew.Rodham Editor: Added option to class pickers to force use of class Display Names Change 4093826 by Andrew.Rodham Removed implicit gamma to linear conversion from EXR writer - This was only implemented for exr data that was supplied as 8 bits per channel (ie. uint8), but there is no way of communicating with the Image Writer API to tell it whether you want it to do that conversion. This code is too low level to be making assumptions about what color-space the data is in. - This ensures that R8G8B8A8 render targets exported as EXR are exported as-is without any modification #jira UESP-545 Change 4093830 by Andrew.Rodham Fixed shutdown crash when destroying a media player that was still playing Change 4093831 by Andrew.Rodham Fixed exception handling in png image wrapper Change 4093833 by Andrew.Rodham Slate: Fixed not being able to set a hyperlink on notifications with unbound attributes that had explicit values set Change 4093841 by Andrew.Rodham Added a utility struct for dealing with editor actor layers from within Blueprints Change 4093867 by Andrew.Rodham Sequencer: Added the ability to implement custom capture protocols for movie scene captures - Converted capture protocol settings and instances to be single UObjects. This unifies the two concepts, and allows for Blueprint implementations. - Removed capture protocol registry since it is no longer required. - Removed FCaptureProtocolID in favor of class discovery at runtime. - Added new module "ImageWriteQueue", responsible for asynchronously managing a queue of image file write operations. - Added new capture protocol for capturing final pixels to EXR (including burn-ins) - Added a new BP function, ExportToDisk, accessible on all UTexture properties for writing texture and render target data to image files - New global BP nodes for querying movie capture status: IsCaptureInProgress, FindCaptureProtocol - Removed Flush On Draw functionality from viewports and frame grabber since it is unnecessary. #jira UESP-545 Change 4094239 by Rex.Hill Export sequence to usd #jira UESP-563 Change 4094393 by Andrew.Rodham Renamed references of 'BufferName' to 'StreamName' for user defined capture protocols Change 4094622 by Patrick.Boutot Add MediaFrameworkUtilitites plugin. Add MediaBundle. An asset that create a MediaPlayer, MediaSource, MediaTexture and MaterialInstance. Add MediaBundleActor. Can auto play a MediaBundle when click & drag in the viewport. Add the Media category in placement mode. Add flag on the MediaPlayer that prevent it from closing when PIE is started or closed. Change 4094673 by Anousack.Kitisa Created widget to display metadata as list view of tags/values. #jira UEENT-1296 Change 4094795 by Simon.Therriault MediaFrameworkUtilities - Adding default media texture for default media bundle material - Changed default material to unlit Change 4094867 by Rex.Hill Usd sequence exporter camera rotation corrected Change 4096426 by JeanLuc.Corenthin - Fixed logic of FLayoutUV::FindCharts to properly extract the list of triangles based on a mesh description. - Fixed logic in FMeshDescriptionOperations::ConverToRawMesh & FMeshDescriptionOperations::ConvertHardEdgesToSmoothGroup to take in account the fact that the arrays are sparse arrays - Fixed logic in FQuadricSimplifierMeshReduction::ReduceMeshDescription which wrongly assumed that number of vertex instances equals three times the number of triangles. - Added early-out in UMeshDescription::ComputePolygonTriangulation when perimeter has 3 vertex indices - Changed version of static mesh and mesh description - Fixed issue with mismatching attribute set when generating LOD meshes #jira UEENT-887, UE-59474, UE-59471 Change 4097101 by Patrick.Boutot Remove warning in PropertyEditorClass when trying to load the "None" class. Change 4097443 by Rex.Hill USD export bake keys Change 4097468 by Patrick.Boutot Edit and initialize the timecode provider of the editor. Change 4097479 by Anousack.Kitisa Added support for commandlet and unattended script modes to Plugin Warden. #jira UE-57333 Change 4097578 by Rex.Hill USD export tweaks Change 4098257 by Simon.Therriault GarbageMatteCaptureComponent - Adding spawned actor tracking to be able to use GarbageMatteActor spawned in editor. Change 4100072 by Jamie.Dale Updated wrapped enums to be more consistent with native Python enums - Wrapped enums now generate values that are instances of the enum type itself, containing a name and value field (like native Python enums). - Wrapped enums are now strongly typed and do not allow implicit conversion from numbers (explicit casting is available, but throws if the value is unknown). - Wrapped enum entries may be compared against numbers (even numbers that don't have valid values) via the == and != operators (like IntEnum in Python). - Wrapped enums may now be iterated (like native Python enums). - Wrapped enums now return a length based on their number of entries (like native Python enums). - ScriptName meta-data can now be used with enum entries. Change 4100255 by Patrick.Boutot [MediaBundle] Modify the base shader to support "failed texture" Change 4103838 by Simon.Therriault MR Garbage Matte Component - Adding FocalDriver interface to be able to poll focal information from outside (cinecamera). Could be updated to be event driven. Change 4115616 by Rex.Hill USD Exporter now exposed to UI Change 4116333 by Simon.Therriault MediaBundle - Updated default media bundle to include lens distortion and chromakeying - Added possibility to spawn material editor for MediaBundle inner material - Fix for inner objects flags preventing asset deletion - Fix for CloseMedia not being called when changing map Lens Distortion - Fix for not being able to generate a Identity lens displacement map Change 4117952 by Rex.Hill Expose OpenEditorForAssets to python Change 4118498 by Rex.Hill Sequencer USD export can now export properties of actors in levels Change 4118515 by Rex.Hill Update sequencer export task comment Change 4118706 by Rex.Hill Sequencer USD updates Change 4118968 by Rex.Hill Sequencer USD export now supports visibility Change 4119702 by Simon.Therriault MediaBundle - Fix crash when changing MediaBundle on Actor multiple times. - Fix crash when Undoing after placing a MediaBundle and pressing Stop then Undo. - Fixed bad reference count in MediaBundle when undo/redo of MediaBundle setting changed on MediaBundleActor - Added PostEditChange after setting MaterialProperty to fix potential propagation. Change 4120060 by Patrick.Boutot Fix typo for TimecodeProviderClassName. Add "Config required restart" Add a button to reapply the CustomTimeStep or TimecodeProvider Change 4122062 by Krzysztof.Narkowicz Fixed movie burnout fixed timestep. Engine didn't use a fixed time step due to a following bug: 1. UAutomatedLevelSequenceCapture::Initialize calls UMovieSceneCapture::Initialize. 2. UMovieSceneCapture::Initialize creates FRealTimeCaptureStrategy and calls CaptureStrategy->OnInitialize(). 3. UAutomatedLevelSequenceCapture::Initialize changes CaptureStrategy to FFixedTimeStepCaptureStrategy, but no one calls CaptureStrategy->OnInitialize(); after that and this function is required to set the fixed time step. 4. Result: movies are burned out with variable time step, causing different inconsistencies between frames, settings and HW configurations. #jira none Change 4122236 by Anousack.Kitisa Made the "Import Into Level..." File menu action follow the EditorImport flag of a SceneImportFactory. #jira UE-57612 #jira UEENT-762 Change 4122588 by Rex.Hill Sequencer Export USD lights now supported Change 4122822 by JeanMichel.Dignard Fix for UV packing FlipX. Don't flip the empty columns at the end since they are always expected to be on the right side. The same was already done for FlipY. #jira UE-56664 Change 4123009 by JeanMichel.Dignard Copied fixes from MeshUtilities LayoutUV to MeshDescription LayoutUV Change 4123517 by JeanLuc.Corenthin Fixed crash when running cooked game crash with asset imported from datasmith #jira UE-60173 Change 4124569 by Patrick.Boutot [AJA] When the CustomTimeStep & TimecodeProvider signal is lost in the editor (not in PIE), try to re-synchronize every second. Change 4126421 by Max.Chen Sequencer: Add the ability to switch the takes of all the selected shots/subsections. #jira UESP-761 Change 4133010 by Simon.Therriault MediaBundle - Made assets in the bundle visible in the content browser (different package per asset) and updated to support duplication correctly - Quick fix for MaterialDynamicInstance garbage matte parameter not going back to default value when cleared. - Added looping option on the bundle Keyer and lens materials - Renamed some parameter groups to Keyer_XX Change 4135728 by Rex.Hill MovieSceneCapture crash fix when iteration on classes defined in python Change 4135732 by Rex.Hill Sequencer scripting: expose get playback range, sub sequence get sequence Change 4135734 by Rex.Hill USD python code refactored Change 4136017 by Matt.Hoffman Fixes FrameNumber nodes tripping an ensure when using them via Blueprints and fixes FrameNumbers & friends not being properly breakable in BP. #jira UE-60188 Change 4147959 by Patrick.Boutot Media Output Architecture. Support 8bits & 10bits color. Capture the buffer as is with the correct pixel format and the corredt target size. Change 4147962 by Patrick.Boutot Remove AjaMediaViewportOutput && AjaMediaViewportOutputImpl. Refactor AjaMediaOutput to extend MediaOutput. Refactor AjaMediaGrameGrabberProtocol to use AjaMediaCapture. Create AjaMediaCapture. Change 4148395 by Rex.Hill USD python code cleanup Change 4152901 by Rex.Hill Fix crash when recompiling blueprint or script class that serializes an object reference manually Change 4152906 by Rex.Hill USD level import/export exposed to UI Change 4152956 by Rex.Hill Rename unreal_usd to usd_unreal to avoid future module name conflicts Change 4153331 by Rex.Hill Simplify USD attribute definitions Change 4155472 by Rex.Hill USD level import now handles cameras and lights Change 4155832 by Patrick.Boutot Fix Packaging for MediaFrameworkUtilities Fix MediaPlayer that crash on close when the engine is closing. Change 4156020 by Mike.Zyracki LIVE LINK Sequencer Recording and Playback #jira UESP-714 #jira UESP-715 Support for Live Link Recording/Playback with Sequencer. Basically if we see a MotionController controlled by a LiveLink Subject or a LiveLink Component on a Actor we create a LiveLinkTrack for it that will record raw sequencer data into. We currently do that at the end of recording but will investigate saving it as we record. For Playback we create a Live Link Subject per recorded track and push up interpolated data per Engine Tick on Evaluate. We need to see if we need to send out raw data but that's complicated due to the fact that sequencer time may not be sequential but random, Moved FLiveLinkTimeFrame to LiveLinkTypes so we can grab raw data. Added functions to LiveLinkClient/Subject to get raw data so we dont' need to do expensive searches. Also changed that code so that we can only save the LiveLinkData when specified. We decided to have the sequencer own saving of the live link data so we explicilty turn on saving when we start to record and then turn if off at the end. Without this it's possible to easily run out of memory while LiveLink records. In order to record LiveLinkComponents under Actors we had to change ActorRecording to record ActorComponents and not jus SceneComponents. Not sure of any drawbacks with this but it seems to work well. Had to make sure we stll keeped attach/parent/child logic when recording. Change 4158488 by Rex.Hill USD scene import/export now uses UsdLux lights Change 4158742 by Rex.Hill USD: Add test for level export and import Change 4161645 by Patrick.Boutot Update MediaRecorder to use the ImageWriteQueue. Add flag in IImageWriteQueue.Enqueue to prevent block if the queue is full. Change 4161651 by Patrick.Boutot Modify MediaCompositing to use an existing MediaPlayer Change 4161657 by Patrick.Boutot Extend the SequenceRecorder to support additional object to record from other plugins. Add SequenceRecorder for MediaPlayer. Will record every frame to disk that the MediaPlayer produce. Change 4162699 by Rex.Hill USD export sequence updates Change 4163138 by Rex.Hill USD sequence export test added Change 4163426 by Mike.Zyracki Fix for Curve Names being kept and AutoSetting Tangents on Live Link Recording Change 4165714 by Patrick.Boutot [MediaCapture] Remove color box that tell the status of the MediaCapture. Add MediaCapture's name and use an image to represent the status. Use a ScrollBox around the "preview" output. Can select any actors. Only show the selectable camera grid when there is more than one camera. Change 4166652 by Rex.Hill Expose SetMobility to scripting Change 4167292 by Mike.Zyracki Make sure we call Finalize Evaluation when closing or deleting the Sequencer. This will make sure TearDown is called on sections which fixes issues with LiveLink Sources not getting deleted and probably also issues with MovieScenePlayers not getting released correctly. Also includes addition to show the SubjectName next to the Sequencer Source in the LiveLinkClient UI. Change 4170578 by Rex.Hill PackageTools exposed to scripting Change 4170619 by Rex.Hill Fix ReversePolygonFacing crash Change 4170621 by Rex.Hill USD mesh import can now be given list of individual meshes Change 4172495 by Matt.Hoffman Fixes some flipped logic in Sequencer Media Track that was preventing it from working as expected. Slightly simplifies the logic on setting up movie data, and ensures that the external movie player has a callback registered so that SeekTo calls will work. Makes it so that you can specify your own sound component with an external media player as a media player can have multiple sound components listening to it. Adds support for flagging the media player to loop to help cue some media sources like EXR to handle loop points better. #jira None Change 4173387 by Jon.Nabozny Bookmark usability and extensibility improvements Change 4173755 by Rex.Hill PackageTools namespace deprecation Change 4181799 by Patrick.Boutot Fix precesion error when importing a camera switcher in sequencer #jira UE-61212 Change 4184435 by Patrick.Boutot Only show the MediaCapture tab spawner in the level editor. Make sure the Material used to draw the render target is GCed. Change 4195803 by Patrick.Boutot Warn user if the AJA CustomTimeStep is used with VSync enabled. Change 4195866 by Patrick.Boutot Remove mention of CharBGR10A2 in AJA. The feature is not yet ready. Change 4196059 by Rex.Hill Fix linux compile due to a .cpp including BookMarkBase.h instead of BookmarkBase.h Change 4196380 by Patrick.Boutot MediaCapture capture the backbuffer when the Viewport don't use an internal texture. #jira UE-61601 Change 4199378 by Patrick.Boutot For MediaFramework, add support for 10bits RGB texture Change 4199380 by Patrick.Boutot [AJA] Add support for 10bits RGB texture in input Fix interlaced format that wasn't using the proper Stride value. Change 4200359 by Jamie.Dale Renamed some "K2_" prefixed functions for Python Change 4203016 by Max.Chen Sequencer: Add movie scene locking/read only. Fixed a few bugs with locked sections - shouldn't be able to create or move keys on locked sections #jira UESP-867 Change 4203018 by Max.Chen Sequencer: Test for movie scene read only before calling modify/transactions. #jira UESP-867 Change4203622by Simon.Therriault Bringing Aja MediaOutput MediaMode fix from Release 4.20 Change 4204895 by Rex.Hill Expose several file path functions to scripting Change 4206747 by Rex.Hill USD level import and export updates Change 4206783 by Rex.Hill USD updates Change 4207021 by Rex.Hill USD, fix rotation on level import when there is non-uniform scale Change 4207414 by Rex.Hill USD import static mesh material improvements Change 4209733 by Patrick.Boutot Change the log time to use the current frame Timecode #jira UEENT-1107 Change 4209738 by Patrick.Boutot Option to automatically try to reopen the MediaSource again if an error is detected Change 4210385 by Max.Chen Sequencer: Fix CurrentShot LocalTime computation by using sequence time in playback resolution to compute the local shot time. Also, fixed the burnin asset so that CurrentShotLocalTime is hooked up to ShotFrame instead of MasterTime. This fixes a bug where the burnin's {ShotFrame} is not reporting the local shot frame number. #jira UE-61728 Change 4219824 by Patrick.Boutot Use the correct EditorCondition for property MaxNumAncillaryFrameBuffe Change 4220706 by Louise.Rasmussen Sequencer: Syncronizes Sections using Source Timecode Relative to the first Selected Section #JIRA UESP-826 Change 4220708 by Louise.Rasmussen Sequencer: Adds SourceTimecode option to the Render Movie Settings Burn In #JIRA UESP-826 Change 4226970 by Patrick.Boutot Add a Timecode widget, TimecodeProvider widget and a TimecodeProvider Tab Change 4227333 by Rex.Hill USD Sequencer export now supports deltas Change 4227455 by Matt.Hoffman Adds support to the Audio Mixer Submix to pause and resume a recording. #jira UESEQ-77 Change 4230963 by Patrick.Boutot Make the namespace an import option Change 4234208 by Jon.Nabozny Fixed crash when 5 or more LiveLink sources were connected at the same time Change 4234273 by Jon.Nabozny Add methods in FApp to get the current Timecode FrameRate. Change 4237170 by Simon.Therriault MediaCapture Fix for MediaCapture panel not working in PIE Change 4243758 by Andrew.Rodham It's now possible to resolve pixel data from a render target whose texture resource is still pending creation Change 4244790 by Matt.Hoffman This adds experimental support to Sequencer's Render to Movie for exporting audio via rendering a second pass. This requires the new audio mixer (launch editor with "-audiomixer") and currently supports exporting to .wav. The second pass disables rendering in the Viewport and disables capturing frames during this pass which removes the overhead caused by rendering the scene. Complex scenes still evaluate the sequence which may impact performance in complex situations (such as the Fortnite Launch Trailer). Current Limitations: Requires the new audio mixer ("-audiomixer") The second pass must acheive real time framerates. The audio engine is only built to handle real time situations (due to the high precision needed, gotten via the platform clock) so any drops in engine framerate during the second pass will cause a desync of the audio (as there will be more samples captured than frames of video). The editor has significant overhead which often prevents achieving consistent real-time rates. Using "Capture in New Process" alleviates this issue, even without closing the Editor. Audio has been enabled for both image capture and audio capture passes, which means stuttery audio now plays back during image capture. Attempts to alleviate this issue ended up conflicting with some editor code that forces the audio multiplier to 1.0 each Tick(), so audio has to play on both image and audio passes. Forces background audio (otherwise your output audio wav will be blank!) when app is not in focus, though users should leave the app in focus for best performance. #jira UESEQ-77, UESP-669 Change 4246443 by Simon.Tourangeau Remove Beta flag from nDisplay plugin #jira UEENT-1716 Change 4246480 by Simon.Tourangeau Fix nDisplay plugin icon #jira UEENT-1715 Change 4246571 by Simon.Tourangeau Merging Lauren's VR Editor fixes 4085915 Gamma correction fixes for VR Mode Content Browser icons and camera previews 4087955 Adding a third looping option to the Sequencer Radial Menu. Selecting the Looping option now cycles through No Looping > Loop All > Loop Range 4089914 Adding set start/end range buttons to radial menu 4090502 Fixing sequencer looping not being set correctly 4092824 Cameras are now visible in VR Mode - interim implementation until Game Mode works entirely 4095161 Fix for opening a sequence blocking level editor tab drag and drop 4096999 Making a VR Edit show flags mode that is similar to Game Mode but without the Game flag set to true, does hide billboards. Camera hide/show behavior is now correct. 4097286 Placing cameras now only summons the preview panel once you release 4100941 New spawn location for camera preview window (in front and to the side, on whichever side matches your UI hand) 4102732 Hiding VR editor elements from camera preview 4103378 Added camera burnin text on preview windows as well. 4103466 Fixes for camera text 4103779 Fix for the actor previews not unpinning when entering VR mode. 4105722 Adding support for multiple viewport previews in VR mode, and not creating a new viewport interaction if one already exists when getting it. 4106982 Any dockable window can now be placed in the world. 4107298 Fix for crash when closing multiple camera previews 4107426 Fix for crash when connecting node with no texture set 4136343 UI windows docked "to the world" no longer scale with you and stay the size they are docked at. 4136345 Settings for tweaking VR mode movement 4147473 Fix for controllers not showing up 4147734 Sequencer scrubbing will now pause when removing your thumb from a Vive touchpad4171489Added external UI panel support to VREditor module. Created an example camera-adjusting UI 4186392 Second fix for sequencer scrubbing on the radial menu Change 4247984 by Jamie.Dale Fixed potential memory corruption caused by Python glue code generation #jira UE-62397 Change 4255471 by Anousack.Kitisa Added functionalities to add/insert/remove UV channel from a StaticMesh accessible through the StaticMeshEditor and scripting. #jira UEENT-1592 #jira UEENT-1597 #jira UEENT-1660 Change 4256323 by Anousack.Kitisa Added Polygon Selection Mode by smoothing group in the MeshEditor. #jira UEENT-1594 Change 4258012 by Homam.Bahnassi Extending UVEdit material function to support mirroring. #jira UE-57306 Change 4258231 by Jamie.Dale Fixed GetHostName failing to convert UTF-8 data correctly Change 4258579 by Jamie.Dale Ensure that packages re-created after deleting their only asset are marked as fully loaded Change 4258652 by Jamie.Dale Added script exposed method to convert an Unreal relative path to absolute Change 4259124 by Patrick.Boutot For MediaBundle, show or hide the failed texture on console. #jira UE-61672 Change 4259264 by Jamie.Dale Show an error if trying to use ExecutePythonScript without Python enabled #jira UE-62318 Change 4259451 by Jamie.Dale No longer use stale subtitles in dialogue waves #jira UE-61500 Change 4259511 by Jamie.Dale Fix crash when passing None as the class for find/load_asset #jira UE-62130 Change 4259542 by Patrick.Boutot Can select the TimecodeSynchronizer from the Toolbar menu. Add option to show it in the toolbar. Can be defaulted by user/machine. Change 4259582 by Patrick.Boutot Hide Edit & Paste from PropertyMenuAssetPicker Change 4260760 by Max.Chen Sequencer: Fix dereferencing null pointer - CameraNode Change 4260895 by Jamie.Dale Changing localization target settings now updates the gather INI files immediately Change 4262166 by Patrick.Boutot Add support for MediaSourceProxy and MediaOutputProxy. Change 4262535 by Andrew.Rodham Sequencer: Added a method for user-defined capture protocols to resolve a buffer and pass it directly to a bound delegate handler Originating source CL#4261391 Change 4262669 by Patrick.Boutot Add MediaProfile. It let the user select their media sources and media outputs by machine by user. Change 4264577 by Patrick.Boutot Change the type of FMediaFrameworkCaptureCameraViewportCameraOutputInfo.LockedCameraActors to LazyObject to enable cross level reference. #jira UE-62438 Include dependence to settings Change 4265750 by JeanLuc.Corenthin Fix array's size issues with MeshDescription utility functions #jira UEENT-1574 Change 4268181 by Patrick.Boutot Mark LockedCameraActors as deprecated. #ROBOMERGE-OWNER: jason.bestimt #ROBOMERGE-SOURCE: CL 4279869 in //UE4/Main/... #ROBOMERGE-BOT: DEVVR (Main -> Dev-VR) [CL 4280409 by jeanmichel dignard in Dev-VR branch]
2480 lines
92 KiB
C++
2480 lines
92 KiB
C++
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AssetTools.h"
|
|
#include "Factories/Factory.h"
|
|
#include "Misc/MessageDialog.h"
|
|
#include "HAL/FileManager.h"
|
|
#include "Misc/FileHelper.h"
|
|
#include "Misc/Paths.h"
|
|
#include "Misc/ScopedSlowTask.h"
|
|
#include "UObject/GCObjectScopeGuard.h"
|
|
#include "UObject/UObjectHash.h"
|
|
#include "UObject/UObjectIterator.h"
|
|
#include "Engine/Blueprint.h"
|
|
#include "Exporters/Exporter.h"
|
|
#include "Editor/EditorEngine.h"
|
|
#include "SourceControlOperations.h"
|
|
#include "ISourceControlModule.h"
|
|
#include "SourceControlHelpers.h"
|
|
#include "Editor/UnrealEdEngine.h"
|
|
#include "Settings/EditorLoadingSavingSettings.h"
|
|
#include "ThumbnailRendering/ThumbnailManager.h"
|
|
#include "Editor.h"
|
|
#include "EditorDirectories.h"
|
|
#include "FileHelpers.h"
|
|
#include "UnrealEdGlobals.h"
|
|
#include "AssetToolsLog.h"
|
|
#include "AssetToolsModule.h"
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
#include "IClassTypeActions.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Blueprint.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Curve.h"
|
|
#include "AssetTypeActions/AssetTypeActions_MaterialInterface.h"
|
|
#include "AssetTypeActions/AssetTypeActions_SkeletalMesh.h"
|
|
#include "AssetTypeActions/AssetTypeActions_FbxSceneImportData.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Texture.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TextureRenderTarget.h"
|
|
#include "AssetTypeActions/AssetTypeActions_VectorField.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AnimationAsset.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AnimBlueprint.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AnimComposite.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AnimMontage.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AnimSequence.h"
|
|
#include "AssetTypeActions/AssetTypeActions_BlendSpace.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AimOffset.h"
|
|
#include "AssetTypeActions/AssetTypeActions_BlendSpace1D.h"
|
|
#include "AssetTypeActions/AssetTypeActions_AimOffset1D.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CameraAnim.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TextureRenderTarget2D.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CanvasRenderTarget2D.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CurveFloat.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CurveTable.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CurveVector.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CurveLinearColor.h"
|
|
#include "AssetTypeActions/AssetTypeActions_CurveLinearColorAtlas.h"
|
|
#include "AssetTypeActions/AssetTypeActions_DataAsset.h"
|
|
#include "AssetTypeActions/AssetTypeActions_DataTable.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Enum.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Class.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Struct.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Font.h"
|
|
#include "AssetTypeActions/AssetTypeActions_FontFace.h"
|
|
#include "AssetTypeActions/AssetTypeActions_ForceFeedbackEffect.h"
|
|
#include "AssetTypeActions/AssetTypeActions_HLODProxy.h"
|
|
#include "AssetTypeActions/AssetTypeActions_SubsurfaceProfile.h"
|
|
#include "AssetTypeActions/AssetTypeActions_InstancedFoliageSettings.h"
|
|
#include "AssetTypeActions/AssetTypeActions_InterpData.h"
|
|
#include "AssetTypeActions/AssetTypeActions_LandscapeLayer.h"
|
|
#include "AssetTypeActions/AssetTypeActions_LandscapeGrassType.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Material.h"
|
|
#include "AssetTypeActions/AssetTypeActions_MaterialFunction.h"
|
|
#include "AssetTypeActions/AssetTypeActions_MaterialFunctionInstance.h"
|
|
#include "AssetTypeActions/AssetTypeActions_MaterialInstanceConstant.h"
|
|
#include "AssetTypeActions/AssetTypeActions_MaterialParameterCollection.h"
|
|
#include "AssetTypeActions/AssetTypeActions_ObjectLibrary.h"
|
|
#include "AssetTypeActions/AssetTypeActions_ParticleSystem.h"
|
|
#include "AssetTypeActions/AssetTypeActions_PhysicalMaterial.h"
|
|
#include "AssetTypeActions/AssetTypeActions_PhysicsAsset.h"
|
|
#include "AssetTypeActions/AssetTypeActions_PoseAsset.h"
|
|
#include "AssetTypeActions/AssetTypeActions_PreviewMeshCollection.h"
|
|
#include "AssetTypeActions/AssetTypeActions_ProceduralFoliageSpawner.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Redirector.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Rig.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Skeleton.h"
|
|
#include "AssetTypeActions/AssetTypeActions_SlateBrush.h"
|
|
#include "AssetTypeActions/AssetTypeActions_SlateWidgetStyle.h"
|
|
#include "AssetTypeActions/AssetTypeActions_StaticMesh.h"
|
|
#include "AssetTypeActions/AssetTypeActions_Texture2D.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TextureCube.h"
|
|
#include "AssetTypeActions/AssetTypeActions_VolumeTexture.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TextureRenderTargetCube.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TextureLightProfile.h"
|
|
#include "AssetTypeActions/AssetTypeActions_TouchInterface.h"
|
|
#include "AssetTypeActions/AssetTypeActions_VectorFieldAnimated.h"
|
|
#include "AssetTypeActions/AssetTypeActions_VectorFieldStatic.h"
|
|
#include "AssetTypeActions/AssetTypeActions_World.h"
|
|
#include "SDiscoveringAssetsDialog.h"
|
|
#include "AssetFixUpRedirectors.h"
|
|
#include "ObjectTools.h"
|
|
#include "PackageTools.h"
|
|
#include "AssetRegistryModule.h"
|
|
#include "DesktopPlatformModule.h"
|
|
#include "IContentBrowserSingleton.h"
|
|
#include "ContentBrowserModule.h"
|
|
#include "SPackageReportDialog.h"
|
|
#include "EngineAnalytics.h"
|
|
#include "AnalyticsEventAttribute.h"
|
|
#include "Interfaces/IAnalyticsProvider.h"
|
|
#include "Logging/MessageLog.h"
|
|
#include "UnrealExporter.h"
|
|
#include "Framework/Notifications/NotificationManager.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "Widgets/Notifications/SNotificationList.h"
|
|
#include "AutomatedAssetImportData.h"
|
|
#include "AssetImportTask.h"
|
|
#include "Dialogs/DlgPickPath.h"
|
|
#include "Misc/FeedbackContext.h"
|
|
#include "BusyCursor.h"
|
|
#include "AssetExportTask.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "AssetTools"
|
|
|
|
|
|
TScriptInterface<IAssetTools> UAssetToolsHelpers::GetAssetTools()
|
|
{
|
|
return &UAssetToolsImpl::Get();
|
|
}
|
|
|
|
/** UInterface constructor */
|
|
UAssetTools::UAssetTools(const class FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
UAssetToolsImpl::UAssetToolsImpl(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
, AssetRenameManager(MakeShareable(new FAssetRenameManager))
|
|
, AssetFixUpRedirectors(MakeShareable(new FAssetFixUpRedirectors))
|
|
, NextUserCategoryBit(EAssetTypeCategories::FirstUser)
|
|
{
|
|
// Register the built-in advanced categories
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_0"), FAdvancedAssetCategory(EAssetTypeCategories::Animation, LOCTEXT("AnimationAssetCategory", "Animation")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_1"), FAdvancedAssetCategory(EAssetTypeCategories::Blueprint, LOCTEXT("BlueprintAssetCategory", "Blueprints")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_2"), FAdvancedAssetCategory(EAssetTypeCategories::MaterialsAndTextures, LOCTEXT("MaterialAssetCategory", "Materials & Textures")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_3"), FAdvancedAssetCategory(EAssetTypeCategories::Sounds, LOCTEXT("SoundAssetCategory", "Sounds")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_4"), FAdvancedAssetCategory(EAssetTypeCategories::Physics, LOCTEXT("PhysicsAssetCategory", "Physics")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_5"), FAdvancedAssetCategory(EAssetTypeCategories::UI, LOCTEXT("UserInterfaceAssetCategory", "User Interface")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_6"), FAdvancedAssetCategory(EAssetTypeCategories::Misc, LOCTEXT("MiscellaneousAssetCategory", "Miscellaneous")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_7"), FAdvancedAssetCategory(EAssetTypeCategories::Gameplay, LOCTEXT("GameplayAssetCategory", "Gameplay")));
|
|
AllocatedCategoryBits.Add(TEXT("_BuiltIn_8"), FAdvancedAssetCategory(EAssetTypeCategories::Media, LOCTEXT("MediaAssetCategory", "Media")));
|
|
|
|
EAssetTypeCategories::Type BlendablesCategoryBit = RegisterAdvancedAssetCategory(FName(TEXT("Blendables")), LOCTEXT("BlendablesAssetCategory", "Blendables"));
|
|
|
|
// Register the built-in asset type actions
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AnimationAsset));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AnimBlueprint));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AnimComposite));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AnimMontage));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AnimSequence));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AimOffset));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_AimOffset1D));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_BlendSpace));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PoseAsset));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_BlendSpace1D));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Blueprint));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CameraAnim));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CanvasRenderTarget2D));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Curve));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CurveFloat));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CurveTable));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CurveVector));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CurveLinearColor));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_CurveLinearColorAtlas));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_DataAsset));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_DataTable));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Enum));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Class));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Struct));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_SceneImportData));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Font));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_FontFace));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ForceFeedbackEffect));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_HLODProxy));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_SubsurfaceProfile));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_InstancedFoliageSettings));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_InterpData));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_LandscapeLayer));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_LandscapeGrassType));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Material(BlendablesCategoryBit)));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunction));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunctionLayer));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunctionLayerInstance));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunctionLayerBlend));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunctionLayerBlendInstance));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialFunctionInstance));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialInstanceConstant(BlendablesCategoryBit)));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialInterface));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_MaterialParameterCollection));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ObjectLibrary));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ParticleSystem));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PhysicalMaterial));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PhysicsAsset));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PreviewMeshCollection));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ProceduralFoliageSpawner));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Redirector));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Rig));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_SkeletalMesh));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Skeleton));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_SlateBrush));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_SlateWidgetStyle));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_StaticMesh));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Texture));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_Texture2D));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TextureCube));
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_VolumeTexture) );
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TextureRenderTarget));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TextureRenderTarget2D));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TextureRenderTargetCube));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TextureLightProfile));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_TouchInterface));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_VectorField));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_VectorFieldAnimated));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_VectorFieldStatic));
|
|
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_World));
|
|
|
|
// Note: Please don't add any more actions here! They belong in an editor-only module that is more tightly
|
|
// coupled to your new system, and you should not create a dependency on your new system from AssetTools.
|
|
}
|
|
|
|
void UAssetToolsImpl::RegisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& NewActions)
|
|
{
|
|
AssetTypeActionsList.Add(NewActions);
|
|
}
|
|
|
|
void UAssetToolsImpl::UnregisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& ActionsToRemove)
|
|
{
|
|
AssetTypeActionsList.Remove(ActionsToRemove);
|
|
}
|
|
|
|
void UAssetToolsImpl::GetAssetTypeActionsList( TArray<TWeakPtr<IAssetTypeActions>>& OutAssetTypeActionsList ) const
|
|
{
|
|
for (auto ActionsIt = AssetTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
|
|
{
|
|
OutAssetTypeActionsList.Add(*ActionsIt);
|
|
}
|
|
}
|
|
|
|
TWeakPtr<IAssetTypeActions> UAssetToolsImpl::GetAssetTypeActionsForClass( UClass* Class ) const
|
|
{
|
|
TSharedPtr<IAssetTypeActions> MostDerivedAssetTypeActions;
|
|
|
|
for (int32 TypeActionsIdx = 0; TypeActionsIdx < AssetTypeActionsList.Num(); ++TypeActionsIdx)
|
|
{
|
|
TSharedRef<IAssetTypeActions> TypeActions = AssetTypeActionsList[TypeActionsIdx];
|
|
UClass* SupportedClass = TypeActions->GetSupportedClass();
|
|
|
|
if ( Class->IsChildOf(SupportedClass) )
|
|
{
|
|
if ( !MostDerivedAssetTypeActions.IsValid() || SupportedClass->IsChildOf( MostDerivedAssetTypeActions->GetSupportedClass() ) )
|
|
{
|
|
MostDerivedAssetTypeActions = TypeActions;
|
|
}
|
|
}
|
|
}
|
|
|
|
return MostDerivedAssetTypeActions;
|
|
}
|
|
|
|
TArray<TWeakPtr<IAssetTypeActions>> UAssetToolsImpl::GetAssetTypeActionsListForClass(UClass* Class) const
|
|
{
|
|
TArray<TWeakPtr<IAssetTypeActions>> ResultAssetTypeActionsList;
|
|
|
|
for (int32 TypeActionsIdx = 0; TypeActionsIdx < AssetTypeActionsList.Num(); ++TypeActionsIdx)
|
|
{
|
|
TSharedRef<IAssetTypeActions> TypeActions = AssetTypeActionsList[TypeActionsIdx];
|
|
UClass* SupportedClass = TypeActions->GetSupportedClass();
|
|
|
|
if (Class->IsChildOf(SupportedClass))
|
|
{
|
|
ResultAssetTypeActionsList.Add(TypeActions);
|
|
}
|
|
}
|
|
|
|
return ResultAssetTypeActionsList;
|
|
}
|
|
|
|
EAssetTypeCategories::Type UAssetToolsImpl::RegisterAdvancedAssetCategory(FName CategoryKey, FText CategoryDisplayName)
|
|
{
|
|
EAssetTypeCategories::Type Result = FindAdvancedAssetCategory(CategoryKey);
|
|
if (Result == EAssetTypeCategories::Misc)
|
|
{
|
|
if (NextUserCategoryBit != 0)
|
|
{
|
|
// Register the category
|
|
Result = (EAssetTypeCategories::Type)NextUserCategoryBit;
|
|
AllocatedCategoryBits.Add(CategoryKey, FAdvancedAssetCategory(Result, CategoryDisplayName));
|
|
|
|
// Advance to the next bit, or store that we're out
|
|
if (NextUserCategoryBit == EAssetTypeCategories::LastUser)
|
|
{
|
|
NextUserCategoryBit = 0;
|
|
}
|
|
else
|
|
{
|
|
NextUserCategoryBit = NextUserCategoryBit << 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogAssetTools, Warning, TEXT("RegisterAssetTypeCategory(\"%s\", \"%s\") failed as all user bits have been exhausted (placing into the Misc category instead)"), *CategoryKey.ToString(), *CategoryDisplayName.ToString());
|
|
}
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
EAssetTypeCategories::Type UAssetToolsImpl::FindAdvancedAssetCategory(FName CategoryKey) const
|
|
{
|
|
if (const FAdvancedAssetCategory* ExistingCategory = AllocatedCategoryBits.Find(CategoryKey))
|
|
{
|
|
return ExistingCategory->CategoryType;
|
|
}
|
|
else
|
|
{
|
|
return EAssetTypeCategories::Misc;
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::GetAllAdvancedAssetCategories(TArray<FAdvancedAssetCategory>& OutCategoryList) const
|
|
{
|
|
AllocatedCategoryBits.GenerateValueArray(OutCategoryList);
|
|
}
|
|
|
|
void UAssetToolsImpl::RegisterClassTypeActions(const TSharedRef<IClassTypeActions>& NewActions)
|
|
{
|
|
ClassTypeActionsList.Add(NewActions);
|
|
}
|
|
|
|
void UAssetToolsImpl::UnregisterClassTypeActions(const TSharedRef<IClassTypeActions>& ActionsToRemove)
|
|
{
|
|
ClassTypeActionsList.Remove(ActionsToRemove);
|
|
}
|
|
|
|
void UAssetToolsImpl::GetClassTypeActionsList( TArray<TWeakPtr<IClassTypeActions>>& OutClassTypeActionsList ) const
|
|
{
|
|
for (auto ActionsIt = ClassTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
|
|
{
|
|
OutClassTypeActionsList.Add(*ActionsIt);
|
|
}
|
|
}
|
|
|
|
TWeakPtr<IClassTypeActions> UAssetToolsImpl::GetClassTypeActionsForClass( UClass* Class ) const
|
|
{
|
|
TSharedPtr<IClassTypeActions> MostDerivedClassTypeActions;
|
|
|
|
for (int32 TypeActionsIdx = 0; TypeActionsIdx < ClassTypeActionsList.Num(); ++TypeActionsIdx)
|
|
{
|
|
TSharedRef<IClassTypeActions> TypeActions = ClassTypeActionsList[TypeActionsIdx];
|
|
UClass* SupportedClass = TypeActions->GetSupportedClass();
|
|
|
|
if ( Class->IsChildOf(SupportedClass) )
|
|
{
|
|
if ( !MostDerivedClassTypeActions.IsValid() || SupportedClass->IsChildOf( MostDerivedClassTypeActions->GetSupportedClass() ) )
|
|
{
|
|
MostDerivedClassTypeActions = TypeActions;
|
|
}
|
|
}
|
|
}
|
|
|
|
return MostDerivedClassTypeActions;
|
|
}
|
|
|
|
bool UAssetToolsImpl::GetAssetActions( const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder, bool bIncludeHeading )
|
|
{
|
|
bool bAddedActions = false;
|
|
|
|
if ( InObjects.Num() )
|
|
{
|
|
// Find the most derived common class for all passed in Objects
|
|
UClass* CommonClass = InObjects[0]->GetClass();
|
|
for (int32 ObjIdx = 1; ObjIdx < InObjects.Num(); ++ObjIdx)
|
|
{
|
|
while (!InObjects[ObjIdx]->IsA(CommonClass))
|
|
{
|
|
CommonClass = CommonClass->GetSuperClass();
|
|
}
|
|
}
|
|
|
|
// Get the nearest common asset type for all the selected objects
|
|
TSharedPtr<IAssetTypeActions> CommonAssetTypeActions = GetAssetTypeActionsForClass(CommonClass).Pin();
|
|
|
|
// If we found a common type actions object, get actions from it
|
|
if ( CommonAssetTypeActions.IsValid() && CommonAssetTypeActions->HasActions(InObjects) )
|
|
{
|
|
if ( bIncludeHeading )
|
|
{
|
|
MenuBuilder.BeginSection("GetAssetActions", FText::Format( LOCTEXT("AssetSpecificOptionsMenuHeading", "{0} Actions"), CommonAssetTypeActions->GetName() ) );
|
|
}
|
|
|
|
// Get the actions
|
|
CommonAssetTypeActions->GetActions(InObjects, MenuBuilder);
|
|
|
|
if ( bIncludeHeading )
|
|
{
|
|
MenuBuilder.EndSection();
|
|
}
|
|
|
|
bAddedActions = true;
|
|
}
|
|
}
|
|
|
|
return bAddedActions;
|
|
}
|
|
|
|
struct FRootedOnScope
|
|
{
|
|
UObject* Obj;
|
|
|
|
FRootedOnScope(UObject* InObj) : Obj(nullptr)
|
|
{
|
|
if (InObj && !InObj->IsRooted())
|
|
{
|
|
Obj = InObj;
|
|
Obj->AddToRoot();
|
|
}
|
|
}
|
|
|
|
~FRootedOnScope()
|
|
{
|
|
if (Obj)
|
|
{
|
|
Obj->RemoveFromRoot();
|
|
}
|
|
}
|
|
};
|
|
|
|
UObject* UAssetToolsImpl::CreateAsset(const FString& AssetName, const FString& PackagePath, UClass* AssetClass, UFactory* Factory, FName CallingContext)
|
|
{
|
|
FRootedOnScope DontGCFactory(Factory);
|
|
|
|
// Verify the factory class
|
|
if ( !ensure(AssetClass || Factory) )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("MustSupplyClassOrFactory", "The new asset wasn't created due to a problem finding the appropriate factory or class for the new asset.") );
|
|
return nullptr;
|
|
}
|
|
|
|
if ( AssetClass && Factory && !ensure(AssetClass->IsChildOf(Factory->GetSupportedClass())) )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("InvalidFactory", "The new asset wasn't created because the supplied factory does not support the supplied class.") );
|
|
return nullptr;
|
|
}
|
|
|
|
const FString PackageName = UPackageTools::SanitizePackageName(PackagePath + TEXT("/") + AssetName);
|
|
|
|
// Make sure we can create the asset without conflicts
|
|
if ( !CanCreateAsset(AssetName, PackageName, LOCTEXT("CreateANewObject", "Create a new object")) )
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
UClass* ClassToUse = AssetClass ? AssetClass : (Factory ? Factory->GetSupportedClass() : nullptr);
|
|
|
|
UPackage* Pkg = CreatePackage(nullptr,*PackageName);
|
|
UObject* NewObj = nullptr;
|
|
EObjectFlags Flags = RF_Public|RF_Standalone|RF_Transactional;
|
|
if ( Factory )
|
|
{
|
|
NewObj = Factory->FactoryCreateNew(ClassToUse, Pkg, FName( *AssetName ), Flags, nullptr, GWarn, CallingContext);
|
|
}
|
|
else if ( AssetClass )
|
|
{
|
|
NewObj = NewObject<UObject>(Pkg, ClassToUse, FName(*AssetName), Flags);
|
|
}
|
|
|
|
if( NewObj )
|
|
{
|
|
// Notify the asset registry
|
|
FAssetRegistryModule::AssetCreated(NewObj);
|
|
|
|
// analytics create record
|
|
UAssetToolsImpl::OnNewCreateRecord(AssetClass, false);
|
|
|
|
// Mark the package dirty...
|
|
Pkg->MarkPackageDirty();
|
|
}
|
|
|
|
return NewObj;
|
|
}
|
|
|
|
UObject* UAssetToolsImpl::CreateAsset(UClass* AssetClass, UFactory* Factory, FName CallingContext /*= NAME_None*/)
|
|
{
|
|
return CreateAssetWithDialog(AssetClass, Factory, CallingContext);
|
|
}
|
|
|
|
UObject* UAssetToolsImpl::CreateAssetWithDialog(UClass* AssetClass, UFactory* Factory, FName CallingContext)
|
|
{
|
|
if (Factory != nullptr)
|
|
{
|
|
// Determine the starting path. Try to use the most recently used directory
|
|
FString AssetPath;
|
|
|
|
const FString DefaultFilesystemDirectory = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::NEW_ASSET);
|
|
if (DefaultFilesystemDirectory.IsEmpty() || !FPackageName::TryConvertFilenameToLongPackageName(DefaultFilesystemDirectory, AssetPath))
|
|
{
|
|
// No saved path, just use the game content root
|
|
AssetPath = TEXT("/Game");
|
|
}
|
|
|
|
FString PackageName;
|
|
FString AssetName;
|
|
CreateUniqueAssetName(AssetPath / Factory->GetDefaultNewAssetName(), TEXT(""), PackageName, AssetName);
|
|
|
|
return CreateAssetWithDialog(AssetName, AssetPath, AssetClass, Factory, CallingContext);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
|
|
UObject* UAssetToolsImpl::CreateAssetWithDialog(const FString& AssetName, const FString& PackagePath, UClass* AssetClass, UFactory* Factory, FName CallingContext)
|
|
{
|
|
FSaveAssetDialogConfig SaveAssetDialogConfig;
|
|
SaveAssetDialogConfig.DialogTitleOverride = LOCTEXT("SaveAssetDialogTitle", "Save Asset As");
|
|
SaveAssetDialogConfig.DefaultPath = PackagePath;
|
|
SaveAssetDialogConfig.DefaultAssetName = AssetName;
|
|
SaveAssetDialogConfig.ExistingAssetPolicy = ESaveAssetDialogExistingAssetPolicy::AllowButWarn;
|
|
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
FString SaveObjectPath = ContentBrowserModule.Get().CreateModalSaveAssetDialog(SaveAssetDialogConfig);
|
|
if (!SaveObjectPath.IsEmpty())
|
|
{
|
|
FEditorDelegates::OnConfigureNewAssetProperties.Broadcast(Factory);
|
|
if (Factory->ConfigureProperties())
|
|
{
|
|
const FString SavePackageName = FPackageName::ObjectPathToPackageName(SaveObjectPath);
|
|
const FString SavePackagePath = FPaths::GetPath(SavePackageName);
|
|
const FString SaveAssetName = FPaths::GetBaseFilename(SavePackageName);
|
|
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::NEW_ASSET, PackagePath);
|
|
|
|
return CreateAsset(SaveAssetName, SavePackagePath, AssetClass, Factory, CallingContext);
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
UObject* UAssetToolsImpl::DuplicateAssetWithDialog(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject)
|
|
{
|
|
FSaveAssetDialogConfig SaveAssetDialogConfig;
|
|
SaveAssetDialogConfig.DialogTitleOverride = LOCTEXT("DuplicateAssetDialogTitle", "Duplicate Asset As");
|
|
SaveAssetDialogConfig.DefaultPath = PackagePath;
|
|
SaveAssetDialogConfig.DefaultAssetName = AssetName;
|
|
SaveAssetDialogConfig.ExistingAssetPolicy = ESaveAssetDialogExistingAssetPolicy::AllowButWarn;
|
|
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
FString SaveObjectPath = ContentBrowserModule.Get().CreateModalSaveAssetDialog(SaveAssetDialogConfig);
|
|
if (!SaveObjectPath.IsEmpty())
|
|
{
|
|
const FString SavePackageName = FPackageName::ObjectPathToPackageName(SaveObjectPath);
|
|
const FString SavePackagePath = FPaths::GetPath(SavePackageName);
|
|
const FString SaveAssetName = FPaths::GetBaseFilename(SavePackageName);
|
|
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::NEW_ASSET, PackagePath);
|
|
|
|
return PerformDuplicateAsset(SaveAssetName, SavePackagePath, OriginalObject, true);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
UObject* UAssetToolsImpl::DuplicateAsset(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject)
|
|
{
|
|
return PerformDuplicateAsset(AssetName, PackagePath, OriginalObject, false);
|
|
}
|
|
|
|
UObject* UAssetToolsImpl::PerformDuplicateAsset(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject, bool bWithDialog)
|
|
{
|
|
// Verify the source object
|
|
if ( !OriginalObject )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("InvalidSourceObject", "The new asset wasn't created due to a problem finding the object to duplicate.") );
|
|
return nullptr;
|
|
}
|
|
|
|
const FString PackageName = PackagePath + TEXT("/") + AssetName;
|
|
|
|
// Make sure we can create the asset without conflicts
|
|
if ( !CanCreateAsset(AssetName, PackageName, LOCTEXT("DuplicateAnObject", "Duplicate an object")) )
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
ObjectTools::FPackageGroupName PGN;
|
|
PGN.PackageName = PackageName;
|
|
PGN.GroupName = TEXT("");
|
|
PGN.ObjectName = AssetName;
|
|
|
|
TSet<UPackage*> ObjectsUserRefusedToFullyLoad;
|
|
bool bPromtToOverwrite = bWithDialog;
|
|
UObject* NewObject = ObjectTools::DuplicateSingleObject(OriginalObject, PGN, ObjectsUserRefusedToFullyLoad, bPromtToOverwrite);
|
|
if(NewObject != nullptr)
|
|
{
|
|
if ( ISourceControlModule::Get().IsEnabled() )
|
|
{
|
|
// Save package here if SCC is enabled because the user can use SCC to revert a change
|
|
TArray<UPackage*> OutermostPackagesToSave;
|
|
OutermostPackagesToSave.Add(NewObject->GetOutermost());
|
|
|
|
const bool bCheckDirty = false;
|
|
const bool bPromptToSave = false;
|
|
FEditorFileUtils::PromptForCheckoutAndSave(OutermostPackagesToSave, bCheckDirty, bPromptToSave);
|
|
|
|
// now attempt to branch, we can do this now as we should have a file on disk
|
|
SourceControlHelpers::BranchPackage(NewObject->GetOutermost(), OriginalObject->GetOutermost());
|
|
}
|
|
|
|
// analytics create record
|
|
UAssetToolsImpl::OnNewCreateRecord(NewObject->GetClass(), true);
|
|
}
|
|
|
|
return NewObject;
|
|
}
|
|
|
|
bool UAssetToolsImpl::RenameAssets(const TArray<FAssetRenameData>& AssetsAndNames) const
|
|
{
|
|
return AssetRenameManager->RenameAssets(AssetsAndNames);
|
|
}
|
|
|
|
void UAssetToolsImpl::RenameAssetsWithDialog(const TArray<FAssetRenameData>& AssetsAndNames, bool bAutoCheckout) const
|
|
{
|
|
AssetRenameManager->RenameAssetsWithDialog(AssetsAndNames, bAutoCheckout);
|
|
}
|
|
|
|
void UAssetToolsImpl::FindSoftReferencesToObject(FSoftObjectPath TargetObject, TArray<UObject*>& ReferencingObjects) const
|
|
{
|
|
AssetRenameManager->FindSoftReferencesToObject(TargetObject, ReferencingObjects);
|
|
}
|
|
|
|
TArray<UObject*> UAssetToolsImpl::ImportAssets(const FString& DestinationPath)
|
|
{
|
|
return ImportAssetsWithDialog(DestinationPath);
|
|
}
|
|
|
|
TArray<UObject*> UAssetToolsImpl::ImportAssetsWithDialog(const FString& DestinationPath)
|
|
{
|
|
TArray<UObject*> ReturnObjects;
|
|
FString FileTypes, AllExtensions;
|
|
TArray<UFactory*> Factories;
|
|
|
|
// Get the list of valid factories
|
|
for( TObjectIterator<UClass> It ; It ; ++It )
|
|
{
|
|
UClass* CurrentClass = (*It);
|
|
|
|
if( CurrentClass->IsChildOf(UFactory::StaticClass()) && !(CurrentClass->HasAnyClassFlags(CLASS_Abstract)) )
|
|
{
|
|
UFactory* Factory = Cast<UFactory>( CurrentClass->GetDefaultObject() );
|
|
if( Factory->bEditorImport )
|
|
{
|
|
Factories.Add( Factory );
|
|
}
|
|
}
|
|
}
|
|
|
|
TMultiMap<uint32, UFactory*> FilterIndexToFactory;
|
|
|
|
// Generate the file types and extensions represented by the selected factories
|
|
ObjectTools::GenerateFactoryFileExtensions( Factories, FileTypes, AllExtensions, FilterIndexToFactory );
|
|
|
|
FileTypes = FString::Printf(TEXT("All Files (%s)|%s|%s"),*AllExtensions,*AllExtensions,*FileTypes);
|
|
|
|
// Prompt the user for the filenames
|
|
TArray<FString> OpenFilenames;
|
|
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
|
|
bool bOpened = false;
|
|
int32 FilterIndex = -1;
|
|
|
|
if ( DesktopPlatform )
|
|
{
|
|
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
|
|
|
|
bOpened = DesktopPlatform->OpenFileDialog(
|
|
ParentWindowWindowHandle,
|
|
LOCTEXT("ImportDialogTitle", "Import").ToString(),
|
|
FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT),
|
|
TEXT(""),
|
|
FileTypes,
|
|
EFileDialogFlags::Multiple,
|
|
OpenFilenames,
|
|
FilterIndex
|
|
);
|
|
}
|
|
|
|
if ( bOpened )
|
|
{
|
|
if ( OpenFilenames.Num() > 0 )
|
|
{
|
|
UFactory* ChosenFactory = nullptr;
|
|
if (FilterIndex > 0)
|
|
{
|
|
ChosenFactory = *FilterIndexToFactory.Find(FilterIndex);
|
|
}
|
|
|
|
|
|
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, OpenFilenames[0]);
|
|
ReturnObjects = ImportAssets(OpenFilenames, DestinationPath, ChosenFactory);
|
|
}
|
|
}
|
|
|
|
return ReturnObjects;
|
|
}
|
|
|
|
TArray<UObject*> UAssetToolsImpl::ImportAssetsAutomated(const UAutomatedAssetImportData* ImportData) const
|
|
{
|
|
check(ImportData);
|
|
|
|
FAssetImportParams Params;
|
|
|
|
Params.bAutomated = true;
|
|
Params.bForceOverrideExisting = ImportData->bReplaceExisting;
|
|
Params.bSyncToBrowser = false;
|
|
Params.SpecifiedFactory = ImportData->Factory;
|
|
Params.ImportData = ImportData;
|
|
|
|
return ImportAssetsInternal(ImportData->Filenames, ImportData->DestinationPath, nullptr, Params);
|
|
}
|
|
|
|
void UAssetToolsImpl::ImportAssetTasks(const TArray<UAssetImportTask*>& ImportTasks) const
|
|
{
|
|
FScopedSlowTask SlowTask(ImportTasks.Num(), LOCTEXT("ImportSlowTask", "Importing"));
|
|
SlowTask.MakeDialog();
|
|
|
|
FAssetImportParams Params;
|
|
Params.bSyncToBrowser = false;
|
|
|
|
TArray<FString> Filenames;
|
|
Filenames.Add(TEXT(""));
|
|
TArray<UPackage*> PackagesToSave;
|
|
for (UAssetImportTask* ImportTask : ImportTasks)
|
|
{
|
|
if (!ImportTask)
|
|
{
|
|
UE_LOG(LogAssetTools, Warning, TEXT("ImportAssetTasks() supplied an empty task"));
|
|
continue;
|
|
}
|
|
|
|
SlowTask.EnterProgressFrame(1, FText::Format(LOCTEXT("Import_ImportingFile", "Importing \"{0}\"..."), FText::FromString(FPaths::GetBaseFilename(ImportTask->Filename))));
|
|
|
|
Params.AssetImportTask = ImportTask;
|
|
Params.bForceOverrideExisting = ImportTask->bReplaceExisting;
|
|
Params.bAutomated = ImportTask->bAutomated;
|
|
Filenames[0] = ImportTask->Filename;
|
|
TArray<UObject*> ImportedObjects = ImportAssetsInternal(Filenames, ImportTask->DestinationPath, nullptr, Params);
|
|
|
|
PackagesToSave.Reset(1);
|
|
for (UObject* Object : ImportedObjects)
|
|
{
|
|
ImportTask->ImportedObjectPaths.Add(Object->GetPathName());
|
|
if (ImportTask->bSave)
|
|
{
|
|
PackagesToSave.AddUnique(Object->GetOutermost());
|
|
}
|
|
}
|
|
|
|
if (ImportTask->bSave)
|
|
{
|
|
UEditorLoadingAndSavingUtils::SavePackages(PackagesToSave, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::ExportAssets(const TArray<FString>& AssetsToExport, const FString& ExportPath) const
|
|
{
|
|
TArray<UObject*> AssetObjectsToExport;
|
|
AssetObjectsToExport.Reserve(AssetsToExport.Num());
|
|
|
|
for (const FString& AssetStr : AssetsToExport)
|
|
{
|
|
UObject* Asset = LoadObject<UObject>(nullptr, *AssetStr);
|
|
if (Asset)
|
|
{
|
|
AssetObjectsToExport.Add(Asset);
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogAssetTools, Error, TEXT("Could not load asset '%s' to export it"), *AssetStr);
|
|
}
|
|
}
|
|
|
|
const bool bPromptIndividualFilenames = false;
|
|
ExportAssetsInternal(AssetObjectsToExport, bPromptIndividualFilenames, ExportPath);
|
|
}
|
|
|
|
void UAssetToolsImpl::ExportAssets(const TArray<UObject*>& AssetsToExport, const FString& ExportPath) const
|
|
{
|
|
const bool bPromptIndividualFilenames = false;
|
|
ExportAssetsInternal(AssetsToExport, bPromptIndividualFilenames, ExportPath);
|
|
}
|
|
|
|
void UAssetToolsImpl::ExportAssetsWithDialog(const TArray<UObject*>& AssetsToExport, bool bPromptForIndividualFilenames) const
|
|
{
|
|
ExportAssetsInternal(AssetsToExport, bPromptForIndividualFilenames, TEXT(""));
|
|
}
|
|
|
|
void UAssetToolsImpl::ExportAssetsWithDialog(const TArray<FString>& AssetsToExport, bool bPromptForIndividualFilenames) const
|
|
{
|
|
TArray<UObject*> AssetObjectsToExport;
|
|
AssetObjectsToExport.Reserve(AssetsToExport.Num());
|
|
|
|
for (const FString& AssetStr : AssetsToExport)
|
|
{
|
|
UObject* Asset = LoadObject<UObject>(nullptr, *AssetStr);
|
|
if (Asset)
|
|
{
|
|
AssetObjectsToExport.Add(Asset);
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogAssetTools, Error, TEXT("Could not load asset '%s' to export it"), *AssetStr);
|
|
}
|
|
}
|
|
|
|
ExportAssetsInternal(AssetObjectsToExport, bPromptForIndividualFilenames, TEXT(""));
|
|
}
|
|
|
|
void UAssetToolsImpl::ExpandDirectories(const TArray<FString>& Files, const FString& DestinationPath, TArray<TPair<FString, FString>>& FilesAndDestinations) const
|
|
{
|
|
// Iterate through all files in the list, if any folders are found, recurse and expand them.
|
|
for ( int32 FileIdx = 0; FileIdx < Files.Num(); ++FileIdx )
|
|
{
|
|
const FString& Filename = Files[FileIdx];
|
|
|
|
// If the file being imported is a directory, just include all sub-files and skip the directory.
|
|
if ( IFileManager::Get().DirectoryExists(*Filename) )
|
|
{
|
|
FString FolderName = FPaths::GetCleanFilename(Filename);
|
|
|
|
// Get all files & folders in the folder.
|
|
FString SearchPath = Filename / FString(TEXT("*"));
|
|
TArray<FString> SubFiles;
|
|
IFileManager::Get().FindFiles(SubFiles, *SearchPath, true, true);
|
|
|
|
// FindFiles just returns file and directory names, so we need to tack on the root path to get the full path.
|
|
TArray<FString> FullPathItems;
|
|
for ( FString& SubFile : SubFiles )
|
|
{
|
|
FullPathItems.Add(Filename / SubFile);
|
|
}
|
|
|
|
// Expand any sub directories found.
|
|
FString NewSubDestination = DestinationPath / FolderName;
|
|
ExpandDirectories(FullPathItems, NewSubDestination, FilesAndDestinations);
|
|
}
|
|
else
|
|
{
|
|
// Add any files and their destination path.
|
|
FilesAndDestinations.Emplace(Filename, DestinationPath);
|
|
}
|
|
}
|
|
}
|
|
TArray<UObject*> UAssetToolsImpl::ImportAssets(const TArray<FString>& Files, const FString& DestinationPath, UFactory* ChosenFactory, bool bSyncToBrowser /* = true */, TArray<TPair<FString, FString>>* FilesAndDestinations /* = nullptr */) const
|
|
{
|
|
const bool bForceOverrideExisting = false;
|
|
|
|
FAssetImportParams Params;
|
|
|
|
Params.bAutomated = false;
|
|
Params.bForceOverrideExisting = false;
|
|
Params.bSyncToBrowser = bSyncToBrowser;
|
|
Params.SpecifiedFactory = ChosenFactory;
|
|
|
|
return ImportAssetsInternal(Files, DestinationPath, FilesAndDestinations, Params);
|
|
}
|
|
|
|
void UAssetToolsImpl::CreateUniqueAssetName(const FString& InBasePackageName, const FString& InSuffix, FString& OutPackageName, FString& OutAssetName) const
|
|
{
|
|
const FString SanitizedBasePackageName = UPackageTools::SanitizePackageName(InBasePackageName);
|
|
|
|
const FString PackagePath = FPackageName::GetLongPackagePath(SanitizedBasePackageName);
|
|
const FString BaseAssetNameWithSuffix = FPackageName::GetLongPackageAssetName(SanitizedBasePackageName) + InSuffix;
|
|
const FString SanitizedBaseAssetName = ObjectTools::SanitizeObjectName(BaseAssetNameWithSuffix);
|
|
|
|
int32 IntSuffix = 0;
|
|
bool bObjectExists = false;
|
|
|
|
int32 CharIndex = SanitizedBaseAssetName.Len() - 1;
|
|
while (CharIndex >= 0 && SanitizedBaseAssetName[CharIndex] >= TEXT('0') && SanitizedBaseAssetName[CharIndex] <= TEXT('9'))
|
|
{
|
|
--CharIndex;
|
|
}
|
|
FString TrailingInteger;
|
|
FString TrimmedBaseAssetName = SanitizedBaseAssetName;
|
|
if (SanitizedBaseAssetName.Len() > 0 && CharIndex == -1)
|
|
{
|
|
// This is the all numeric name, in this case we'd like to append _number, because just adding a number isn't great
|
|
TrimmedBaseAssetName += TEXT("_");
|
|
IntSuffix = 2;
|
|
}
|
|
if (CharIndex >= 0 && CharIndex < SanitizedBaseAssetName.Len() - 1)
|
|
{
|
|
TrailingInteger = SanitizedBaseAssetName.RightChop(CharIndex + 1);
|
|
TrimmedBaseAssetName = SanitizedBaseAssetName.Left(CharIndex + 1);
|
|
IntSuffix = FCString::Atoi(*TrailingInteger);
|
|
}
|
|
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
|
|
do
|
|
{
|
|
bObjectExists = false;
|
|
if ( IntSuffix < 1 )
|
|
{
|
|
OutAssetName = SanitizedBaseAssetName;
|
|
}
|
|
else
|
|
{
|
|
FString Suffix = FString::Printf(TEXT("%d"), IntSuffix);
|
|
while (Suffix.Len() < TrailingInteger.Len())
|
|
{
|
|
Suffix = TEXT("0") + Suffix;
|
|
}
|
|
OutAssetName = FString::Printf(TEXT("%s%s"), *TrimmedBaseAssetName, *Suffix);
|
|
}
|
|
|
|
OutPackageName = PackagePath + TEXT("/") + OutAssetName;
|
|
FString ObjectPath = OutPackageName + TEXT(".") + OutAssetName;
|
|
|
|
// Use the asset registry if possible to find existing assets without loading them
|
|
if ( !AssetRegistryModule.Get().IsLoadingAssets() )
|
|
{
|
|
FAssetData AssetData = AssetRegistryModule.Get().GetAssetByObjectPath(*ObjectPath);
|
|
if(AssetData.IsValid())
|
|
{
|
|
bObjectExists = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bObjectExists = LoadObject<UObject>(nullptr, *ObjectPath, nullptr, LOAD_NoWarn | LOAD_NoRedirects) != nullptr;
|
|
}
|
|
IntSuffix++;
|
|
}
|
|
while (bObjectExists != false);
|
|
}
|
|
|
|
bool UAssetToolsImpl::AssetUsesGenericThumbnail( const FAssetData& AssetData ) const
|
|
{
|
|
if ( !AssetData.IsValid() )
|
|
{
|
|
// Invalid asset, assume it does not use a shared thumbnail
|
|
return false;
|
|
}
|
|
|
|
if( AssetData.IsAssetLoaded() )
|
|
{
|
|
// Loaded asset, see if there is a rendering info for it
|
|
UObject* Asset = AssetData.GetAsset();
|
|
FThumbnailRenderingInfo* RenderInfo = GUnrealEd->GetThumbnailManager()->GetRenderingInfo( Asset );
|
|
return !RenderInfo || !RenderInfo->Renderer;
|
|
}
|
|
|
|
if ( AssetData.AssetClass == UBlueprint::StaticClass()->GetFName() )
|
|
{
|
|
// Unloaded blueprint asset
|
|
// It would be more correct here to find the rendering info for the generated class,
|
|
// but instead we are simply seeing if there is a thumbnail saved on disk for this asset
|
|
FString PackageFilename;
|
|
if ( FPackageName::DoesPackageExist(AssetData.PackageName.ToString(), nullptr, &PackageFilename) )
|
|
{
|
|
TSet<FName> ObjectFullNames;
|
|
FThumbnailMap ThumbnailMap;
|
|
|
|
FName ObjectFullName = FName(*AssetData.GetFullName());
|
|
ObjectFullNames.Add(ObjectFullName);
|
|
|
|
ThumbnailTools::LoadThumbnailsFromPackage(PackageFilename, ObjectFullNames, ThumbnailMap);
|
|
|
|
FObjectThumbnail* ThumbnailPtr = ThumbnailMap.Find(ObjectFullName);
|
|
if (ThumbnailPtr)
|
|
{
|
|
return (*ThumbnailPtr).IsEmpty();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Unloaded non-blueprint asset. See if the class has a rendering info.
|
|
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *AssetData.AssetClass.ToString());
|
|
|
|
UObject* ClassCDO = nullptr;
|
|
if (Class != nullptr)
|
|
{
|
|
ClassCDO = Class->GetDefaultObject();
|
|
}
|
|
|
|
// Get the rendering info for this object
|
|
FThumbnailRenderingInfo* RenderInfo = nullptr;
|
|
if (ClassCDO != nullptr)
|
|
{
|
|
RenderInfo = GUnrealEd->GetThumbnailManager()->GetRenderingInfo( ClassCDO );
|
|
}
|
|
|
|
return !RenderInfo || !RenderInfo->Renderer;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void UAssetToolsImpl::DiffAgainstDepot( UObject* InObject, const FString& InPackagePath, const FString& InPackageName ) const
|
|
{
|
|
check( InObject );
|
|
|
|
// Make sure our history is up to date
|
|
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
|
|
TSharedRef<FUpdateStatus, ESPMode::ThreadSafe> UpdateStatusOperation = ISourceControlOperation::Create<FUpdateStatus>();
|
|
UpdateStatusOperation->SetUpdateHistory(true);
|
|
SourceControlProvider.Execute(UpdateStatusOperation, SourceControlHelpers::PackageFilename(InPackagePath));
|
|
|
|
// Get the SCC state
|
|
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(SourceControlHelpers::PackageFilename(InPackagePath), EStateCacheUsage::Use);
|
|
|
|
// If we have an asset and its in SCC..
|
|
if( SourceControlState.IsValid() && InObject != nullptr && SourceControlState->IsSourceControlled() )
|
|
{
|
|
// Get the file name of package
|
|
FString RelativeFileName;
|
|
if(FPackageName::DoesPackageExist(InPackagePath, nullptr, &RelativeFileName))
|
|
{
|
|
if(SourceControlState->GetHistorySize() > 0)
|
|
{
|
|
TSharedPtr<ISourceControlRevision, ESPMode::ThreadSafe> Revision = SourceControlState->GetHistoryItem(0);
|
|
check(Revision.IsValid());
|
|
|
|
// Get the head revision of this package from source control
|
|
FString AbsoluteFileName = FPaths::ConvertRelativePathToFull(RelativeFileName);
|
|
FString TempFileName;
|
|
if(Revision->Get(TempFileName))
|
|
{
|
|
// Try and load that package
|
|
UPackage* TempPackage = LoadPackage(nullptr, *TempFileName, LOAD_ForDiff|LOAD_DisableCompileOnLoad);
|
|
if(TempPackage != nullptr)
|
|
{
|
|
// Grab the old asset from that old package
|
|
UObject* OldObject = FindObject<UObject>(TempPackage, *InPackageName);
|
|
if(OldObject != nullptr)
|
|
{
|
|
/* Set the revision information*/
|
|
FRevisionInfo OldRevision;
|
|
OldRevision.Changelist = Revision->GetCheckInIdentifier();
|
|
OldRevision.Date = Revision->GetDate();
|
|
OldRevision.Revision = Revision->GetRevision();
|
|
|
|
FRevisionInfo NewRevision;
|
|
NewRevision.Revision = TEXT("");
|
|
DiffAssets(OldObject, InObject, OldRevision, NewRevision);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::DiffAssets(UObject* OldAsset, UObject* NewAsset, const struct FRevisionInfo& OldRevision, const struct FRevisionInfo& NewRevision) const
|
|
{
|
|
if(OldAsset == nullptr || NewAsset == nullptr)
|
|
{
|
|
UE_LOG(LogAssetTools, Warning, TEXT("DiffAssets: One of the supplied assets was nullptr."));
|
|
return;
|
|
}
|
|
|
|
// Get class of both assets
|
|
UClass* OldClass = OldAsset->GetClass();
|
|
UClass* NewClass = NewAsset->GetClass();
|
|
// If same class..
|
|
if(OldClass == NewClass)
|
|
{
|
|
// Get class-specific actions
|
|
TWeakPtr<IAssetTypeActions> Actions = GetAssetTypeActionsForClass( NewClass );
|
|
if(Actions.IsValid())
|
|
{
|
|
// And use that to perform the Diff
|
|
Actions.Pin()->PerformAssetDiff(OldAsset, NewAsset, OldRevision, NewRevision);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogAssetTools, Warning, TEXT("DiffAssets: Classes were not the same."));
|
|
}
|
|
}
|
|
|
|
FString UAssetToolsImpl::DumpAssetToTempFile(UObject* Asset) const
|
|
{
|
|
check(Asset);
|
|
|
|
// Clear the mark state for saving.
|
|
UnMarkAllObjects(EObjectMark(OBJECTMARK_TagExp | OBJECTMARK_TagImp));
|
|
|
|
FStringOutputDevice Archive;
|
|
const FExportObjectInnerContext Context;
|
|
|
|
// Export asset to archive
|
|
UExporter::ExportToOutputDevice(&Context, Asset, nullptr, Archive, TEXT("copy"), 0, PPF_ExportsNotFullyQualified|PPF_Copy|PPF_Delimited, false, Asset->GetOuter());
|
|
|
|
// Used to generate unique file names during a run
|
|
static int TempFileNum = 0;
|
|
|
|
// Build name for temp text file
|
|
FString RelTempFileName = FString::Printf(TEXT("%sText%s-%d.txt"), *FPaths::DiffDir(), *Asset->GetName(), TempFileNum++);
|
|
FString AbsoluteTempFileName = FPaths::ConvertRelativePathToFull(RelTempFileName);
|
|
|
|
// Save text into temp file
|
|
if( !FFileHelper::SaveStringToFile( Archive, *AbsoluteTempFileName ) )
|
|
{
|
|
//UE_LOG(LogAssetTools, Warning, TEXT("DiffAssets: Could not write %s"), *AbsoluteTempFileName);
|
|
return TEXT("");
|
|
}
|
|
else
|
|
{
|
|
return AbsoluteTempFileName;
|
|
}
|
|
}
|
|
|
|
FString WrapArgument(const FString& Argument)
|
|
{
|
|
// Wrap the passed in argument so it changes from Argument to "Argument"
|
|
return FString::Printf(TEXT("%s%s%s"), (Argument.StartsWith("\"")) ? TEXT(""): TEXT("\""),
|
|
*Argument,
|
|
(Argument.EndsWith("\"")) ? TEXT(""): TEXT("\""));
|
|
}
|
|
|
|
bool UAssetToolsImpl::CreateDiffProcess(const FString& DiffCommand, const FString& OldTextFilename, const FString& NewTextFilename, const FString& DiffArgs) const
|
|
{
|
|
// Construct Arguments
|
|
FString Arguments = FString::Printf( TEXT("%s %s %s"),*WrapArgument(OldTextFilename), *WrapArgument(NewTextFilename), *DiffArgs );
|
|
|
|
bool bTryRunDiff = true;
|
|
FString NewDiffCommand = DiffCommand;
|
|
|
|
while (bTryRunDiff)
|
|
{
|
|
// Fire process
|
|
if (FPlatformProcess::CreateProc(*NewDiffCommand, *Arguments, true, false, false, nullptr, 0, nullptr, nullptr).IsValid())
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
const FText Message = FText::Format(NSLOCTEXT("AssetTools", "DiffFail", "The currently set diff tool '{0}' could not be run. Would you like to set a new diff tool?"), FText::FromString(DiffCommand));
|
|
EAppReturnType::Type Response = FMessageDialog::Open(EAppMsgType::YesNo, Message);
|
|
if (Response == EAppReturnType::No)
|
|
{
|
|
bTryRunDiff = false;
|
|
}
|
|
else
|
|
{
|
|
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
|
|
check(DesktopPlatform);
|
|
|
|
const FText FileFilterType = NSLOCTEXT("AssetTools", "Executables", "Executables");
|
|
#if PLATFORM_WINDOWS
|
|
const FString FileFilterText = FString::Printf(TEXT("%s (*.exe)|*.exe"), *FileFilterType.ToString());
|
|
#elif PLATFORM_MAC
|
|
const FString FileFilterText = FString::Printf(TEXT("%s (*.app)|*.app"), *FileFilterType.ToString());
|
|
#else
|
|
const FString FileFilterText = FString::Printf(TEXT("%s"), *FileFilterType.ToString());
|
|
#endif
|
|
|
|
TArray<FString> OutFiles;
|
|
if (DesktopPlatform->OpenFileDialog(
|
|
nullptr,
|
|
NSLOCTEXT("AssetTools", "ChooseDiffTool", "Choose Diff Tool").ToString(),
|
|
TEXT(""),
|
|
TEXT(""),
|
|
FileFilterText,
|
|
EFileDialogFlags::None,
|
|
OutFiles))
|
|
{
|
|
UEditorLoadingSavingSettings& Settings = *GetMutableDefault<UEditorLoadingSavingSettings>();
|
|
Settings.TextDiffToolPath.FilePath = OutFiles[0];
|
|
Settings.SaveConfig();
|
|
NewDiffCommand = OutFiles[0];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void UAssetToolsImpl::MigratePackages(const TArray<FName>& PackageNamesToMigrate) const
|
|
{
|
|
// Packages must be saved for the migration to work
|
|
const bool bPromptUserToSave = true;
|
|
const bool bSaveMapPackages = true;
|
|
const bool bSaveContentPackages = true;
|
|
if ( FEditorFileUtils::SaveDirtyPackages( bPromptUserToSave, bSaveMapPackages, bSaveContentPackages ) )
|
|
{
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
if ( AssetRegistryModule.Get().IsLoadingAssets() )
|
|
{
|
|
// Open a dialog asking the user to wait while assets are being discovered
|
|
SDiscoveringAssetsDialog::OpenDiscoveringAssetsDialog(
|
|
SDiscoveringAssetsDialog::FOnAssetsDiscovered::CreateUObject(this, &UAssetToolsImpl::PerformMigratePackages, PackageNamesToMigrate)
|
|
);
|
|
}
|
|
else
|
|
{
|
|
// Assets are already discovered, perform the migration now
|
|
PerformMigratePackages(PackageNamesToMigrate);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::OnNewImportRecord(UClass* AssetType, const FString& FileExtension, bool bSucceeded, bool bWasCancelled, const FDateTime& StartTime)
|
|
{
|
|
// Don't attempt to report usage stats if analytics isn't available
|
|
if(AssetType != nullptr && FEngineAnalytics::IsAvailable())
|
|
{
|
|
TArray<FAnalyticsEventAttribute> Attribs;
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("AssetType"), AssetType->GetName()));
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("FileExtension"), FileExtension));
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("Outcome"), bSucceeded ? TEXT("Success") : (bWasCancelled ? TEXT("Cancelled") : TEXT("Failed"))));
|
|
FTimespan TimeTaken = FDateTime::UtcNow() - StartTime;
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("TimeTaken.Seconds"), (float)TimeTaken.GetTotalSeconds()));
|
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.ImportAsset"), Attribs);
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::OnNewCreateRecord(UClass* AssetType, bool bDuplicated)
|
|
{
|
|
// Don't attempt to report usage stats if analytics isn't available
|
|
if(AssetType != nullptr && FEngineAnalytics::IsAvailable())
|
|
{
|
|
TArray<FAnalyticsEventAttribute> Attribs;
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("AssetType"), AssetType->GetName()));
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("Duplicated"), bDuplicated? TEXT("Yes") : TEXT("No")));
|
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.CreateAsset"), Attribs);
|
|
}
|
|
}
|
|
|
|
TArray<UObject*> UAssetToolsImpl::ImportAssetsInternal(const TArray<FString>& Files, const FString& RootDestinationPath, TArray<TPair<FString, FString>> *FilesAndDestinationsPtr, const FAssetImportParams& Params) const
|
|
{
|
|
UFactory* SpecifiedFactory = Params.SpecifiedFactory;
|
|
const bool bForceOverrideExisting = Params.bForceOverrideExisting;
|
|
const bool bSyncToBrowser = Params.bSyncToBrowser;
|
|
const bool bAutomatedImport = Params.bAutomated || GIsAutomationTesting;
|
|
|
|
TArray<UObject*> ReturnObjects;
|
|
TMap< FString, TArray<UFactory*> > ExtensionToFactoriesMap;
|
|
|
|
FScopedSlowTask SlowTask(Files.Num(), LOCTEXT("ImportSlowTask", "Importing"));
|
|
SlowTask.MakeDialog();
|
|
|
|
|
|
TArray<TPair<FString, FString>> FilesAndDestinations;
|
|
if (FilesAndDestinationsPtr == nullptr)
|
|
{
|
|
ExpandDirectories(Files, RootDestinationPath, FilesAndDestinations);
|
|
}
|
|
else
|
|
{
|
|
FilesAndDestinations = (*FilesAndDestinationsPtr);
|
|
}
|
|
|
|
if(SpecifiedFactory == nullptr)
|
|
{
|
|
// First instantiate one factory for each file extension encountered that supports the extension
|
|
// @todo import: gmp: show dialog in case of multiple matching factories
|
|
for(TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
|
|
{
|
|
if(!(*ClassIt)->IsChildOf(UFactory::StaticClass()) || ((*ClassIt)->HasAnyClassFlags(CLASS_Abstract)) || (*ClassIt)->IsChildOf(USceneImportFactory::StaticClass()))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
UFactory* Factory = Cast<UFactory>((*ClassIt)->GetDefaultObject());
|
|
|
|
if(!Factory->bEditorImport)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TArray<FString> FactoryExtensions;
|
|
Factory->GetSupportedFileExtensions(FactoryExtensions);
|
|
|
|
for(auto& FileDest : FilesAndDestinations)
|
|
{
|
|
const FString FileExtension = FPaths::GetExtension(FileDest.Key);
|
|
|
|
// Case insensitive string compare with supported formats of this factory
|
|
if(FactoryExtensions.Contains(FileExtension))
|
|
{
|
|
TArray<UFactory*>& ExistingFactories = ExtensionToFactoriesMap.FindOrAdd(FileExtension);
|
|
|
|
// Do not remap extensions, just reuse the existing UFactory.
|
|
// There may be multiple UFactories, so we will keep track of all of them
|
|
bool bFactoryAlreadyInMap = false;
|
|
for(auto FoundFactoryIt = ExistingFactories.CreateConstIterator(); FoundFactoryIt; ++FoundFactoryIt)
|
|
{
|
|
if((*FoundFactoryIt)->GetClass() == Factory->GetClass())
|
|
{
|
|
bFactoryAlreadyInMap = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!bFactoryAlreadyInMap)
|
|
{
|
|
// We found a factory for this file, it can be imported!
|
|
// Create a new factory of the same class and make sure it doesn't get GCed.
|
|
// The object will be removed from the root set at the end of this function.
|
|
UFactory* NewFactory = NewObject<UFactory>(GetTransientPackage(), Factory->GetClass());
|
|
if(NewFactory->ConfigureProperties())
|
|
{
|
|
NewFactory->AddToRoot();
|
|
ExistingFactories.Add(NewFactory);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if(SpecifiedFactory->bEditorImport && !bAutomatedImport)
|
|
{
|
|
|
|
TArray<FString> FactoryExtensions;
|
|
SpecifiedFactory->GetSupportedFileExtensions(FactoryExtensions);
|
|
|
|
for(auto FileIt = Files.CreateConstIterator(); FileIt; ++FileIt)
|
|
{
|
|
const FString FileExtension = FPaths::GetExtension(*FileIt);
|
|
|
|
// Case insensitive string compare with supported formats of this factory
|
|
if(!FactoryExtensions.Contains(FileExtension))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
TArray<UFactory*>& ExistingFactories = ExtensionToFactoriesMap.FindOrAdd(FileExtension);
|
|
|
|
// Do not remap extensions, just reuse the existing UFactory.
|
|
// There may be multiple UFactories, so we will keep track of all of them
|
|
bool bFactoryAlreadyInMap = false;
|
|
for(auto FoundFactoryIt = ExistingFactories.CreateConstIterator(); FoundFactoryIt; ++FoundFactoryIt)
|
|
{
|
|
if((*FoundFactoryIt)->GetClass() == SpecifiedFactory->GetClass())
|
|
{
|
|
bFactoryAlreadyInMap = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(!bFactoryAlreadyInMap)
|
|
{
|
|
// We found a factory for this file, it can be imported!
|
|
// Create a new factory of the same class and make sure it doesnt get GCed.
|
|
// The object will be removed from the root set at the end of this function.
|
|
UFactory* NewFactory = NewObject<UFactory>(GetTransientPackage(), SpecifiedFactory->GetClass());
|
|
if(NewFactory->ConfigureProperties())
|
|
{
|
|
NewFactory->AddToRoot();
|
|
ExistingFactories.Add(NewFactory);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// We need to sort the factories so that they get tested in priority order
|
|
for(auto& ExtensionToFactories : ExtensionToFactoriesMap)
|
|
{
|
|
ExtensionToFactories.Value.Sort(&UFactory::SortFactoriesByPriority);
|
|
}
|
|
|
|
// Some flags to keep track of what the user decided when asked about overwriting or replacing
|
|
bool bOverwriteAll = false;
|
|
bool bReplaceAll = false;
|
|
bool bDontOverwriteAny = false;
|
|
bool bDontReplaceAny = false;
|
|
if (Params.AssetImportTask && Params.AssetImportTask->bAutomated)
|
|
{
|
|
bOverwriteAll = bReplaceAll = Params.AssetImportTask->bReplaceExisting;
|
|
bDontOverwriteAny = bDontReplaceAny = !Params.AssetImportTask->bReplaceExisting;
|
|
}
|
|
|
|
TArray<UFactory*> UsedFactories;
|
|
|
|
// Now iterate over the input files and use the same factory object for each file with the same extension
|
|
for(int32 FileIdx = 0; FileIdx < FilesAndDestinations.Num(); ++FileIdx)
|
|
{
|
|
// Filename and DestinationPath will need to get santized before we create an asset out of them as they
|
|
// can be created out of sources that contain spaces and other invalid characters. Filename cannot be sanitized
|
|
// until other checks are done that rely on looking at the actual source file so sanitation is delayed.
|
|
const FString& Filename = FilesAndDestinations[FileIdx].Key;
|
|
const FString DestinationPath = ObjectTools::SanitizeObjectPath(FilesAndDestinations[FileIdx].Value);
|
|
|
|
|
|
SlowTask.EnterProgressFrame(1, FText::Format(LOCTEXT("Import_ImportingFile", "Importing \"{0}\"..."), FText::FromString(FPaths::GetBaseFilename(Filename))));
|
|
|
|
FString FileExtension = FPaths::GetExtension(Filename);
|
|
|
|
const TArray<UFactory*>* FactoriesPtr = ExtensionToFactoriesMap.Find(FileExtension);
|
|
UFactory* Factory = nullptr;
|
|
// Assume that for automated import, the user knows exactly what factory to use if it exists
|
|
if(bAutomatedImport && SpecifiedFactory && SpecifiedFactory->FactoryCanImport(Filename))
|
|
{
|
|
Factory = SpecifiedFactory;
|
|
}
|
|
else if(FactoriesPtr)
|
|
{
|
|
const TArray<UFactory*>& Factories = *FactoriesPtr;
|
|
|
|
// Handle the potential of multiple factories being found
|
|
if(Factories.Num() > 0)
|
|
{
|
|
Factory = Factories[0];
|
|
|
|
for(auto FactoryIt = Factories.CreateConstIterator(); FactoryIt; ++FactoryIt)
|
|
{
|
|
UFactory* TestFactory = *FactoryIt;
|
|
if(TestFactory->FactoryCanImport(Filename))
|
|
{
|
|
Factory = TestFactory;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(FEngineAnalytics::IsAvailable())
|
|
{
|
|
TArray<FAnalyticsEventAttribute> Attribs;
|
|
Attribs.Add(FAnalyticsEventAttribute(TEXT("FileExtension"), FileExtension));
|
|
|
|
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.ImportFailed"), Attribs);
|
|
}
|
|
|
|
const FText Message = FText::Format(LOCTEXT("ImportFailed_UnknownExtension", "Failed to import '{0}'. Unknown extension '{1}'."), FText::FromString(Filename), FText::FromString(FileExtension));
|
|
FNotificationInfo Info(Message);
|
|
Info.ExpireDuration = 3.0f;
|
|
Info.bUseLargeFont = false;
|
|
Info.bFireAndForget = true;
|
|
Info.bUseSuccessFailIcons = true;
|
|
FSlateNotificationManager::Get().AddNotification(Info)->SetCompletionState(SNotificationItem::CS_Fail);
|
|
|
|
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
|
|
}
|
|
|
|
if(Factory != nullptr)
|
|
{
|
|
// Reset the 'Do you want to overwrite the existing object?' Yes to All / No to All prompt, to make sure the
|
|
// user gets a chance to select something when the factory is first used during this import
|
|
if (!UsedFactories.Contains(Factory))
|
|
{
|
|
Factory->ResetState();
|
|
UsedFactories.AddUnique(Factory);
|
|
}
|
|
|
|
UClass* ImportAssetType = Factory->SupportedClass;
|
|
bool bImportSucceeded = false;
|
|
bool bImportWasCancelled = false;
|
|
FDateTime ImportStartTime = FDateTime::UtcNow();
|
|
|
|
FString Name;
|
|
if (Params.AssetImportTask && !Params.AssetImportTask->DestinationName.IsEmpty())
|
|
{
|
|
Name = Params.AssetImportTask->DestinationName;
|
|
}
|
|
else
|
|
{
|
|
Name = FPaths::GetBaseFilename(Filename);
|
|
}
|
|
Name = ObjectTools::SanitizeObjectName(Name);
|
|
|
|
FString PackageName = ObjectTools::SanitizeInvalidChars(FPaths::Combine(*DestinationPath, *Name), INVALID_LONGPACKAGE_CHARACTERS);
|
|
|
|
// We can not create assets that share the name of a map file in the same location
|
|
if(FEditorFileUtils::IsMapPackageAsset(PackageName))
|
|
{
|
|
const FText Message = FText::Format(LOCTEXT("AssetNameInUseByMap", "You can not create an asset named '{0}' because there is already a map file with this name in this folder."), FText::FromString(Name));
|
|
if(!bAutomatedImport)
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, Message);
|
|
}
|
|
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
|
|
UPackage* Pkg = CreatePackage(nullptr, *PackageName);
|
|
if(!ensure(Pkg))
|
|
{
|
|
// Failed to create the package to hold this asset for some reason
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
|
|
// Make sure the destination package is loaded
|
|
Pkg->FullyLoad();
|
|
|
|
// Check for an existing object
|
|
UObject* ExistingObject = StaticFindObject(UObject::StaticClass(), Pkg, *Name);
|
|
if(ExistingObject != nullptr)
|
|
{
|
|
// If the existing object is one of the imports we've just created we can't replace or overwrite it
|
|
if(ReturnObjects.Contains(ExistingObject))
|
|
{
|
|
if(ImportAssetType == nullptr)
|
|
{
|
|
// The factory probably supports multiple types and cant be determined yet without asking the user or actually loading it
|
|
// We just need to generate an unused name so object should do fine.
|
|
ImportAssetType = UObject::StaticClass();
|
|
}
|
|
// generate a unique name for this import
|
|
Name = MakeUniqueObjectName(Pkg, ImportAssetType, *Name).ToString();
|
|
}
|
|
else
|
|
{
|
|
// If the object is supported by the factory we are using, ask if we want to overwrite the asset
|
|
// Otherwise, prompt to replace the object
|
|
if(Factory->DoesSupportClass(ExistingObject->GetClass()))
|
|
{
|
|
// The factory can overwrite this object, ask if that is okay, unless "Yes To All" or "No To All" was already selected
|
|
EAppReturnType::Type UserResponse;
|
|
|
|
if(bForceOverrideExisting || bOverwriteAll || GIsAutomationTesting)
|
|
{
|
|
UserResponse = EAppReturnType::YesAll;
|
|
}
|
|
else if(bDontOverwriteAny)
|
|
{
|
|
UserResponse = EAppReturnType::NoAll;
|
|
}
|
|
else
|
|
{
|
|
UserResponse = FMessageDialog::Open(
|
|
EAppMsgType::YesNoYesAllNoAll,
|
|
FText::Format(LOCTEXT("ImportObjectAlreadyExists_SameClass", "Do you want to overwrite the existing asset?\n\nAn asset already exists at the import location: {0}"), FText::FromString(PackageName)));
|
|
|
|
bOverwriteAll = UserResponse == EAppReturnType::YesAll;
|
|
bDontOverwriteAny = UserResponse == EAppReturnType::NoAll;
|
|
}
|
|
|
|
const bool bWantOverwrite = UserResponse == EAppReturnType::Yes || UserResponse == EAppReturnType::YesAll;
|
|
|
|
if(!bWantOverwrite)
|
|
{
|
|
// User chose not to replace the package
|
|
bImportWasCancelled = true;
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
}
|
|
else if(!bAutomatedImport)
|
|
{
|
|
// The factory can't overwrite this asset, ask if we should delete the object then import the new one. Only do this if "Yes To All" or "No To All" was not already selected.
|
|
EAppReturnType::Type UserResponse;
|
|
|
|
if(bReplaceAll)
|
|
{
|
|
UserResponse = EAppReturnType::YesAll;
|
|
}
|
|
else if(bDontReplaceAny)
|
|
{
|
|
UserResponse = EAppReturnType::NoAll;
|
|
}
|
|
else
|
|
{
|
|
UserResponse = FMessageDialog::Open(
|
|
EAppMsgType::YesNoYesAllNoAll,
|
|
FText::Format(LOCTEXT("ImportObjectAlreadyExists_DifferentClass", "Do you want to replace the existing asset?\n\nAn asset already exists at the import location: {0}"), FText::FromString(PackageName)));
|
|
|
|
bReplaceAll = UserResponse == EAppReturnType::YesAll;
|
|
bDontReplaceAny = UserResponse == EAppReturnType::NoAll;
|
|
}
|
|
|
|
const bool bWantReplace = UserResponse == EAppReturnType::Yes || UserResponse == EAppReturnType::YesAll;
|
|
|
|
if(bWantReplace)
|
|
{
|
|
// Delete the existing object
|
|
int32 NumObjectsDeleted = 0;
|
|
TArray< UObject* > ObjectsToDelete;
|
|
ObjectsToDelete.Add(ExistingObject);
|
|
|
|
// If the user forcefully deletes the package, all sorts of things could become invalidated,
|
|
// the Pkg pointer might be killed even though it was added to the root.
|
|
TWeakObjectPtr<UPackage> WeakPkg(Pkg);
|
|
|
|
// Dont let the package get garbage collected (just in case we are deleting the last asset in the package)
|
|
Pkg->AddToRoot();
|
|
NumObjectsDeleted = ObjectTools::DeleteObjects(ObjectsToDelete, /*bShowConfirmation=*/false);
|
|
|
|
// If the weak package ptr is still valid, it should then be safe to remove it from the root.
|
|
if(WeakPkg.IsValid())
|
|
{
|
|
Pkg->RemoveFromRoot();
|
|
}
|
|
|
|
const FString QualifiedName = PackageName + TEXT(".") + Name;
|
|
FText Reason;
|
|
if(NumObjectsDeleted == 0 || !IsUniqueObjectName(*QualifiedName, ANY_PACKAGE, Reason))
|
|
{
|
|
// Original object couldn't be deleted
|
|
const FText Message = FText::Format(LOCTEXT("ImportDeleteFailed", "Failed to delete '{0}'. The asset is referenced by other content."), FText::FromString(PackageName));
|
|
FMessageDialog::Open(EAppMsgType::Ok, Message);
|
|
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
// succeed, recreate package since it has been deleted
|
|
Pkg = CreatePackage(nullptr, *PackageName);
|
|
Pkg->MarkAsFullyLoaded();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// User chose not to replace the package
|
|
bImportWasCancelled = true;
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Check for a package that was marked for delete in source control
|
|
if(!CheckForDeletedPackage(Pkg))
|
|
{
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
continue;
|
|
}
|
|
|
|
Factory->SetAutomatedAssetImportData(Params.ImportData);
|
|
Factory->SetAssetImportTask(Params.AssetImportTask);
|
|
|
|
ImportAssetType = Factory->ResolveSupportedClass();
|
|
UObject* Result = Factory->ImportObject(ImportAssetType, Pkg, FName(*Name), RF_Public | RF_Standalone | RF_Transactional, Filename, nullptr, bImportWasCancelled);
|
|
|
|
Factory->SetAutomatedAssetImportData(nullptr);
|
|
Factory->SetAssetImportTask(nullptr);
|
|
|
|
// Do not report any error if the operation was canceled.
|
|
if(!bImportWasCancelled)
|
|
{
|
|
if(Result)
|
|
{
|
|
ReturnObjects.Add(Result);
|
|
|
|
// Notify the asset registry
|
|
FAssetRegistryModule::AssetCreated(Result);
|
|
GEditor->BroadcastObjectReimported(Result);
|
|
|
|
bImportSucceeded = true;
|
|
}
|
|
else
|
|
{
|
|
const FText Message = FText::Format(LOCTEXT("ImportFailed_Generic", "Failed to import '{0}'. Failed to create asset '{1}'.\nPlease see Output Log for details."), FText::FromString(Filename), FText::FromString(PackageName));
|
|
if(!bAutomatedImport)
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, Message);
|
|
}
|
|
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
|
|
}
|
|
}
|
|
|
|
// Refresh the supported class. Some factories (e.g. FBX) only resolve their type after reading the file
|
|
ImportAssetType = Factory->ResolveSupportedClass();
|
|
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
|
|
}
|
|
else
|
|
{
|
|
// A factory or extension was not found. The extension warning is above. If a factory was not found, the user likely canceled a factory configuration dialog.
|
|
}
|
|
}
|
|
|
|
// Clean up and remove the factories we created from the root set
|
|
for(auto ExtensionIt = ExtensionToFactoriesMap.CreateConstIterator(); ExtensionIt; ++ExtensionIt)
|
|
{
|
|
for(auto FactoryIt = ExtensionIt.Value().CreateConstIterator(); FactoryIt; ++FactoryIt)
|
|
{
|
|
(*FactoryIt)->CleanUp();
|
|
(*FactoryIt)->RemoveFromRoot();
|
|
}
|
|
}
|
|
|
|
// Sync content browser to the newly created assets
|
|
if(ReturnObjects.Num() && (bSyncToBrowser != false))
|
|
{
|
|
UAssetToolsImpl::Get().SyncBrowserToAssets(ReturnObjects);
|
|
}
|
|
|
|
return ReturnObjects;
|
|
}
|
|
|
|
void UAssetToolsImpl::ExportAssetsInternal(const TArray<UObject*>& ObjectsToExport, bool bPromptIndividualFilenames, const FString& ExportPath) const
|
|
{
|
|
FString LastExportPath = !ExportPath.IsEmpty() ? ExportPath : FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_EXPORT);
|
|
|
|
if (ObjectsToExport.Num() == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
FString SelectedExportPath;
|
|
if (!bPromptIndividualFilenames)
|
|
{
|
|
if (ExportPath.IsEmpty())
|
|
{
|
|
// If not prompting individual files, prompt the user to select a target directory.
|
|
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
|
|
if (DesktopPlatform)
|
|
{
|
|
FString FolderName;
|
|
const FString Title = NSLOCTEXT("UnrealEd", "ChooseADirectory", "Choose A Directory").ToString();
|
|
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
|
|
FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr),
|
|
Title,
|
|
LastExportPath,
|
|
FolderName
|
|
);
|
|
|
|
if (bFolderSelected)
|
|
{
|
|
SelectedExportPath = FolderName;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SelectedExportPath = ExportPath;
|
|
}
|
|
|
|
// Copy off the selected path for future export operations.
|
|
LastExportPath = SelectedExportPath;
|
|
}
|
|
|
|
GWarn->BeginSlowTask(NSLOCTEXT("UnrealEd", "Exporting", "Exporting"), true);
|
|
|
|
// Create an array of all available exporters.
|
|
TArray<UExporter*> Exporters;
|
|
ObjectTools::AssembleListOfExporters(Exporters);
|
|
|
|
//Array to control the batch mode and the show options for the exporters that will be use by the selected assets
|
|
TArray<UExporter*> UsedExporters;
|
|
|
|
// Export the objects.
|
|
bool bAnyObjectMissingSourceData = false;
|
|
for (int32 Index = 0; Index < ObjectsToExport.Num(); Index++)
|
|
{
|
|
GWarn->StatusUpdate(Index, ObjectsToExport.Num(), FText::Format(NSLOCTEXT("UnrealEd", "Exportingf", "Exporting ({0} of {1})"), FText::AsNumber(Index), FText::AsNumber(ObjectsToExport.Num())));
|
|
|
|
UObject* ObjectToExport = ObjectsToExport[Index];
|
|
if (!ObjectToExport)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (ObjectToExport->GetOutermost()->HasAnyPackageFlags(PKG_DisallowExport))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Find all the exporters that can export this type of object and construct an export file dialog.
|
|
TArray<FString> AllFileTypes;
|
|
TArray<FString> AllExtensions;
|
|
TArray<FString> PreferredExtensions;
|
|
|
|
// Iterate in reverse so the most relevant file formats are considered first.
|
|
for (int32 ExporterIndex = Exporters.Num() - 1; ExporterIndex >= 0; --ExporterIndex)
|
|
{
|
|
UExporter* Exporter = Exporters[ExporterIndex];
|
|
if (Exporter->SupportedClass)
|
|
{
|
|
const bool bObjectIsSupported = Exporter->SupportsObject(ObjectToExport);
|
|
if (bObjectIsSupported)
|
|
{
|
|
// Get a string representing of the exportable types.
|
|
check(Exporter->FormatExtension.Num() == Exporter->FormatDescription.Num());
|
|
check(Exporter->FormatExtension.IsValidIndex(Exporter->PreferredFormatIndex));
|
|
for (int32 FormatIndex = Exporter->FormatExtension.Num() - 1; FormatIndex >= 0; --FormatIndex)
|
|
{
|
|
const FString& FormatExtension = Exporter->FormatExtension[FormatIndex];
|
|
const FString& FormatDescription = Exporter->FormatDescription[FormatIndex];
|
|
|
|
if (FormatIndex == Exporter->PreferredFormatIndex)
|
|
{
|
|
PreferredExtensions.Add(FormatExtension);
|
|
}
|
|
AllFileTypes.Add(FString::Printf(TEXT("%s (*.%s)|*.%s"), *FormatDescription, *FormatExtension, *FormatExtension));
|
|
AllExtensions.Add(FString::Printf(TEXT("*.%s"), *FormatExtension));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Skip this object if no exporter found for this resource type.
|
|
if (PreferredExtensions.Num() == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// If FBX is listed, make that the most preferred option
|
|
const FString PreferredExtension = TEXT("FBX");
|
|
int32 ExtIndex = PreferredExtensions.Find(PreferredExtension);
|
|
if (ExtIndex > 0)
|
|
{
|
|
PreferredExtensions.RemoveAt(ExtIndex);
|
|
PreferredExtensions.Insert(PreferredExtension, 0);
|
|
}
|
|
FString FirstExtension = PreferredExtensions[0];
|
|
|
|
// If FBX is listed, make that the first option here too, then compile them all into one string
|
|
check(AllFileTypes.Num() == AllExtensions.Num())
|
|
for (ExtIndex = 1; ExtIndex < AllFileTypes.Num(); ++ExtIndex)
|
|
{
|
|
const FString FileType = AllFileTypes[ExtIndex];
|
|
if (FileType.Contains(PreferredExtension))
|
|
{
|
|
AllFileTypes.RemoveAt(ExtIndex);
|
|
AllFileTypes.Insert(FileType, 0);
|
|
|
|
const FString Extension = AllExtensions[ExtIndex];
|
|
AllExtensions.RemoveAt(ExtIndex);
|
|
AllExtensions.Insert(Extension, 0);
|
|
}
|
|
}
|
|
FString FileTypes;
|
|
FString Extensions;
|
|
for (ExtIndex = 0; ExtIndex < AllFileTypes.Num(); ++ExtIndex)
|
|
{
|
|
if (FileTypes.Len())
|
|
{
|
|
FileTypes += TEXT("|");
|
|
}
|
|
FileTypes += AllFileTypes[ExtIndex];
|
|
|
|
if (Extensions.Len())
|
|
{
|
|
Extensions += TEXT(";");
|
|
}
|
|
Extensions += AllExtensions[ExtIndex];
|
|
}
|
|
FileTypes = FString::Printf(TEXT("%s|All Files (%s)|%s"), *FileTypes, *Extensions, *Extensions);
|
|
|
|
FString SaveFileName;
|
|
if (bPromptIndividualFilenames)
|
|
{
|
|
TArray<FString> SaveFilenames;
|
|
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
|
|
bool bSave = false;
|
|
if (DesktopPlatform)
|
|
{
|
|
bSave = DesktopPlatform->SaveFileDialog(
|
|
FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr),
|
|
FText::Format(NSLOCTEXT("UnrealEd", "Save_F", "Save: {0}"), FText::FromString(ObjectToExport->GetName())).ToString(),
|
|
*LastExportPath,
|
|
*ObjectToExport->GetName(),
|
|
*FileTypes,
|
|
EFileDialogFlags::None,
|
|
SaveFilenames
|
|
);
|
|
}
|
|
|
|
if (!bSave)
|
|
{
|
|
int32 NumObjectsLeftToExport = ObjectsToExport.Num() - Index - 1;
|
|
if (NumObjectsLeftToExport > 0)
|
|
{
|
|
const FText ConfirmText = FText::Format(NSLOCTEXT("UnrealEd", "AssetTools_ExportObjects_CancelRemaining", "Would you like to cancel exporting the next {0} files as well?"), FText::AsNumber(NumObjectsLeftToExport));
|
|
if (EAppReturnType::Yes == FMessageDialog::Open(EAppMsgType::YesNo, ConfirmText))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
SaveFileName = FString(SaveFilenames[0]);
|
|
|
|
// Copy off the selected path for future export operations.
|
|
LastExportPath = SaveFileName;
|
|
}
|
|
else
|
|
{
|
|
// Assemble a filename from the export directory and the object path.
|
|
SaveFileName = SelectedExportPath;
|
|
|
|
if (!FPackageName::IsShortPackageName(ObjectToExport->GetOutermost()->GetFName()))
|
|
{
|
|
// Determine the save file name from the long package name
|
|
FString PackageName = ObjectToExport->GetOutermost()->GetName();
|
|
if (PackageName.Left(1) == TEXT("/"))
|
|
{
|
|
// Trim the leading slash so the file manager doesn't get confused
|
|
PackageName = PackageName.Mid(1);
|
|
}
|
|
|
|
FPaths::NormalizeFilename(PackageName);
|
|
SaveFileName /= PackageName;
|
|
}
|
|
else
|
|
{
|
|
// Assemble the path from the package name.
|
|
SaveFileName /= ObjectToExport->GetOutermost()->GetName();
|
|
SaveFileName /= ObjectToExport->GetName();
|
|
}
|
|
SaveFileName += FString::Printf(TEXT(".%s"), *FirstExtension);
|
|
UE_LOG(LogAssetTools, Log, TEXT("Exporting \"%s\" to \"%s\""), *ObjectToExport->GetPathName(), *SaveFileName);
|
|
}
|
|
|
|
// Create the path, then make sure the target file is not read-only.
|
|
const FString ObjectExportPath(FPaths::GetPath(SaveFileName));
|
|
const bool bFileInSubdirectory = ObjectExportPath.Contains(TEXT("/"));
|
|
if (bFileInSubdirectory && (!IFileManager::Get().MakeDirectory(*ObjectExportPath, true)))
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, FText::Format(NSLOCTEXT("UnrealEd", "Error_FailedToMakeDirectory", "Failed to make directory {0}"), FText::FromString(ObjectExportPath)));
|
|
}
|
|
else if (IFileManager::Get().IsReadOnly(*SaveFileName))
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, FText::Format(NSLOCTEXT("UnrealEd", "Error_CouldntWriteToFile_F", "Couldn't write to file '{0}'. Maybe file is read-only?"), FText::FromString(SaveFileName)));
|
|
}
|
|
else
|
|
{
|
|
// We have a writeable file. Now go through that list of exporters again and find the right exporter and use it.
|
|
TArray<UExporter*> ValidExporters;
|
|
|
|
for (int32 ExporterIndex = 0; ExporterIndex < Exporters.Num(); ++ExporterIndex)
|
|
{
|
|
UExporter* Exporter = Exporters[ExporterIndex];
|
|
if (Exporter->SupportsObject(ObjectToExport))
|
|
{
|
|
check(Exporter->FormatExtension.Num() == Exporter->FormatDescription.Num());
|
|
for (int32 FormatIndex = 0; FormatIndex < Exporter->FormatExtension.Num(); ++FormatIndex)
|
|
{
|
|
const FString& FormatExtension = Exporter->FormatExtension[FormatIndex];
|
|
if (FCString::Stricmp(*FormatExtension, *FPaths::GetExtension(SaveFileName)) == 0 ||
|
|
FCString::Stricmp(*FormatExtension, TEXT("*")) == 0)
|
|
{
|
|
ValidExporters.Add(Exporter);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Handle the potential of multiple exporters being found
|
|
UExporter* ExporterToUse = NULL;
|
|
if (ValidExporters.Num() == 1)
|
|
{
|
|
ExporterToUse = ValidExporters[0];
|
|
}
|
|
else if (ValidExporters.Num() > 1)
|
|
{
|
|
// Set up the first one as default
|
|
ExporterToUse = ValidExporters[0];
|
|
|
|
// ...but search for a better match if available
|
|
for (int32 ExporterIdx = 0; ExporterIdx < ValidExporters.Num(); ExporterIdx++)
|
|
{
|
|
if (ValidExporters[ExporterIdx]->GetClass()->GetFName() == ObjectToExport->GetExporterName())
|
|
{
|
|
ExporterToUse = ValidExporters[ExporterIdx];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// If an exporter was found, use it.
|
|
if (ExporterToUse)
|
|
{
|
|
const FScopedBusyCursor BusyCursor;
|
|
|
|
if (!UsedExporters.Contains(ExporterToUse))
|
|
{
|
|
ExporterToUse->SetBatchMode(ObjectsToExport.Num() > 1 && !bPromptIndividualFilenames);
|
|
ExporterToUse->SetCancelBatch(false);
|
|
ExporterToUse->SetShowExportOption(true);
|
|
ExporterToUse->AddToRoot();
|
|
UsedExporters.Add(ExporterToUse);
|
|
}
|
|
|
|
UAssetExportTask* ExportTask = NewObject<UAssetExportTask>();
|
|
FGCObjectScopeGuard ExportTaskGuard(ExportTask);
|
|
ExportTask->Object = ObjectToExport;
|
|
ExportTask->Exporter = ExporterToUse;
|
|
ExportTask->Filename = SaveFileName;
|
|
ExportTask->bSelected = false;
|
|
ExportTask->bReplaceIdentical = true;
|
|
ExportTask->bPrompt = false;
|
|
ExportTask->bUseFileArchive = ObjectToExport->IsA(UPackage::StaticClass());
|
|
ExportTask->bWriteEmptyFiles = false;
|
|
|
|
UExporter::RunAssetExportTask(ExportTask);
|
|
|
|
if (ExporterToUse->GetBatchMode() && ExporterToUse->GetCancelBatch())
|
|
{
|
|
//Exit the export file loop when there is a cancel all
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//Set back the default value for the all used exporters
|
|
for (UExporter* UsedExporter : UsedExporters)
|
|
{
|
|
UsedExporter->SetBatchMode(false);
|
|
UsedExporter->SetCancelBatch(false);
|
|
UsedExporter->SetShowExportOption(true);
|
|
UsedExporter->RemoveFromRoot();
|
|
}
|
|
UsedExporters.Empty();
|
|
|
|
if (bAnyObjectMissingSourceData)
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "Exporter_Error_SourceDataUnavailable", "No source data available for some objects. See the log for details."));
|
|
}
|
|
|
|
GWarn->EndSlowTask();
|
|
|
|
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_EXPORT, LastExportPath);
|
|
}
|
|
|
|
UAssetToolsImpl& UAssetToolsImpl::Get()
|
|
{
|
|
FAssetToolsModule& Module = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
|
|
return static_cast<UAssetToolsImpl&>(Module.Get());
|
|
}
|
|
|
|
void UAssetToolsImpl::SyncBrowserToAssets(const TArray<UObject*>& AssetsToSync)
|
|
{
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
|
|
}
|
|
|
|
void UAssetToolsImpl::SyncBrowserToAssets(const TArray<FAssetData>& AssetsToSync)
|
|
{
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
|
|
}
|
|
|
|
bool UAssetToolsImpl::CheckForDeletedPackage(const UPackage* Package) const
|
|
{
|
|
if ( ISourceControlModule::Get().IsEnabled() )
|
|
{
|
|
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
|
|
if ( SourceControlProvider.IsAvailable() )
|
|
{
|
|
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Package, EStateCacheUsage::ForceUpdate);
|
|
if ( SourceControlState.IsValid() && SourceControlState->IsDeleted() )
|
|
{
|
|
// Creating an asset in a package that is marked for delete - revert the delete and check out the package
|
|
if (!SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), Package))
|
|
{
|
|
// Failed to revert file which was marked for delete
|
|
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("RevertDeletedFileFailed", "Failed to revert package which was marked for delete."));
|
|
return false;
|
|
}
|
|
|
|
if (!SourceControlProvider.Execute(ISourceControlOperation::Create<FCheckOut>(), Package))
|
|
{
|
|
// Failed to check out file
|
|
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("CheckOutFileFailed", "Failed to check out package"));
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FMessageLog EditorErrors("EditorErrors");
|
|
EditorErrors.Warning(LOCTEXT( "DeletingNoSCCConnection", "Could not check for deleted file. No connection to source control available!"));
|
|
EditorErrors.Notify();
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool UAssetToolsImpl::CanCreateAsset(const FString& AssetName, const FString& PackageName, const FText& OperationText) const
|
|
{
|
|
// @todo: These 'reason' messages are not localized strings!
|
|
FText Reason;
|
|
if (!FName(*AssetName).IsValidObjectName( Reason )
|
|
|| !FPackageName::IsValidLongPackageName( PackageName, /*bIncludeReadOnlyRoots=*/false, &Reason ) )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, Reason );
|
|
return false;
|
|
}
|
|
|
|
// We can not create assets that share the name of a map file in the same location
|
|
if ( FEditorFileUtils::IsMapPackageAsset(PackageName) )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, FText::Format( LOCTEXT("AssetNameInUseByMap", "You can not create an asset named '{0}' because there is already a map file with this name in this folder."), FText::FromString( AssetName ) ) );
|
|
return false;
|
|
}
|
|
|
|
// Find (or create!) the desired package for this object
|
|
UPackage* Pkg = CreatePackage(nullptr,*PackageName);
|
|
|
|
// Handle fully loading packages before creating new objects.
|
|
TArray<UPackage*> TopLevelPackages;
|
|
TopLevelPackages.Add( Pkg );
|
|
if( !UPackageTools::HandleFullyLoadingPackages( TopLevelPackages, OperationText ) )
|
|
{
|
|
// User aborted.
|
|
return false;
|
|
}
|
|
|
|
// We need to test again after fully loading.
|
|
if (!FName(*AssetName).IsValidObjectName( Reason )
|
|
|| !FPackageName::IsValidLongPackageName( PackageName, /*bIncludeReadOnlyRoots=*/false, &Reason ) )
|
|
{
|
|
FMessageDialog::Open( EAppMsgType::Ok, Reason );
|
|
return false;
|
|
}
|
|
|
|
// Check for an existing object
|
|
UObject* ExistingObject = StaticFindObject( UObject::StaticClass(), Pkg, *AssetName );
|
|
if( ExistingObject != nullptr )
|
|
{
|
|
// Object already exists in either the specified package or another package. Check to see if the user wants
|
|
// to replace the object.
|
|
bool bWantReplace =
|
|
EAppReturnType::Yes == FMessageDialog::Open(
|
|
EAppMsgType::YesNo,
|
|
EAppReturnType::No,
|
|
FText::Format(
|
|
NSLOCTEXT("UnrealEd", "ReplaceExistingObjectInPackage_F", "An object [{0}] of class [{1}] already exists in file [{2}]. Do you want to replace the existing object? If you click 'Yes', the existing object will be deleted. Otherwise, click 'No' and choose a unique name for your new object." ),
|
|
FText::FromString(AssetName), FText::FromString(ExistingObject->GetClass()->GetName()), FText::FromString(PackageName) ) );
|
|
|
|
if( bWantReplace )
|
|
{
|
|
// Replacing an object. Here we go!
|
|
// Delete the existing object
|
|
bool bDeleteSucceeded = ObjectTools::DeleteSingleObject( ExistingObject );
|
|
|
|
if (bDeleteSucceeded)
|
|
{
|
|
// Force GC so we can cleanly create a new asset (and not do an 'in place' replacement)
|
|
CollectGarbage( GARBAGE_COLLECTION_KEEPFLAGS );
|
|
|
|
// Old package will be GC'ed... create a new one here
|
|
Pkg = CreatePackage(nullptr,*PackageName);
|
|
Pkg->MarkAsFullyLoaded();
|
|
}
|
|
else
|
|
{
|
|
// Notify the user that the operation failed b/c the existing asset couldn't be deleted
|
|
FMessageDialog::Open( EAppMsgType::Ok, FText::Format( NSLOCTEXT("DlgNewGeneric", "ContentBrowser_CannotDeleteReferenced", "{0} wasn't created.\n\nThe asset is referenced by other content."), FText::FromString( AssetName ) ) );
|
|
}
|
|
|
|
if( !bDeleteSucceeded || !IsUniqueObjectName( *AssetName, Pkg, Reason ) )
|
|
{
|
|
// Original object couldn't be deleted
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// User chose not to replace the object; they'll need to enter a new name
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// Check for a package that was marked for delete in source control
|
|
if ( !CheckForDeletedPackage(Pkg) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void UAssetToolsImpl::PerformMigratePackages(TArray<FName> PackageNamesToMigrate) const
|
|
{
|
|
// Form a full list of packages to move by including the dependencies of the supplied packages
|
|
TSet<FName> AllPackageNamesToMove;
|
|
{
|
|
FScopedSlowTask SlowTask( PackageNamesToMigrate.Num(), LOCTEXT( "MigratePackages_GatheringDependencies", "Gathering Dependencies..." ) );
|
|
SlowTask.MakeDialog();
|
|
|
|
for ( auto PackageIt = PackageNamesToMigrate.CreateConstIterator(); PackageIt; ++PackageIt )
|
|
{
|
|
SlowTask.EnterProgressFrame();
|
|
|
|
if ( !AllPackageNamesToMove.Contains(*PackageIt) )
|
|
{
|
|
AllPackageNamesToMove.Add(*PackageIt);
|
|
RecursiveGetDependencies(*PackageIt, AllPackageNamesToMove);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Confirm that there is at least one package to move
|
|
if ( AllPackageNamesToMove.Num() == 0 )
|
|
{
|
|
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("MigratePackages_NoFilesToMove", "No files were found to move"));
|
|
return;
|
|
}
|
|
|
|
// Prompt the user displaying all assets that are going to be migrated
|
|
{
|
|
const FText ReportMessage = LOCTEXT("MigratePackagesReportTitle", "The following assets will be migrated to another content folder.");
|
|
TArray<FString> ReportPackageNames;
|
|
for ( auto PackageIt = AllPackageNamesToMove.CreateConstIterator(); PackageIt; ++PackageIt )
|
|
{
|
|
ReportPackageNames.Add((*PackageIt).ToString());
|
|
}
|
|
SPackageReportDialog::FOnReportConfirmed OnReportConfirmed = SPackageReportDialog::FOnReportConfirmed::CreateUObject(this, &UAssetToolsImpl::MigratePackages_ReportConfirmed, ReportPackageNames);
|
|
SPackageReportDialog::OpenPackageReportDialog(ReportMessage, ReportPackageNames, OnReportConfirmed);
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::MigratePackages_ReportConfirmed(TArray<FString> ConfirmedPackageNamesToMigrate) const
|
|
{
|
|
// Choose a destination folder
|
|
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
|
|
FString DestinationFolder;
|
|
if ( ensure(DesktopPlatform) )
|
|
{
|
|
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
|
|
|
|
const FString Title = LOCTEXT("MigrateToFolderTitle", "Choose a destination Content folder").ToString();
|
|
bool bFolderAccepted = false;
|
|
while (!bFolderAccepted)
|
|
{
|
|
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
|
|
ParentWindowWindowHandle,
|
|
Title,
|
|
FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_EXPORT),
|
|
DestinationFolder
|
|
);
|
|
|
|
if ( !bFolderSelected )
|
|
{
|
|
// User canceled, return
|
|
return;
|
|
}
|
|
|
|
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_EXPORT, DestinationFolder);
|
|
FPaths::NormalizeFilename(DestinationFolder);
|
|
if ( !DestinationFolder.EndsWith(TEXT("/")) )
|
|
{
|
|
DestinationFolder += TEXT("/");
|
|
}
|
|
|
|
// Verify that it is a content folder
|
|
if ( DestinationFolder.EndsWith(TEXT("/Content/")) )
|
|
{
|
|
bFolderAccepted = true;
|
|
}
|
|
else
|
|
{
|
|
// The user chose a non-content folder. Confirm that this was their intention.
|
|
const FText Message = FText::Format(LOCTEXT("MigratePackages_NonContentFolder", "{0} does not appear to be a game Content folder. Migrated content will only work properly if placed in a Content folder. Would you like to place your content here anyway?"), FText::FromString(DestinationFolder));
|
|
EAppReturnType::Type Response = FMessageDialog::Open(EAppMsgType::YesNo, Message);
|
|
bFolderAccepted = (Response == EAppReturnType::Yes);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Not on a platform that supports desktop functionality
|
|
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("NoDesktopPlatform", "Error: This platform does not support a file dialog."));
|
|
return;
|
|
}
|
|
|
|
bool bUserCanceled = false;
|
|
|
|
// Copy all specified assets and their dependencies to the destination folder
|
|
FScopedSlowTask SlowTask( 2, LOCTEXT( "MigratePackages_CopyingFiles", "Copying Files..." ) );
|
|
SlowTask.MakeDialog();
|
|
|
|
EAppReturnType::Type LastResponse = EAppReturnType::Yes;
|
|
TArray<FString> SuccessfullyCopiedFiles;
|
|
TArray<FString> SuccessfullyCopiedPackages;
|
|
FString CopyErrors;
|
|
|
|
SlowTask.EnterProgressFrame();
|
|
{
|
|
FScopedSlowTask LoopProgress(ConfirmedPackageNamesToMigrate.Num());
|
|
for ( auto PackageNameIt = ConfirmedPackageNamesToMigrate.CreateConstIterator(); PackageNameIt; ++PackageNameIt )
|
|
{
|
|
LoopProgress.EnterProgressFrame();
|
|
|
|
const FString& PackageName = *PackageNameIt;
|
|
FString SrcFilename;
|
|
if ( !FPackageName::DoesPackageExist(PackageName, nullptr, &SrcFilename) )
|
|
{
|
|
const FText ErrorMessage = FText::Format(LOCTEXT("MigratePackages_PackageMissing", "{0} does not exist on disk."), FText::FromString(PackageName));
|
|
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *ErrorMessage.ToString());
|
|
CopyErrors += ErrorMessage.ToString() + LINE_TERMINATOR;
|
|
}
|
|
else if (SrcFilename.Contains(FPaths::EngineContentDir()))
|
|
{
|
|
const FString LeafName = SrcFilename.Replace(*FPaths::EngineContentDir(), TEXT("Engine/"));
|
|
CopyErrors += FText::Format(LOCTEXT("MigratePackages_EngineContent", "Unable to migrate Engine asset {0}. Engine assets cannot be migrated."), FText::FromString(LeafName)).ToString() + LINE_TERMINATOR;
|
|
}
|
|
else
|
|
{
|
|
bool bFileOKToCopy = true;
|
|
|
|
FString DestFilename = DestinationFolder;
|
|
|
|
FString SubFolder;
|
|
if ( SrcFilename.Split( TEXT("/Content/"), nullptr, &SubFolder ) )
|
|
{
|
|
DestFilename += *SubFolder;
|
|
|
|
if ( IFileManager::Get().FileSize(*DestFilename) > 0 )
|
|
{
|
|
// The destination file already exists! Ask the user what to do.
|
|
EAppReturnType::Type Response;
|
|
if ( LastResponse == EAppReturnType::YesAll || LastResponse == EAppReturnType::NoAll )
|
|
{
|
|
Response = LastResponse;
|
|
}
|
|
else
|
|
{
|
|
const FText Message = FText::Format( LOCTEXT("MigratePackages_AlreadyExists", "An asset already exists at location {0} would you like to overwrite it?"), FText::FromString(DestFilename) );
|
|
Response = FMessageDialog::Open( EAppMsgType::YesNoYesAllNoAllCancel, Message );
|
|
if ( Response == EAppReturnType::Cancel )
|
|
{
|
|
// The user chose to cancel mid-operation. Break out.
|
|
bUserCanceled = true;
|
|
break;
|
|
}
|
|
LastResponse = Response;
|
|
}
|
|
|
|
const bool bWantOverwrite = Response == EAppReturnType::Yes || Response == EAppReturnType::YesAll;
|
|
if( !bWantOverwrite )
|
|
{
|
|
// User chose not to replace the package
|
|
bFileOKToCopy = false;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Couldn't find Content folder in source path
|
|
bFileOKToCopy = false;
|
|
}
|
|
|
|
if ( bFileOKToCopy )
|
|
{
|
|
if ( IFileManager::Get().Copy(*DestFilename, *SrcFilename) == COPY_OK )
|
|
{
|
|
SuccessfullyCopiedPackages.Add(PackageName);
|
|
SuccessfullyCopiedFiles.Add(DestFilename);
|
|
}
|
|
else
|
|
{
|
|
UE_LOG(LogAssetTools, Warning, TEXT("Failed to copy %s to %s while migrating assets"), *SrcFilename, *DestFilename);
|
|
CopyErrors += SrcFilename + LINE_TERMINATOR;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FString SourceControlErrors;
|
|
SlowTask.EnterProgressFrame();
|
|
|
|
if ( !bUserCanceled && SuccessfullyCopiedFiles.Num() > 0 )
|
|
{
|
|
// attempt to add files to source control (this can quite easily fail, but if it works it is very useful)
|
|
if(GetDefault<UEditorLoadingSavingSettings>()->bSCCAutoAddNewFiles)
|
|
{
|
|
if(ISourceControlModule::Get().IsEnabled())
|
|
{
|
|
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
|
|
if(SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), SuccessfullyCopiedFiles) == ECommandResult::Failed)
|
|
{
|
|
FScopedSlowTask LoopProgress(SuccessfullyCopiedFiles.Num());
|
|
|
|
for(auto FileIt(SuccessfullyCopiedFiles.CreateConstIterator()); FileIt; FileIt++)
|
|
{
|
|
LoopProgress.EnterProgressFrame();
|
|
if(!SourceControlProvider.GetState(*FileIt, EStateCacheUsage::Use)->IsAdded())
|
|
{
|
|
SourceControlErrors += FText::Format(LOCTEXT("MigratePackages_SourceControlError", "{0} could not be added to source control"), FText::FromString(*FileIt)).ToString();
|
|
SourceControlErrors += LINE_TERMINATOR;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FMessageLog MigrateLog("AssetTools");
|
|
FText LogMessage = FText::FromString(TEXT("Content migration completed successfully!"));
|
|
EMessageSeverity::Type Severity = EMessageSeverity::Info;
|
|
if ( CopyErrors.Len() > 0 || SourceControlErrors.Len() > 0 )
|
|
{
|
|
FString ErrorMessage;
|
|
Severity = EMessageSeverity::Error;
|
|
if( CopyErrors.Len() > 0 )
|
|
{
|
|
MigrateLog.NewPage( LOCTEXT("MigratePackages_CopyErrorsPage", "Copy Errors") );
|
|
MigrateLog.Error(FText::FromString(*CopyErrors));
|
|
ErrorMessage += FText::Format(LOCTEXT( "MigratePackages_CopyErrors", "Copied {0} files. Some content could not be copied."), FText::AsNumber(SuccessfullyCopiedPackages.Num())).ToString();
|
|
}
|
|
if( SourceControlErrors.Len() > 0 )
|
|
{
|
|
MigrateLog.NewPage( LOCTEXT("MigratePackages_SourceControlErrorsListPage", "Source Control Errors") );
|
|
MigrateLog.Error(FText::FromString(*SourceControlErrors));
|
|
ErrorMessage += LINE_TERMINATOR;
|
|
ErrorMessage += LOCTEXT( "MigratePackages_SourceControlErrorsList", "Some files reported source control errors.").ToString();
|
|
}
|
|
if ( SuccessfullyCopiedPackages.Num() > 0 )
|
|
{
|
|
MigrateLog.NewPage( LOCTEXT("MigratePackages_CopyErrorsSuccesslistPage", "Copied Successfully") );
|
|
MigrateLog.Info(FText::FromString(*SourceControlErrors));
|
|
ErrorMessage += LINE_TERMINATOR;
|
|
ErrorMessage += LOCTEXT( "MigratePackages_CopyErrorsSuccesslist", "Some files were copied successfully.").ToString();
|
|
for ( auto FileIt = SuccessfullyCopiedPackages.CreateConstIterator(); FileIt; ++FileIt )
|
|
{
|
|
if(FileIt->Len()>0)
|
|
{
|
|
MigrateLog.Info(FText::FromString(*FileIt));
|
|
}
|
|
}
|
|
}
|
|
LogMessage = FText::FromString(ErrorMessage);
|
|
}
|
|
else if ( !bUserCanceled )
|
|
{
|
|
MigrateLog.NewPage( LOCTEXT("MigratePackages_CompletePage", "Content migration completed successfully!") );
|
|
for ( auto FileIt = SuccessfullyCopiedPackages.CreateConstIterator(); FileIt; ++FileIt )
|
|
{
|
|
if(FileIt->Len()>0)
|
|
{
|
|
MigrateLog.Info(FText::FromString(*FileIt));
|
|
}
|
|
}
|
|
}
|
|
MigrateLog.Notify(LogMessage, Severity, true);
|
|
}
|
|
|
|
void UAssetToolsImpl::RecursiveGetDependencies(const FName& PackageName, TSet<FName>& AllDependencies) const
|
|
{
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
TArray<FName> Dependencies;
|
|
AssetRegistryModule.Get().GetDependencies(PackageName, Dependencies);
|
|
|
|
for ( auto DependsIt = Dependencies.CreateConstIterator(); DependsIt; ++DependsIt )
|
|
{
|
|
if ( !AllDependencies.Contains(*DependsIt) )
|
|
{
|
|
// @todo Make this skip all packages whose root is different than the source package list root. For now we just skip engine content.
|
|
const bool bIsEnginePackage = (*DependsIt).ToString().StartsWith(TEXT("/Engine"));
|
|
const bool bIsScriptPackage = (*DependsIt).ToString().StartsWith(TEXT("/Script"));
|
|
if ( !bIsEnginePackage && !bIsScriptPackage )
|
|
{
|
|
AllDependencies.Add(*DependsIt);
|
|
RecursiveGetDependencies(*DependsIt, AllDependencies);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAssetToolsImpl::FixupReferencers(const TArray<UObjectRedirector*>& Objects) const
|
|
{
|
|
AssetFixUpRedirectors->FixupReferencers(Objects);
|
|
}
|
|
|
|
void UAssetToolsImpl::OpenEditorForAssets(const TArray<UObject*>& Assets) const
|
|
{
|
|
FAssetEditorManager::Get().OpenEditorForAssets(Assets);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|