You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb None ========================== MAJOR FEATURES + CHANGES ========================== Change 3108929 on 2016/08/31 by Jon.Nabozny PR #2745: Add FQuat version of SetWorldRotation functions (Contibuted by EverNewJoy) #jira UE-35260 Change 3108930 on 2016/08/31 by Jon.Nabozny Fix out of date URadialForceComponent::CollisionObjectQueryParams by adding a BeginPlay event callback. #jira UE-33880 Change 3108934 on 2016/08/31 by Jon.Nabozny Fix check in UCharacterMovement::StepUp to properly account for distance the component is above the floor. #jira UE-33051 Change3108971on 2016/08/31 by Jon.Nabozny Add missing URadialForceComponent.h changes from CR 3108930 Change 3109557 on 2016/09/01 by Thomas.Sarkanen Copying //Tasks/Dev-Framework/Dev-PersonaUpgrade to Dev-Framework (//UE4/Dev-Framework) Persona Upgrade Summary of changes: - Persona module is now a repository of re-usable components, rather than an asset editor in itself. - Multiple asset editors now exist for specific asset types (Animation, Skeleton, anim BP etc). - Skeleton editing is now performed via the new IEditableSkeleton interface. This wraps up all mutations that can be performed on a skeleton in a model-view type architecture. - Skeleton tree acts as the view of the editable skeleton's data. When an edit is made in one version of a skeleton tree, it is reflected in all of them. - Removed all 'PersonaPtr's. Communication is now performed via delegates and appropriate API bindings (preview scene, editable skeleton etc.) - Viewport reworked to use editor modes for its more specific inputs. Skeletal controls now use editor modes for their inputs. - Better control of 'focus on draw' in the viewport. We can now optionally interpolate in approriate circumstances. - Animation preview scene resurrected. Now we manage much of the underlying objects in the preview scene. It also acts as a messaging conduit for events related to the scene. - We can now add additional meshes to a skeleton for use as previews. This is perfomred via a new UPreviewMeshCollection asset type & edited in the viewport. - Removed old SAdditionalMeshesEditor as the new system replaces its functionality. - Added asset family shortcut bar (and IAssetFamily to support this). - Const corrected some engine functions. - Added the ability for a skel mesh component to function without a primary skeletal mesh. This is usually a transient state in-editor but now the engine will not crash. - Padding, layouts and appearance of all editors have been polished. - Moved recording controls to the viewport and recording code into the preview scene. Now anything that uses a Persona viewport can use recording. - Tweaked recording icon to always use some red (feedback was it was non-obvious that it was a recording button). - Improved anim BP preview editor. We now have a bubtton that copies values that have changed to the defaults so that preview edits can more easily be seen & transferred. - Removed sequence recorder from non-level editor windows. Change 3109628 on 2016/09/01 by Thomas.Sarkanen Fix non-unity build Change 3109639 on 2016/09/01 by Thomas.Sarkanen CIS fix: Monolithic non-editor builds Change 3109648 on 2016/09/01 by Thomas.Sarkanen Properly fix monolithic CIS this time Change 3109683 on 2016/09/01 by Thomas.Sarkanen Fix Mac editor CIS Change 3109689 on 2016/09/01 by Benn.Gallagher Fix crash in when a client spawns a destructible in a world with multiple players, caused by assuming we have a scene when the insertion may be deferred. #jira UE-35353 Change 3109699 on 2016/09/01 by Thomas.Sarkanen More Mac Editor CIS fixes. Change 3109727 on 2016/09/01 by Danny.Bouimad Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone. Change 3109758 on 2016/09/01 by Thomas.Sarkanen More Mac editor CIS fixes Somehow includes from engine and unrealed were still getting picked up outside of PCH on windows. Updated PCH's and other includes to cover the mssing types. Change 3109829 on 2016/09/01 by Thomas.Sarkanen Fix crash when attaching slave components with differing bone counts Change 3111672 on 2016/09/02 by Thomas.Sarkanen Populated UV channels correctly Delegate for preview mesh change was being fired early (when the preview scene was created), so UV channels were never populated. Added a call to populate on construction. Change 3111924 on 2016/09/02 by Martin.Wilson Clean up references to GetBoneTree and deprecate #jira UE-35525 Change 3112086 on 2016/09/02 by Martin.Wilson Fix pose flickering on LOD change when using Layered Blend by Bone node #Jira UE-35471 Change 3112097 on 2016/09/02 by Aaron.McLeran UE-35533 StopQuietest concurrency not resulting in sounds returning to play - Issue is due to the fact that once an active sound was flagged as needing to stop due to max concurrency, it was never unflagging as needing to stop - Fix is to make sure to unflag active sounds in a concurrency group as bShouldStopDueToMaxConcurrency before flagging the ones that do. Change 3112467 on 2016/09/02 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3112269 Change 3112604 on 2016/09/02 by Lina.Halper Fixed merge compile error Change 3113524 on 2016/09/05 by Thomas.Sarkanen Prevent invalid assets from causing crashes with asset families Store asset references as weak object ptrs as assets can go away underneath us. Also dont preserve asset families when all referencing asset editors are shut down, use weak references instead. #jira UE-35572 - Crash when opening Child Montage after force deleting an older child montage with the same name from the same asset Change 3114118 on 2016/09/06 by Marc.Audy Add boolean return to AGameMode::ClearPause to indicate whether pausing was cleared #jira UE-32852 Change 3114201 on 2016/09/06 by Lina.Halper #ANMI: Moving animation curves from asset to skeleton - Backward compatibility - AnimCurve Viewer contains the setting of changing curve type - only material or morph would display. - Morphtarget curves are automatically set on loading - Asset still contains curve type including editable or disabled and so on. I was going to make this to be editor only but I can't until we copy over all the data - because morphtarget/material deprecated flags are needed to be loaded in game - TODO: Moving cached UI to FBoneContainer, so that it can work with RequiredBones - TODO: Linking curve to joint - TODO: Allow Layer blending to use this data to blend curves #Code review:Martin.Wilson, James.Golding #jira: UEFW-179 Change 3114391 on 2016/09/06 by Lina.Halper Build warning fix Change 3114399 on 2016/09/06 by Lina.Halper Fix build error. Change 3114403 on 2016/09/06 by Lina.Halper Attempt to fix build error Change 3114591 on 2016/09/06 by Lina.Halper Fix compile error Change 3114963 on 2016/09/06 by Lina.Halper Fixed crash on deleting skeleton when placed in the level #jira: UE-35601 Change 3114985 on 2016/09/06 by Lina.Halper Fix crash with copy pose mesh node not checking registered or not. #jira: UE-35602 Change 3115933 on 2016/09/07 by James.Golding UE-33251 - add 'restart required' to bSupportUVFromHitResults option Change 3116021 on 2016/09/07 by Marc.Audy Fix spelling de-auto NULL to nullptr minor optimization Change 3116046 on 2016/09/07 by James.Golding Move AnimNode_LegIK.h to Public and .cpp for Private Change3116048on 2016/09/07 by James.Golding UE-34640 Fix bogus tooltips for collision channels Change 3116050 on 2016/09/07 by James.Golding PR #2728: UE-34953: Improved comments for Hit callbacks (Contributed by projectgheist) Change 3116060 on 2016/09/07 by Lina.Halper #ANIM: - Fix crash of setting multiple times in the same menu - Make sure you can set to original animation, and not break #jira: UE-35580 Change 3116064 on 2016/09/07 by James.Golding Fix missing change for LegIK file move Change 3116291 on 2016/09/07 by Marc.Audy FindObjectWithOuter once again allows ClassToLookFor to be null as comment indicates is allowed Change 3116590 on 2016/09/07 by Dan.Reynolds Audio Test Map Content WIP Change 3116649 on 2016/09/07 by mason.seay Updated map to test flying Change 3116712 on 2016/09/07 by dan.reynolds Test Content Update EQTest Map WIP Change 3117257 on 2016/09/08 by Benn.Gallagher Fixed skeletal mesh details not working in new standalone mesh editor. Duplicated the detail customization and reworked to handle the new host app (no longer FPersona). Change 3117348 on 2016/09/08 by Benn.Gallagher Added "Post-Process" Animation Blueprints. These run after the main anim instance, and the class used is set on the mesh so that any instance of that mesh uses that class as a post process. If there is a sub-input node inside the post process graph then the pose at the end of the main instance will be passed through into that instance. #jira UEFW-180 Change 3117393 on 2016/09/08 by Benn.Gallagher Hid UDestructibleMesh properties that are unsupported on destructibles in the destrucitble mesh editor (shadow assets and post process blueprints are only for normal skeletal meshes) #jira UE-34508 Change 3117507 on 2016/09/08 by Jurre.deBaare Streamline Persona Asset Browser #added ability to set whether or not a column should generate widgets in STableViews #added filtering code to SAssetview to allow for hiding/showing columns related to the asset type #added an ini path for saving the column filter state in SAnimationSequenceBrowser #jira UEFW-148 Change 3118003 on 2016/09/08 by mason.seay Updating meshes to use complex collision Change 3118020 on 2016/09/08 by Zak.Middleton #ue4 - Auto-register UpdatedComponent in MovementComponent in InitializeComponent() if not found during OnRegister(). This can occur for non-native (BP) root components. Change 3118437 on 2016/09/08 by Lina.Halper Fix grammar error #jira: UE-35729, UE-35730, UE-35729 Change 3118456 on 2016/09/08 by Lina.Halper Removed space because slate showed long spaces. It's long line now but at least in UI, it looks cleaner. Change 3118492 on 2016/09/08 by Aaron.McLeran Copying //UE4/Dev-Audio to Dev-Framework (//UE4/Dev-Framework) Change 3118517 on 2016/09/08 by Lina.Halper Went back to original without spaces Change 3118711 on 2016/09/08 by Aaron.McLeran Fixing build errors with CL 3118492 Change 3118712 on 2016/09/08 by Aaron.McLeran Fixing a build warning with CL 3118492 Change 3118745 on 2016/09/08 by Aaron.McLeran Fixing a build warning with CL 3118492 - Fixed init order in FSoundSource Change 3119201 on 2016/09/09 by Benn.Gallagher Fix static analysis warnings (Accessing nullptr), added check on the pointer #jira UE-35755 Change 3119338 on 2016/09/09 by Benn.Gallagher Fixed destructible import throwing out meshes where 1 or more submeshes are empty Change 3119371 on 2016/09/09 by Lina.Halper fix texts Change 3119453 on 2016/09/09 by Lina.Halper Change text style of the child montage instruction. #jira: UE-35144 Change 3119454 on 2016/09/09 by Lina.Halper Add option to open asset from context menu of the segment #jira: UE-35632 Change 3119457 on 2016/09/09 by mason.seay Updated maps and rebuilt lighting Change 3119584 on 2016/09/09 by Marc.Audy Support for new metadata ShowInnerProperties (written by Matt K) Change 3119667 on 2016/09/09 by Aaron.McLeran Fixing compile errors on Mac. - Commandlet can't run on Mac (or other desktop platforms) right now since audio mixer isn't yet supported there Change 3119732 on 2016/09/09 by Aaron.McLeran Fixing clang compile error - Apparently clang didn't like my ascii art of the wavetable shapes. Switched to /* */ style comment. Change 3119734 on 2016/09/09 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3119702 Change 3119787 on 2016/09/09 by Lina.Halper Move cached UID to required bone - removed skeleton cached UID list - removed skeletalmeshcomponent cached UID list - FBoneContainer will contain UID list and can be re-cached anytime bones are recalculated - added versioning to up-to-date skeleton curve list with skeletalmeshcomponent #code review:Benn.Gallagher, Martin.Wilson Change 3119800 on 2016/09/09 by Aaron.McLeran Changing audio mixer's GetAudioClock to GetAudioTime to avoid conflicting with other GetAudioClock function merged into dev-framework. Change 3120260 on 2016/09/09 by Marc.Audy Fix if statement Change 3120790 on 2016/09/12 by Thomas.Sarkanen Reordered skeletal mesh and animations in asset shortcut bar #jira UE-35845 - Move anim asset shortcut bar ordering to Skeleton > Skeletal Mesh > Animation > AnimBP Change 3120793 on 2016/09/12 by Thomas.Sarkanen Improved fix for missing mesh details customization Improves on CL 3117257. Removed extra RefreshViewports function. Communication should be done via the preview scene to accomodate future multiple viewports. Re-used generic asset properties tab with a callback delegate that allows post-construction customization. Removed older custom tab. Removed dependency between FSkeletalMeshDetails and FSkeletonEditor. Trying to avoid back-pointer dependencies to monolithic editors, as this was the main bulk of refactoring work when teasing Persona apart. Change 3120867 on 2016/09/12 by Marc.Audy Fix incorrect condition in for causing static analysis warning Change 3120900 on 2016/09/12 by mason.seay Actually build lighting this time Change 3120904 on 2016/09/12 by Thomas.Sarkanen Skeletons can now be deleted once opened (once more) Editable skeleton manager now holds onto weak ptrs instread of shared ptrs. Added logic to compact if weak ptrs are invalid. #jira UE-35848 - Can't delete skeletons that have been opened in the new standalone editor Change 3120927 on 2016/09/12 by Thomas.Sarkanen Details panel now shows selected items when re-opened Kept the underlying widget around so that any item selections can still correctly update the (hidden) UI. #jira UE-35445 - Details tab in persona dosn't populate with information when first opened Change 3120979 on 2016/09/12 by Thomas.Sarkanen Re-added the ability to create pose assets This was added at a similar time to my final merges and didnt get merged over to the standalone animation editor. #jira UE-35740 - Create Pose asset missing from create animation dropdown Change 3121208 on 2016/09/12 by Benn.Gallagher Added bulk reimport to the reimport manager that uses slow tasks to give users an idea how far they are through large operations. #jira UE-33216 Change 3121274 on 2016/09/12 by James.Golding PR #2264: Added functions that can change a UTimelineComponent's curve(s) via Blueprints. (Contributed by hgamiel) #jira UE-29346 Change 3121276 on 2016/09/12 by James.Golding UE-33242 : Add option to copy morph target names to clipboard Change 3121278 on 2016/09/12 by James.Golding UE-33004 : Add proper commands for Curve Viewer Change 3121472 on 2016/09/12 by Zak.Middleton #ue4 - Fix UGameplayStatics::SpawnEmitterAttached() using wrong scale when SnapToTarget (Keep World Scale) option is used. Improve comments for SpawnEmitterAttached(). #jira UE-34482 Change 3121829 on 2016/09/12 by dan.reynolds Audio Blueprints Content Example WIP Update checked in to backlog by request of ZakB and Nick BB. Change 3122218 on 2016/09/12 by Aaron.McLeran Minor cleanup in XAudio2Source.cpp Change 3122823 on 2016/09/13 by Thomas.Sarkanen Fix incorrect camera offset when opening some skeletal meshes Skeletons that had no preview skeletal mesh set up gave incorrect bounds on first tick. This is fixed by updating the preview mesh in the scene desc so that bounds are correctly calculated on first viewport tick. #jira UE-35550 - Persona camera is far away from some skeletal meshes Change 3122857 on 2016/09/13 by Lina.Halper Importing frame count issue with blendshapes - with this change when calculating sample rate, it checks blendshape curves. #jira: UE-27706 Change 3122992 on 2016/09/13 by Marc.Audy Child Actor Component now have an editable template * Template is stored as a child inside the child actor template * When gathering components for an actor, need to stop searching beyond any nested AActor #jira UEFW-125, UE-16474 Change 3123087 on 2016/09/13 by Marc.Audy Fix Child Actor Template being nulled out on template Change 3123170 on 2016/09/13 by mason.seay Updated test map to test SpawnEmitterAttached SnapToTarget settings UEENGQA-9268 Change 3123203 on 2016/09/13 by Marc.Audy Multi-select of child actor components allows editing of template properties Change 3123205 on 2016/09/13 by Marc.Audy Fix details panel constantly updating and not being interactable when multi-selected objects have ShowInnerProperty property #author Matt.Kuhlenschmidt Change 3123422 on 2016/09/13 by Aaron.McLeran UE-35950 Fixing XboxOne spatialization - XBoxOne doesn't support device details, so we need to manually set it to the output channels and channel mask. Unfortunately, that was incorrectly set. Change 3123484 on 2016/09/13 by Lina.Halper Fix animation frame UI issue - This now displays from [0, numframes -1] #jira: UE-33437 Change 3123500 on 2016/09/13 by Marc.Audy Undo/redo of mobility changes will also undo/redo the mobility changes on ancestors/descendants that were changed along with it #jira UE-35885 Change 3123549 on 2016/09/13 by Marc.Audy Fix warning message Change 3123581 on 2016/09/13 by Marc.Audy PR #2751: Editor Only UActorComponents for Blueprints (Contributed by moritz-wundke) #jira UE-35424 Change 3123688 on 2016/09/13 by Ben.Zeigler Add logic to K2Node_Variable that updates the variable reference to the correct class, if the variable has moved up or down in the class hierarchy. This is similar to code in UK2Node_CallFunction::CreateSelfPin which already handled this case correctly Change 3123768 on 2016/09/13 by Marc.Audy Go away auto NULL to nullptr Use ranged for instead of iterators Change 3123906 on 2016/09/13 by Aaron.McLeran UE-34615 Supporting Pausing Sounds on Audio Components Change 3123949 on 2016/09/13 by Aaron.McLeran UE-35965 Spatialization no longer occurs when Non-Spatialized Radius is set above 0 Change 3124109 on 2016/09/13 by Aaron.McLeran UE-33364 Making bSuppressSubtitles a UPROPERTY EditAnywhere, BlueprintReadWrite Change 3124137 on 2016/09/13 by Aaron.McLeran PR #2601: made looping sound waves searchable by the asset registry Change 3124396 on 2016/09/14 by James.Golding Allow anim node edit modes to work on all nodes, not just skel controls Change 3124498 on 2016/09/14 by Benn.Gallagher Added method to get swing and twist quaternions from FQuat #jira UE-34054 Change 3124504 on 2016/09/14 by James.Golding Missed a few references to SkeletalControlEditMode Change 3124508 on 2016/09/14 by James.Golding Fix function groupings in animnode editmode headers Change 3124625 on 2016/09/14 by james.cobbett Rebuilding lighting. Change 3124632 on 2016/09/14 by James.Golding UEFW-205 Adding support for PoseDriver to drive bones (based on PoseAsset) - Converted PoseDriver from SkelControl to AnimNode - Added PoseDriverEditMode - Added debug drawing to show target poses and current ref position - Aded support for PoseDriver using translation instead of rotation - Added AnimGraphNode_PoseHandler class, with code corresponding with AnimNode_PoseHandler Change 3124636 on 2016/09/14 by James.Golding Missed file Change 3124652 on 2016/09/14 by Marc.Audy Fix initialization order warning #jira UE-35980 Change 3124658 on 2016/09/14 by Marc.Audy Fix if statement #jira UE-35976 Change 3124685 on 2016/09/14 by James.Golding Move PoseDriver files from BoneControllers to AnimNodes folder Rename AnimNode_PosePriver.cpp to AnimNode_PoseDriver.cpp Move AnimGraphNode_AssetPlayerBase.cpp from Classes to Private Change 3124690 on 2016/09/14 by James.Golding Missing header edit after file move Change 3124707 on 2016/09/14 by Danny.Bouimad Fixing UE-34814, issue where a socket was not rendering correctly. Note: The old socket wasn't attached to a bone to fix the issue so it was attached to the root bone. Somehow this was undone. Change 3124954 on 2016/09/14 by Jurre.deBaare Import Alembic file gets editor crash #fix double check if Alembic isn't lying and there are no actual normals #misc fixed type in function signature #jira UE-35702 Change 3124980 on 2016/09/14 by Lina.Halper Tweak UI of child anim montage - removed padding, changed font size Change 3124981 on 2016/09/14 by Lina.Halper Changed text of keys to Frames Change 3124998 on 2016/09/14 by Lina.Halper Fix curve issue when evaluting with # of frames. #jira: UE-35782 Change 3125034 on 2016/09/14 by Aaron.McLeran Changes to 3123906 based on feedback from Marc Audy Change 3125109 on 2016/09/14 by Aaron.McLeran PR #2463: Support parsing .WAV files with a WAVE_FORMAT_EXTENSIBLE format chunk (Contributed by Mattiwatti) Change 3125184 on 2016/09/14 by Lukasz.Furman vehicle RVO fixes #ue4 Change 3125191 on 2016/09/14 by Lukasz.Furman added blueprint interface for component's navigation influence control #ue4 Change 3125348 on 2016/09/14 by Mason.Seay Added GamepadFaceButtonRight as an input mapping for Crouch Change 3125352 on 2016/09/14 by Lina.Halper #ANIM: Pose Asset - Insert pose support - made sure pose asset editor updates if the new pose is inserted. #jira: UE-32608 Change 3125413 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Add GameModeBase and GameStateBase classes that are parent classes of existing GameMode and GameState. The classes have been split in half so the base functionality needed by all games are in the Base classes, with legacy and match-specific code in the children Added BP access to several GameState and GameMode functions, and GetGameState/GetGameMode now return the base classes. World->GetAuthGameMode now returns GameModeBase, so direct accesses to the return value may not work. The casted template works as before. World->GameState is now private, and GetGameState returns GameStateBase. Code that accessed GameState should now call GetGameState<>. GameModeBase::StartNewPlayer has been deprecated, and split into InitializeHUDForPlayer and HandleStartingNewPlayer. Several Login functions on GameModeBase that take TSharedPtr<const FUniqueNetId> are now deprecated correctly, they previously stopped working correctly in 4.13 The ShouldShowGore feature on GameState has been fully deprecated, along with hooks in Matinee Change 3125414 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Convert all internal templates to use GameModeBase Convert most sample games, ShooterGame and several legacy projects are still using GameMode Change 3125415 on 2016/09/14 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Internal game compile fixes needed to support GameMode refactor Fixed a few places that overrode StartNewPlayer to override new functions instead Change 3125438 on 2016/09/14 by Ben.Zeigler Log compile fix Change 3125460 on 2016/09/14 by Ben.Zeigler Another try at log compile issues Change 3125685 on 2016/09/14 by Aaron.McLeran Attempt to fix compile error Change 3125700 on 2016/09/14 by Aaron.McLeran UE-35958 Undo in sound cue editor does not undo looping changes. Issue was sound cues were not being flagged as transactional and ignoring undo transactions Change 3125857 on 2016/09/14 by Aaron.McLeran -Adding a RF_Transactional flag to postload for sound nodes so older sound nodes created incorrectly will work properly with the undo system. -Changed to setting flag directly in NewObject line instead of calling SetFlags Change 3125888 on 2016/09/14 by Aaron.McLeran Adding call to super post load in USoundNode::PostLoad() Change 3125964 on 2016/09/14 by Aaron.McLeran Fixing attenuation on 2D multichannel files (specifically 3, 7 and 8-channel files). Change 3125974 on 2016/09/14 by Aaron.McLeran UE-35892 Not loading audio data when in -nosound mode Change 3125983 on 2016/09/14 by Ben.Zeigler Better Nogore fix for lens effect Change 3125985 on 2016/09/14 by Ben.Zeigler Fix fortnite compile failure on mac, it was inside non instantiated template Change 3126409 on 2016/09/15 by Benn.Gallagher Fixed crash when adding a reroute node on a line with another reroute node in an anim graph. Becuase we use poselinks as an exec line we weren't killing the output links. #jira UE-35657 Change 3126507 on 2016/09/15 by Thomas.Sarkanen Prevent crash when calling SetAnimationMode on a component with no skeletal mesh Guard against the mesh being NULL, as with other calls to InitializeAnimScriptInstance. #jira UE-36003 - Crash playing Ocean Change 3126539 on 2016/09/15 by Marc.Audy Fix Win32 compilation error #jira UE-36018 Change 3126575 on 2016/09/15 by Marc.Audy Properly fix compile Change 3126635 on 2016/09/15 by Benn.Gallagher Fix for crash when setting collision responses on destructible components after they have been fractured. #jira UE-35604 Change 3126649 on 2016/09/15 by Lina.Halper - Fixed issue with updating cache UID List, so certain curves did not work. - Fixed issue with not finding meta data because the name has changed - converted to SmartName, and if it is going to look for by UID. Change 3126816 on 2016/09/15 by Lukasz.Furman Back out changelist 3125191 Change 3126903 on 2016/09/15 by Marc.Audy Fix !WITH_APEX compile errors from CL# 3126635 Change 3126908 on 2016/09/15 by Mieszko.Zielinski Added initialization of FBlackboardEntry properties #UE4 Change 3127081 on 2016/09/15 by Ben.Zeigler #jira UEFW-32 Game Mode Cleanup Change the way that the GameMode is picked based on URL to be handled by GameInstance instead of World/GameMode. Add PreloadContentForURL, CreateGameModeForURL, and OverrideGameModeClass to GameInstance and deprecate GameMode versions. GameMode::GameModeClassAliases has moved to GameMapsSettings::GameModeClassAliases and WorldSettings::DefaultMapPrefixes has moved to GameMapsSettings::GameModeMapPrefixes and unified in format. Fixed internal game ini files and added example to BaseEngine.ini Removed some outdated seekfree preload code and replace with GameInstance::PreloadContentForURL Change 3127102 on 2016/09/15 by Ben.Zeigler Crash fix if there is no deprecated config section Change 3127103 on 2016/09/15 by Aaron.McLeran UE-34100 audio playback of an individual source Change 3127109 on 2016/09/15 by Marc.Audy Remove inconsistently used AUDIO_DEVICE_HANDLE_INVALID and use INDEX_NONE everywhere instead Change 3127143 on 2016/09/15 by Aaron.McLeran Missing file in CL 3127103 Change 3127218 on 2016/09/15 by Ori.Cohen PR #2766: More vehicle stats for profiler (Contributed by DenizPiri) #JIRA UE-35564 Change 3127264 on 2016/09/15 by Aaron.McLeran Switching to using USoundWave instead of USoundBase in notification delegate for play progress percent Change 3127285 on 2016/09/15 by Marc.Audy Make it easier to create an audio component that will exist across level transitions Refactor FAudioDevice::CreateComponent to use a Params block instead of long parameter list UAudioComponent can now store which AudioDevice it is targetted at instead of being limited to its registered world or the main audio device (breaks in multi-PIE) #jira UE-16451 Change 3127360 on 2016/09/15 by Marc.Audy Consolidate a few GetWorld()s Change 3127931 on 2016/09/16 by Benn.Gallagher Fixed holes appearing in clothing meshes after reskinning changes. Caused by mismatched triangle counts when applying the clothing mesh. #jira UE-36054 Change 3128001 on 2016/09/16 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3127918 Change 3128005 on 2016/09/16 by James.Cobbett #jira UE-29618 Submitting test assets Change 3128022 on 2016/09/16 by Lina.Halper Allow re-merge all skeletalmeshes back to skeleton when recreating skeleton from scratch #jira: UE-27256 Change 3128044 on 2016/09/16 by James.Cobbett Submitting gamemode test asset Change 3128169 on 2016/09/16 by Mieszko.Zielinski Fixed couple of static analysis warnings in AI code #UE4 Change 3128430 on 2016/09/16 by Marc.Audy Fix infinite loop when running a pause frame with tick interval functions (4.13.1) #jira UE-36096 Change 3128558 on 2016/09/16 by Mieszko.Zielinski Refactored FEnvQueryInstance::AddItemData to not require second template parameter (TypeValue) #UE4 #jira UE-33036 Change 3128678 on 2016/09/16 by Jon.Nabozny #rn Added a delegate to GameViewportClient that notifies when the Game's platform specific window is being closed. #rn This can be used to prevent the game from being exited. #jira UE-34123 Change 3128693 on 2016/09/16 by Marc.Audy Add UnpausedTimeSeconds to UWorld to accumulate the dilated/clamped game time even when paused Change 3128753 on 2016/09/16 by Mieszko.Zielinski Fixed aborting previous movements as part requesting a new one needlesly reseting move agent's current velocity #UE4 #jira UE-35852 Change 3128791 on 2016/09/16 by Marc.Audy PR #2777: Accurate DeltaSeconds for objects with TickIntervals (Contributed by YossiMHWF) Tick Functions with a Tick Interval will now return the dilated/clamped game DeltaSeconds since the last time it ticked #jira UE-35719 Change 3128974 on 2016/09/16 by Mieszko.Zielinski Fixes to BB key synchronization #UE4 syncing between two BBs associated by a common parent now works Change 3128984 on 2016/09/16 by Jon.Nabozny Fix FConstraintBaseParams ContactDistance clamping. The value is intended to be in either degrees or cm units (depending on constraint type), so clamping max to 1 doesn't make sense. Change 3129010 on 2016/09/16 by Dan.Reynolds Updating developer folder content for external referencing Change3129093on 2016/09/16 by Ben.Zeigler #jira UE-35424 Switch from using AlwaysLoadOnServer/Client to bIsEditorOnly for components that should be editor only. This works better with cooking and is clearer in usage Move MarkAsEditorOnlySubobject to ActorComponent so it works for all components and not just primitive ones Change 3129103 on 2016/09/16 by Marc.Audy Fix initialization order CIS warning Change 3129361 on 2016/09/16 by Dan.Reynolds Fixes to QASoundWaveProcedural.h Change 3129994 on 2016/09/19 by Thomas.Sarkanen Skeletal mesh to Static mesh conversion Added feature to convert selected actors' meshes into static meshes. Supports static and skeletal meshes. Added extension points to all Persona-based editors so their toolbars can be overriden with context about the editor itself. Added IHasPersonaToolkit interface that all of these editors implement. Added toolbar button to each Persona-based editor. Added level editor right-click menu option. Added CPU skinning path for cloth sections (non-SIMD for now). Moved CPU skinning flag from UDebugSkelMeshComponent into USkinnedMeshComponent. Moved a few structures around so CPU skinned renderdata is more readily exposed. #jira UE-35549 - Convert skel mesh on specific anim frame to StaticMesh Change 3130008 on 2016/09/19 by Benn.Gallagher Fixed crash when creating a destructible mesh from a speed tree mesh. The materials are incompatible - after discussion decided to report the error to the user and bail on making the destructible #jira UE-3687 Change 3130009 on 2016/09/19 by Thomas.Sarkanen Fixed static analysis warnings in Persona and AnimationBlueprintEditor Also moved a bool check inside (original line number for the warning led me to that code instead, but thought it was worth fixing anyways). Change 3130012 on 2016/09/19 by Thomas.Sarkanen CIS fix (implcit use of copy constructor) Change3130016on 2016/09/19 by Thomas.Sarkanen Mac CIS fix - forward declare some classes. Change 3130027 on 2016/09/19 by Thomas.Sarkanen Fix shadow variables found with Clang Change 3130044 on 2016/09/19 by Jurre.deBaare Improved Texture Merging using the Merge Actors Tool #feature added simple binning algorithm to be used with texture importance values #misc small array indexing copy-paste error #jira UE-33823 Change 3130068 on 2016/09/19 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3129803 Change 3130181 on 2016/09/19 by Jurre.deBaare G++ compile errors #fix array enum size requires cast to be valid Change 3130182 on 2016/09/19 by Jurre.deBaare Remove FColor operator after feedback from Marc, assuming color order is indeed icky and can tackle the problem differently Change 3130250 on 2016/09/19 by Marc.Audy Fix flag check indicated by static analysis Change 3130256 on 2016/09/19 by Benn.Gallagher Changed "Create Physics Asset" context menu options to allow creation without assigning the physics asset to the selected mesh to make it easier to set up capsule shadows. #jira UE-34796 Change 3130267 on 2016/09/19 by Marc.Audy Post integration WEX fixups for GameMode and FAudioDevice::CreateComponent changes Change 3130551 on 2016/09/19 by Ben.Zeigler Change WEX OnlineSubsystem plugin to exactly match Engine one with GameMode refactors, no functionaly change but this should make merging easier Change 3130564 on 2016/09/19 by Jurre.deBaare More CIS fixes Change 3130572 on 2016/09/19 by Ben.Zeigler #jira UE-36142 Fix 1v1 and 2v2 game mode references, they were always wrong but are now being cooked properly with the game mode changes Change 3130586 on 2016/09/19 by Ben.Zeigler #jira UE-36124 Fix orion crash, the class layout of OrionGameState_MOBA differed between BlueprintContext and OrionGame modules because of the server perf define being different Change 3130587 on 2016/09/19 by Martin.Wilson Add start time to Montage_Play and PlaySlotAnimationAsDynamicMontage #jira UE-34798 Change 3130694 on 2016/09/19 by Ben.Zeigler #jira UE-35424 Restore BrushComponent to the 4.13 behavior for computing editor only, as they set AlwaysLoadOnClient/Server to false even if they're not editor only unlike other primitive components Change 3130700 on 2016/09/19 by Ben.Zeigler #jira UE-36141 Fix it so PlayerCanRestart is called before restarting player on initial login, to match behavior when requesting a restart or match starting. This is a bug fix in the core code that UT was working around originally Change 3130778 on 2016/09/19 by Dan.Reynolds WIP Content update for external referencing Change 3130812 on 2016/09/19 by Marc.Audy No longer use inconsistently applied bWantsBeginPlay #jira UE-21048 Change 3130876 on 2016/09/19 by Richard.Hinckley Fixing comments for documentation purposes. Change 3131076 on 2016/09/19 by Marc.Audy PR #2775: Make WorldContextObj arguments const pointers (Contributed by jorgenpt) #jira UE-35625 Change 3131102 on 2016/09/19 by Richard.Hinckley Fixing typo that slipped through. Change 3131254 on 2016/09/19 by Ben.Zeigler #jira UE-36162 Remove bad game mode reference Change 3131396 on 2016/09/19 by Marc.Audy Undo CL# 3125974 to fix Fortnite crash until investigation can be done #jira -UE-36164 Change 3131846 on 2016/09/20 by Thomas.Sarkanen Recording now functional again in blendspace editor Blendspaces now use the anim editor base. Anim editor base now has the option of a scrollable or non-scrollable widget area. Blendspaces use the non-scrollable one as before. Scrub widget now seperates the concepts of frames and scrub cursor. This is to allow blendspaces to still use scrubbing when they use normalized time. Removed PURE_VIRTUAL from SAnimEditorBase as it is not a UObject class. #jira UE-35843 - Missing record option for Blendspaces Change 3131921 on 2016/09/20 by Thomas.Sarkanen Re-added anim slot manager tab Anim slot manager was not added back into the standalone editors when they were split up. #jira UE-35954 - Anim Slot Manager opens up to unrecognized tab Change 3131922 on 2016/09/20 by Thomas.Sarkanen Added 'dirty' indicator to asset shortcut bar #jira UE-36015 - No 'dirty' indicator in anim asset shortcut bar Change 3131950 on 2016/09/20 by Thomas.Sarkanen Animation stepping now functions as it did previously Recent changes to deal with different frame counts left off an epsilon in the frame increment/decrement logic. Re-instating the epsilon fixes this. #jira UE-36172 - The To Next button in the Animation timeline doesn't work consistently Change 3131953 on 2016/09/20 by james.cobbett Updating test assets. Change 3132241 on 2016/09/20 by Martin.Wilson Fix crash when importing a pose to pose asset. #jira UE-36122 Change 3132417 on 2016/09/20 by Thomas.Sarkanen Fixed crash when anim instance is set to NULL when URO is turned on (and GC occurs) A dangling pointer to the UID array on the instance was hanging around. We now make sure to clear this when necessary. #jira UE-36182 - Fornite cooked crashed when hitting a husk near/on a chest - CurveToCopyFrom.IsValid() Change 3132790 on 2016/09/20 by Ori.Cohen Ensure that physics handle automatically wakes up any object it's grabbing on release. Also fix editor case where moving camera grabs component #JIRA UE-35257 Change 3132795 on 2016/09/20 by Ori.Cohen Fix typo where enable swing drive was used for both swing and twist. #JIRA UE-35634 Change 3132838 on 2016/09/20 by Ori.Cohen Move flush deferred actor to EndPhysics #JIRA UE-35899 Change 3133088 on 2016/09/20 by Ori.Cohen Back out defer flush change. This requires more thought. Change 3133185 on 2016/09/20 by Wes.Hunt QoS Analytics providers now use the real final Data Router URL #jira UE-30655 Change 3133262 on 2016/09/20 by Wes.Hunt HttpServiceTracker now uses UserID fields that match what we expect for all other apps. Part of #jira UE-33354. Change 3133266 on 2016/09/20 by Wes.Hunt Make anonymous analytics UserID match format expected by the backend to remove ambiguity. Part of #jira UE-33354. Change 3133277 on 2016/09/20 by Chris.Evans !N Pose asset test Change3133504on 2016/09/20 by dan.reynolds Updating WIP Test Content Change3133761on 2016/09/21 by Thomas.Sarkanen Fixed 100% crash when killing a husk Interpolation was still getting performed when we had an invalid UID container. We now check this before kicking off a task. #jira UE-36203 - Fornite cooked crashed when killing a husk and jumping backwards Change 3133766 on 2016/09/21 by Thomas.Sarkanen Fixed crash when compiling animation blueprint when a node outside of the tree evaluation is selected The OnNodeSelected callback was not getting called for deselection when the node could not be found (i.e. was NULL). Removed NULL check as it is valid to call. ALso added comment warning that the passed in runtime node can be NULL. #jira UE-35974 - Crash in FSkeletalControlEditMode when compiling an anim blueprint Change 3133774 on 2016/09/21 by Danny.Bouimad Translation Pose Driver test assets content/animation/posedrivertests Change 3133796 on 2016/09/21 by Thomas.Sarkanen Added metadata to remove "reset to default" button for certain properties Allows removal of the reset button without a cumbersome details customization. Fixes crash where a parent struct of an editfixedsize array was reset. #jira UE-36109 - Crash when resetting shape properties on a BodySetup in PhAT Change 3133831 on 2016/09/21 by Jurre.deBaare Vert Color Background not contained to Asset's Viewport #fix Added a way to directly set the visibility of the floor/environment in the static mesh editor #jira UE-35052 Change 3133832 on 2016/09/21 by Jurre.deBaare Geometry Cache asset will stop animating when Elapsed Time exceeds an excessively high number #fix set UI/clamp min/max for playback speed (-512 - 512x playback speed) and start offset (-14400 - 14400, 4 hours) and clamp at runtime as well #jira UE-34629 Change 3133833 on 2016/09/21 by Jurre.deBaare Geometry Cache asset will continue to loop when running in reverse when Loop is turned off and Elapsed Time is has reached 0 #fix do not wrap around for non-looping negative sampling times :) #jira UE-34630 Change 3133834 on 2016/09/21 by Jurre.deBaare Merge Actors button is not enabled when selecting assets in the viewport if they are not visible in the Merge Actor window #fix moved selected mesh count functionality so that it is not dependent on the listview being rendered (this is an awesome bug) #jira UE-34303 Static mesh does not show after using "Merge Actors" if the mesh is part of a child actor component that has been added to the blueprint #fix recursively add child actor components to include all static meshes #jira UE-25187 Change 3133835 on 2016/09/21 by Jurre.deBaare Mesh Preview Scene: Remove bottom quad from floor mesh to make viewing from below easier. (in loving memory of Tom Looman) #fix new mesh with removed bottom quad, allowing for see-through from below #jira UE-35022 Change 3133836 on 2016/09/21 by Jurre.deBaare It isn't clear when a profile is added to the Preview Scene Settings #fix selected profile now changes to newly added one #jira UE-33848 Change preview scene profile naming to validate name input in UI instead of PostEditChange #fix added ui feedback for duplicate naming #misc extra checks for having a correct profile name when adding a new profile #jira UE-34078 Adding Preview Scene Profile after Removing One duplicates the name of the last added profile #fix determine correct name by checking existing ones #jira UE-33898 Change 3133838 on 2016/09/21 by Jurre.deBaare Prevent preview scene assets being loaded in game (proper fix) #fix now saving direct FString path to the environment cube map and load them once we ::Get the assetviewer settings #jira UE-36082 Change 3133839 on 2016/09/21 by Jurre.deBaare Moving over UE-35254 from 4.13.1 Change 3133840 on 2016/09/21 by Jurre.deBaare Moving over UE-35639 from 4.13.1 Change 3133844 on 2016/09/21 by Jurre.deBaare Alembic import causing a crash #jira UE-35551 #fix handle the case where there is not hierarchy found for a specific object, in that case just output the identity matrix as object matrix #jira UE-35451 #fix handle case where we imported an empty object in the Geometry cache path #misc alembic importer signature change #misc typo in function signature Change 3133951 on 2016/09/21 by Mieszko.Zielinski Fixed deprecation message on UAIPerceptionComponent::GetPerceivedActors #UE4 Change 3134014 on 2016/09/21 by Jon.Nabozny #rn Ensure the runaway loop counter gets reset when processing parallel animation. #jira UE-33946 Change 3134032 on 2016/09/21 by Jurre.deBaare Remove comments Change 3134100 on 2016/09/21 by James.Golding UE-35300 Support UV traces for UV on BSP Change 3134103 on 2016/09/21 by Lukasz.Furman fixed NavLinkProxy not working correctly in PIE #jira UE-36194 Change 3134104 on 2016/09/21 by James.Golding UE-33004 Use UI commands for PoseEditor, allow keyboard shortcuts Change 3134106 on 2016/09/21 by James.Golding UE-36138 Fix crash in procmesh slicing, avoid creating, and skip processing, sections with no verts Change 3134109 on 2016/09/21 by James.Golding UE-35813 Don't do srgb conversion for proc mesh vertex colors UE-35821 Procedural Mesh component not respecting 'Bound Scale' setting Change 3134145 on 2016/09/21 by Mieszko.Zielinski Fixed persistent BB key changes not getting propagated to child BB assets #UE4 Change 3134296 on 2016/09/21 by Lukasz.Furman fixed navlink's "snap to cheapest area" mode not working correctly with dynamic navmesh copy of CL#3133219Change 3134390 on 2016/09/21 by mason.seay Blueprint for collision bug repro Change 3134517 on 2016/09/21 by Mieszko.Zielinski CIS fix #UE4 Change 3134746 on 2016/09/21 by Ben.Zeigler Documentation and comment cleanup pass for GameMode changes, it's ready for a Doc team pass Change GameStateBase::GetDefaultGameMode to return a const * as it's a CDO that is not safe to modify, and remove Blueprint acessibility as there's no way to make that safe Change 3134850 on 2016/09/21 by Ben.Zeigler Fix PlatformShowcase warnings Change 3134852 on 2016/09/21 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3134107 Change 3134853 on 2016/09/21 by Marc.Audy Resolve of reimport portions Change 3134857 on 2016/09/21 by Marc.Audy Fixes related to show inner properties for Map and Set now that Dev-Editor has made it to Dev-Framework Change 3135002 on 2016/09/21 by Ori.Cohen Fix compiler errors Change 3135147 on 2016/09/21 by dan.reynolds AEOverview Test WIP Update Change 3135168 on 2016/09/21 by Wes.Hunt Edigrate of CL3135131: EngineAnalytics uses EngineVersion once again instead of BuildVersion, which doesn't contain major.minor.hotfix info. #jira UE-36211 Change 3135216 on 2016/09/21 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3135156 Change 3135238 on 2016/09/21 by Aaron.McLeran UE-36288 Fixing concurrency resolution stop quietest Change 3135257 on 2016/09/21 by Ben.Zeigler Fix Orion version of OnlineGameFramework plugin Change 3135258 on 2016/09/21 by Ben.Zeigler Other Orion GameMode fixes Change 3135290 on 2016/09/21 by dan.reynolds AEOverview test map skeleton complete with comments per Nick BB request Change 3135323 on 2016/09/21 by dan.reynolds Update to AEOverview test maps Change 3135385 on 2016/09/21 by Marc.Audy Fix static analysis warnings in automation tests Change 3135634 on 2016/09/22 by Thomas.Sarkanen Remove duplicated details customization Now we only have one customization that both 'old' Persona and the skeletal mesh editor can use. Change 3135660 on 2016/09/22 by Thomas.Sarkanen CIS fix: Fixed deleted file still being included. Change 3135949 on 2016/09/22 by Thomas.Sarkanen Fixed (another) crash with invalid curve data when an anim instance is GCed Invalidated cached curve as it can hold onto a reference to anim instance data. Also added a check for valididty in the non-parallel eval, non-interpolation case. #jira UE-36292 - Fortnite Editor Crashed when shooting a husk during defense phase - CurveToCopyFrom.IsValid() [CL 3136620 by Marc Audy in Main branch]
1819 lines
68 KiB
C++
1819 lines
68 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AssetToolsPrivatePCH.h"
|
|
#include "ObjectTools.h"
|
|
#include "PackageTools.h"
|
|
#include "AssetRegistryModule.h"
|
|
#include "DesktopPlatformModule.h"
|
|
#include "AssetToolsModule.h"
|
|
#include "MainFrame.h"
|
|
#include "ContentBrowserModule.h"
|
|
#include "ReferencedAssetsUtils.h"
|
|
#include "SPackageReportDialog.h"
|
|
#include "EngineAnalytics.h"
|
|
#include "IAnalyticsProvider.h"
|
|
#include "MessageLog.h"
|
|
#include "UnrealExporter.h"
|
|
#include "SNotificationList.h"
|
|
#include "NotificationManager.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "AssetTools"
|
|
|
|
FAssetTools::FAssetTools()
|
|
: 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_DataAsset) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DataTable) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DestructibleMesh) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DialogueVoice) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DialogueWave) );
|
|
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_ForceFeedbackEffect) );
|
|
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_MaterialInstanceConstant(BlendablesCategoryBit)) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_MaterialInterface) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_MaterialParameterCollection) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_MorphTarget) );
|
|
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_ReverbEffect) );
|
|
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_SoundAttenuation) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundConcurrency));
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundBase) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundClass) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundCue) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundMix) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SoundWave) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_StaticMesh) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Texture) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Texture2D) );
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureCube) );
|
|
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) );
|
|
|
|
// 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.
|
|
|
|
if ( UEditorEngine::IsUsingWorldAssets() )
|
|
{
|
|
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_World) );
|
|
}
|
|
}
|
|
|
|
FAssetTools::~FAssetTools()
|
|
{
|
|
|
|
}
|
|
|
|
void FAssetTools::RegisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& NewActions)
|
|
{
|
|
AssetTypeActionsList.Add(NewActions);
|
|
}
|
|
|
|
void FAssetTools::UnregisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& ActionsToRemove)
|
|
{
|
|
AssetTypeActionsList.Remove(ActionsToRemove);
|
|
}
|
|
|
|
void FAssetTools::GetAssetTypeActionsList( TArray<TWeakPtr<IAssetTypeActions>>& OutAssetTypeActionsList ) const
|
|
{
|
|
for (auto ActionsIt = AssetTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
|
|
{
|
|
OutAssetTypeActionsList.Add(*ActionsIt);
|
|
}
|
|
}
|
|
|
|
TWeakPtr<IAssetTypeActions> FAssetTools::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;
|
|
}
|
|
|
|
EAssetTypeCategories::Type FAssetTools::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 FAssetTools::FindAdvancedAssetCategory(FName CategoryKey) const
|
|
{
|
|
if (const FAdvancedAssetCategory* ExistingCategory = AllocatedCategoryBits.Find(CategoryKey))
|
|
{
|
|
return ExistingCategory->CategoryType;
|
|
}
|
|
else
|
|
{
|
|
return EAssetTypeCategories::Misc;
|
|
}
|
|
}
|
|
|
|
void FAssetTools::GetAllAdvancedAssetCategories(TArray<FAdvancedAssetCategory>& OutCategoryList) const
|
|
{
|
|
AllocatedCategoryBits.GenerateValueArray(OutCategoryList);
|
|
}
|
|
|
|
void FAssetTools::RegisterClassTypeActions(const TSharedRef<IClassTypeActions>& NewActions)
|
|
{
|
|
ClassTypeActionsList.Add(NewActions);
|
|
}
|
|
|
|
void FAssetTools::UnregisterClassTypeActions(const TSharedRef<IClassTypeActions>& ActionsToRemove)
|
|
{
|
|
ClassTypeActionsList.Remove(ActionsToRemove);
|
|
}
|
|
|
|
void FAssetTools::GetClassTypeActionsList( TArray<TWeakPtr<IClassTypeActions>>& OutClassTypeActionsList ) const
|
|
{
|
|
for (auto ActionsIt = ClassTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
|
|
{
|
|
OutClassTypeActionsList.Add(*ActionsIt);
|
|
}
|
|
}
|
|
|
|
TWeakPtr<IClassTypeActions> FAssetTools::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 FAssetTools::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* FAssetTools::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 = 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;
|
|
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
|
|
FAssetTools::OnNewCreateRecord(AssetClass, false);
|
|
|
|
// Mark the package dirty...
|
|
Pkg->MarkPackageDirty();
|
|
}
|
|
|
|
return NewObj;
|
|
}
|
|
|
|
UObject* FAssetTools::CreateAsset(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* FAssetTools::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* FAssetTools::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 DuplicateAsset(SaveAssetName, SavePackagePath, OriginalObject);
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
UObject* FAssetTools::DuplicateAsset(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject)
|
|
{
|
|
// 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;
|
|
UObject* NewObject = ObjectTools::DuplicateSingleObject(OriginalObject, PGN, ObjectsUserRefusedToFullyLoad);
|
|
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
|
|
FAssetTools::OnNewCreateRecord(NewObject->GetClass(), true);
|
|
}
|
|
|
|
return NewObject;
|
|
}
|
|
|
|
void FAssetTools::RenameAssets(const TArray<FAssetRenameData>& AssetsAndNames) const
|
|
{
|
|
AssetRenameManager->RenameAssets(AssetsAndNames);
|
|
}
|
|
|
|
TArray<UObject*> FAssetTools::ImportAssets(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;
|
|
}
|
|
|
|
void FAssetTools::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.Add(TPairInitializer<FString, FString>(Filename, DestinationPath));
|
|
}
|
|
}
|
|
}
|
|
|
|
TArray<UObject*> FAssetTools::ImportAssets(const TArray<FString>& Files, const FString& RootDestinationPath, UFactory* SpecifiedFactory, bool bSyncToBrowser ) const
|
|
{
|
|
TArray<UObject*> ReturnObjects;
|
|
TMap< FString, TArray<UFactory*> > ExtensionToFactoriesMap;
|
|
|
|
FScopedSlowTask SlowTask(Files.Num() + 3, LOCTEXT("ImportSlowTask", "Importing"));
|
|
SlowTask.MakeDialog();
|
|
|
|
// 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
|
|
UFactory::ResetState();
|
|
|
|
SlowTask.EnterProgressFrame();
|
|
|
|
TArray<TPair<FString, FString>> FilesAndDestinations;
|
|
ExpandDirectories(Files, RootDestinationPath, FilesAndDestinations);
|
|
|
|
SlowTask.EnterProgressFrame(1, LOCTEXT("Import_DeterminingImportTypes", "Determining asset types"));
|
|
|
|
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)))
|
|
{
|
|
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 )
|
|
{
|
|
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;
|
|
|
|
// 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 )
|
|
{
|
|
const FString& Filename = FilesAndDestinations[FileIdx].Key;
|
|
const FString& DestinationPath = 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;
|
|
//When doing automationtest we can setup factory option and we need to make sure we use the specified one
|
|
if (GIsAutomationTesting && 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 )
|
|
{
|
|
UClass* ImportAssetType = Factory->SupportedClass;
|
|
bool bImportSucceeded = false;
|
|
bool bImportWasCancelled = false;
|
|
FDateTime ImportStartTime = FDateTime::UtcNow();
|
|
|
|
FString Name = ObjectTools::SanitizeObjectName(FPaths::GetBaseFilename(Filename));
|
|
FString PackageName = DestinationPath + TEXT("/") + Name;
|
|
|
|
// 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 ) );
|
|
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 (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
|
|
{
|
|
// 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);
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
ImportAssetType = Factory->ResolveSupportedClass();
|
|
UObject* Result = Factory->ImportObject(ImportAssetType, Pkg, FName(*Name), RF_Public | RF_Standalone, Filename, nullptr, bImportWasCancelled);
|
|
|
|
// 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 ) );
|
|
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.
|
|
}
|
|
}
|
|
|
|
SlowTask.EnterProgressFrame(1);
|
|
|
|
// 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 ) )
|
|
{
|
|
FAssetTools::Get().SyncBrowserToAssets(ReturnObjects);
|
|
}
|
|
|
|
return ReturnObjects;
|
|
}
|
|
|
|
void FAssetTools::CreateUniqueAssetName(const FString& InBasePackageName, const FString& InSuffix, FString& OutPackageName, FString& OutAssetName) const
|
|
{
|
|
const FString SanitizedBasePackageName = PackageTools::SanitizePackageName(InBasePackageName);
|
|
|
|
const FString PackagePath = FPackageName::GetLongPackagePath(SanitizedBasePackageName);
|
|
const FString BaseAssetNameWithSuffix = FPackageName::GetLongPackageAssetName(SanitizedBasePackageName) + InSuffix;
|
|
const FString SanitizedBaseAssetName = ObjectTools::SanitizeObjectName(BaseAssetNameWithSuffix);
|
|
|
|
int32 IntSuffix = 1;
|
|
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 FAssetTools::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 FAssetTools::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))
|
|
{
|
|
// Forcibly disable compile on load in case we are loading old blueprints that might try to update/compile
|
|
TGuardValue<bool> DisableCompileOnLoad(GForceDisableBlueprintCompileOnLoad, true);
|
|
|
|
// Try and load that package
|
|
UPackage* TempPackage = LoadPackage(nullptr, *TempFileName, LOAD_ForDiff);
|
|
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 FAssetTools::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 FAssetTools::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 FAssetTools::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 FAssetTools::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::CreateRaw(this, &FAssetTools::PerformMigratePackages, PackageNamesToMigrate)
|
|
);
|
|
}
|
|
else
|
|
{
|
|
// Assets are already discovered, perform the migration now
|
|
PerformMigratePackages(PackageNamesToMigrate);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FAssetTools::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 FAssetTools::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);
|
|
}
|
|
}
|
|
|
|
FAssetTools& FAssetTools::Get()
|
|
{
|
|
FAssetToolsModule& Module = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
|
|
return static_cast<FAssetTools&>(Module.Get());
|
|
}
|
|
|
|
void FAssetTools::SyncBrowserToAssets(const TArray<UObject*>& AssetsToSync)
|
|
{
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
|
|
}
|
|
|
|
void FAssetTools::SyncBrowserToAssets(const TArray<FAssetData>& AssetsToSync)
|
|
{
|
|
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
|
|
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
|
|
}
|
|
|
|
bool FAssetTools::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 FAssetTools::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( !PackageTools::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,
|
|
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);
|
|
}
|
|
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 FAssetTools::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::CreateRaw(this, &FAssetTools::MigratePackages_ReportConfirmed, ReportPackageNames);
|
|
SPackageReportDialog::OpenPackageReportDialog(ReportMessage, ReportPackageNames, OnReportConfirmed);
|
|
}
|
|
}
|
|
|
|
void FAssetTools::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
|
|
{
|
|
const FString DestFilename = SrcFilename.Replace(*FPaths::GameContentDir(), *DestinationFolder);
|
|
|
|
bool bFileOKToCopy = true;
|
|
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;
|
|
}
|
|
}
|
|
|
|
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 FAssetTools::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 FAssetTools::FixupReferencers(const TArray<UObjectRedirector*>& Objects) const
|
|
{
|
|
AssetFixUpRedirectors->FixupReferencers(Objects);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|