Files
UnrealEngineUWP/Engine/Source/Developer/AssetTools/Private/AssetTools.cpp
Ben Marsh bf66aaa497 Copying //UE4/Release-Staging-4.12 to //UE4/Dev-Main (Source: //UE4/Release-4.12 @ 2955635)
==========================
MAJOR FEATURES + CHANGES
==========================

Change 2955635 on 2016/04/26 by Max.Chen

	Sequencer: Fix filtering so that folders that contain filtered nodes will also appear.

	#jira UE-28213

Change 2955617 on 2016/04/25 by Dmitriy.Dyomin

	Better fix for: Post processing rendering artifacts Nexus 6
	this device on Android 5.0.1 does not support BGRA8888 texture as a color attachment
	#jira: UE-24067

Change 2955522 on 2016/04/25 by Max.Chen

	Sequencer: Fix crash when resolving object guid and context is null.

	#jira UE-29916

Change 2955504 on 2016/04/25 by Alexis.Matte

	#jira UE-29926
	Fix build error for SplineComponent. I just move variable under #if !UE_BUILD_SHIPPING instead #if WITH_EDITORONLY_DATA to fix all build flavor, please feel free to adjust according to what the initial fix was suppose to do.

Change 2955500 on 2016/04/25 by Dan.Oconnor

	Integration of 2955445 from Dev-BP
	#jira UE-29012

Change 2955234 on 2016/04/25 by Lina.Halper

	Fixed tool tip of twist node

	#jira : UE-29907

Change 2955211 on 2016/04/25 by Ben.Marsh

	Exclude all plugins which aren't required for a project (ie. don't have any content or modules for the current target) from its target receipt. Prevents dependencies on .uplugin files whose dependencies are otherwise compiled out. Re-enable PS4Media plugin by default.

	#jira UE-29842

Change 2955155 on 2016/04/25 by Jamie.Dale

	Fixed an issue where text committed via a focus loss might not display the correct text if it was changed during commit

	#jira UE-28756

Change 2955144 on 2016/04/25 by Jamie.Dale

	Fixed a case where editable text controls would fail to select their text when focused

	There was an order of operations issue between the options to select all text and move the cursor to the end of the document, which caused the cursor move to happen after the select all, and undo the selection. The order of these operations has now been flipped.

	#jira UE-29818
	#jira UE-29772

Change 2955136 on 2016/04/25 by Chad.Taylor

	Merging to 4.12:

	Morpheus latency fix. Late update tracking frame was getting unnecessarily buffered an extra frame on the RHI thread. Removed buffering and the issue is fixed.

	#jira UE-22581

Change 2955134 on 2016/04/25 by Lina.Halper

	Removed code that blocks moving actor when they don't have physics asset

	#jira : UE-29796
	#code review: Benn.Gallagher

Change 2955130 on 2016/04/25 by Zak.Middleton

	#ue4 - (4.12) Don't reject low distance MTD, it could cause us to not process some valid overlaps.
	(copy of 2955001 in Main)

	#jira UE-29531
	#lockdown Nick.Penwarden

Change 2955098 on 2016/04/25 by Marc.Audy

	Don't spawn a child actor on the client if the server is going to have created one and be replicating it to the client
	#jira UE-7539

Change 2955049 on 2016/04/25 by Richard.TalbotWatkin

	Changes to how SplineComponents debug render. Added a SetDrawDebug method to control whether a spline is rendered. Also extended the facility to non-editor builds.
	#jira UE-29753 - Add ability to display a SplineComponent in-game

Change 2955040 on 2016/04/25 by Chris.Gagnon

	Fixed Initializer Order Warning in hot reload ctor.

	#jira UE-28811, UE-28960

Change 2954995 on 2016/04/25 by Marc.Audy

	Make USceneComponent::Pre/PostNetReceive and PostRepNotifies protected instead of private so that subclasses can implement replication behaviors
	#jira UE-29909

Change 2954970 on 2016/04/25 by Peter.Sauerbrei

	fix for openwrite with O_APPEND flag
	#jira UE-28417

Change 2954917 on 2016/04/25 by Chris.Gagnon

	Moved a desired change from Main to 4.12

	Added input settings to:
	- control if the viewport locks the mouse on acquire capture.
	- control if the viewport acquires capture on the application launch (first window activate).

	#jira UE-28811, UE-28960
	parity with 4.11 (UE-28811, UE-28960 would be reintroduced without this)

Change 2954908 on 2016/04/25 by Alexis.Matte

	#jira UE-29478
	Prevent modal dialog to use 100% of a core

Change 2954888 on 2016/04/25 by Marcus.Wassmer

	Fix compile issue with chinese locale
	#jira UE-29708

Change 2954813 on 2016/04/25 by Lina.Halper

	Fix when not re-validating the correct asset

	#jira : UE-29789
	#code review: Martin.Wilson

Change 2954810 on 2016/04/25 by mason.seay

	Updated map to improve coverage

	#jira UE-29618

Change 2954785 on 2016/04/25 by Max.Chen

	Sequencer: Always spawn sequencer spawnables. Disregard collision settings.

	#jira UE-29825

Change 2954781 on 2016/04/25 by mason.seay

	Test map for Audio Occlusion trace channels

	#jira UE-29618

Change 2954684 on 2016/04/25 by Marc.Audy

	Add GetIsReplicated accessor to AActor
	Deprecate specific GameplayAbility class implementations that was exposing bReplicates
	#jira UE-29897

Change 2954675 on 2016/04/25 by Alexis.Matte

	#jira UE-25430
	Light Intensity value in FBX is a ratio. So I just multiply the default intensity value by the ratio to have something closer to the look in the DCCs

Change 2954669 on 2016/04/25 by Alexis.Matte

	#jira UE-29507
	Import of rigid mesh animation is broken

Change 2954579 on 2016/04/25 by Ben.Marsh

	Temporarily stop the PS4Media plugin being enabled by default, so the UE4Game built for the binary release doesn't depend on it. Will implement whitelist/blacklist for platforms later.

	#jira UE-29842

Change 2954556 on 2016/04/25 by Taizyd.Korambayil

	#jira UE-29877 Setup ThirdPersonCharacter based on correct Code Class

Change 2954552 on 2016/04/25 by Taizyd.Korambayil

	#jira UE-29877 Deleting BP class

Change 2954498 on 2016/04/25 by Ryan.Gerleve

	Fix for remote player controllers reporting that they're actually local player controllers after a seamless travel on the server.
	Transition actors to the new level in a second pass after non-transitioning actors are handled.

	#jira UE-29213

Change 2954446 on 2016/04/25 by Max.Chen

	Sequencer: Fixed spawning actors with instance or multiple owned components

	  - Also fixed issue where recorded actors were sometimes set as transient, meaning they didn't get saved

	#jira UE-29774, UE-29859

Change 2954430 on 2016/04/25 by Marc.Audy

	Don't schedule a tick function with a tick interval that was disabled while it was pending rescheduling
	#jira UE-29118
	#jira UE-29747

Change 2954292 on 2016/04/25 by Richard.TalbotWatkin

	Replicated from //UE4/Dev-Editor CL 2946363 (by Frank.Fella)

	CurveEditorViewportClient - Bounds check when box selecting.  Prevents crashing when the box is outside the viewport.
	#jira UE-29265 - Crash when drag selecting curve keys in matinee

Change 2954262 on 2016/04/25 by Graeme.Thornton

	Fixed a editor crash when destroying linkers half way through a package EndLoad

	#jira UE-29437

Change 2954239 on 2016/04/25 by Marc.Audy

	Fix error message
	#jira UE-00000

Change 2954177 on 2016/04/25 by Dmitriy.Dyomin

	Fixed: Hidden surface removal is not enabled on PowerVR Android devices
	#jira UE-29871

Change 2954026 on 2016/04/24 by Josh.Adams

	[Somehow most files got unchecked in my previous checkin, grr]
	- ProtoStar content/config updates (enabled TAA in the levels, disabled es2 shaders, hides the Unbuilt lighting warning on Android)
	#lockdown nick.penwarden
	#jira UE-29863

Change 2954025 on 2016/04/24 by Josh.Adams

	- ProtoStar content/config updates (enabled TAA in the levels, disabled es2 shaders, hides the Unbuilt lighting warning on Android)
	#lockdown nick.penwarden
	#jira UE-29863

Change 2953946 on 2016/04/24 by Max.Chen

	Sequencer: Fix crash on undo of a sub section.

	#jira UE-29856

Change 2953898 on 2016/04/23 by mitchell.wilson

	#jira UE-29618 Adding subscene_001 sequence for nonlinear workflow testing

Change 2953859 on 2016/04/23 by Maciej.Mroz

	Merged from Dev-Blueprints 2953858
	#jira UE-29790 Editor crashes when opening KiteDemo

Change 2953764 on 2016/04/23 by Max.Chen

	Sequencer: Remove "Experimental" tag on the Level Sequence Actor

	#jira UETOOl-625

Change 2953763 on 2016/04/23 by Max.Chen

	Cinematics: Change text to "Edit Existing Cinematics"

	#jira UE-29102

Change 2953762 on 2016/04/23 by Max.Chen

	Sequencer: Follow up time slider hit testing fix. Don't hit test the selection range if it's empty. This was causing false positives when hovering close to the ranges.

	#jira UE-29658

Change 2953652 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Workaround driver bugs wrt texture format caps
	#jira UE-28140

Change 2953596 on 2016/04/22 by Marcus.Wassmer

	#jira UE-20276
	Merging dual normal clearcoat shading model.
	2863683
	2871229
	2876362
	2876573
	2884007
	2901595

Change 2953594 on 2016/04/22 by Chris.Babcock

	Disable crash handler for VulkanRHI on Android to prevent sig11 on loading driver
	#jira UE-29851
	#ue4
	#android

Change 2953520 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Enable deferred resource deletion
	- Added one resource heap per memory type
	- Improved DumpMemory()
	- Added ensures for missing format features
	#jira UE-28140

Change 2953459 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29748 Resaved Maps to Fix EC Build Warnings
	#jira UE-29744

Change 2953448 on 2016/04/22 by Ryan.Gerleve

	Fix Mac/Linux compile.

	#jira UE-29545

Change 2953311 on 2016/04/22 by Ryan.Gerleve

	Fix for infinite hang when loading a replay from within an actor tick while demo.AsyncLoadWorld is false. LoadMap for the replay is now deferred using the existing PendingNetGame mechanism.
	Added virtual UPendingNetGame::LoadMapCompleted function so that the base PendingNetGame and DemoPendingNetGame can have different behavior.
	To keep things simpler, also parse all replay metadata and streaming levels after the LoadMap call.

	#jira UE-29545

Change 2953219 on 2016/04/22 by mason.seay

	Test map for show collision features

	#jira UE-29618

Change 2953199 on 2016/04/22 by Phillip.Kavan

	[UE-29449] Fix InitProperties() optimization for Blueprint class instances when array property values differ in size.

	change summary:
	- improved UBlueprintGeneratedClass::BuildCustomArrayPropertyListForPostConstruction() by continuing to emit only delta entries for array values that exceed the default array value's size; previously we emitted a NULL in this case to signal a need to initialize all remaining array values in InitProperties(), even if they didn't differ from the default value of the inner property (which in most cases would already have been set at construction time, and thus potentially incurred a redundant copy iteration for each entry)
	- modified FObjectInitializer::InitArrayPropertyFromCustomList() to no longer reset the array value on the instance prior to initialization
	    - added code to properly resize the array on the instance prior to initialization (if it differs in size from the default array value)
	    - removed code that handled a NULL property value in the custom property list stream (this is no longer necessary, see above)
	- modified FObjectInitializer::InitProperties() to restore the post-construction optimization for Blueprint class instances (back to being enabled by default)

	#jira UE-29449

Change 2953195 on 2016/04/22 by Max.Chen

	Sequencer: Fix crash in actor reference track in the cached guid to actor map.

	#jira UE-27523

Change 2953124 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Increase temp frame buffer
	#jira UE-28140

Change 2953121 on 2016/04/22 by Chris.Babcock

	Rebuilt lighting for all levels
	#jira UE-29809

Change 2953073 on 2016/04/22 by mason.seay

	Test assets for notifies in animation composites and montages

	#jira UE-29618

Change 2952960 on 2016/04/22 by Richard.TalbotWatkin

	Changed eye dropper operation so that LMB click selects a color, and pressing Esc cancels the selection and restores the old color.
	#jira UE-28410 - Eye dropper selects color without clicking

Change 2952934 on 2016/04/22 by Allan.Bentham

	Ensure pool's refractive index >= 1
	#jira UE-29777

Change 2952881 on 2016/04/22 by Jamie.Dale

	Better fix for UE-28560 that doesn't regress thumbnail rendering

	We now just silence the warning if dealing with an inactive world.

	#jira UE-28560

Change 2952867 on 2016/04/22 by Thomas.Sarkanen

	Fix issues with matinee-controlled anim instances

	Regression caused by us no longer saving off the anim sequence between updates.

	#jira UE-29812 - Protostar Neutrino spawns but does not Animate or move.

Change 2952826 on 2016/04/22 by Maciej.Mroz

	Merged from Dev-Blueprints 2952820

	#jira UE-28895 Nativizing a blueprint project causes the next non-nativizing package attempt to fail

Change 2952819 on 2016/04/22 by Josh.Adams

	- Fixed crash in a Vulkan shader printout
	#lockdown nick.penwarden
	#jira UE-29820

Change 2952817 on 2016/04/22 by Rolando.Caloca

	UE4.12 - vk - Revert back to simple layouts
	#jira UE-28140

Change 2952792 on 2016/04/22 by Jamie.Dale

	Removed some code that caused worlds loaded by the Content Browser to be initialized before they were ready

	Supposedly this code existed for world thumbnail rendering, however only the active editor world generates a thumbnail, so initializing other worlds wasn't having any effect and thumbnails look identical to before.

	#jira UE-28560

Change 2952783 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-28477 Resaved Flying Template Map

Change 2952767 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29736 Resaved Map to Fix EC Warnings

Change 2952762 on 2016/04/22 by Allan.Bentham

	Update reflection capture to contain only room5 content.
	#jira UE-29777

Change 2952749 on 2016/04/22 by Taizyd.Korambayil

	#jira UE-29740 Resaved Material and Map to Fix Empty Engine Version Error

Change 2952688 on 2016/04/22 by Martin.Wilson

	Fix for BP notifies not displaying when they derive from an abstract base class

	#jira UE-28556

Change 2952685 on 2016/04/22 by Thomas.Sarkanen

	Fix CIS for non-editor builds

	#jira UE-29308 - Fix crash from GC-ed animation asset

Change 2952664 on 2016/04/22 by Thomas.Sarkanen

	Made up/down behaviour for console history consistent and reverted to old ordering by default

	Pressing up or down now brings up history.
	Sorting can now be optionally bottom-to-top or top-to-bottom. Default behaviour is preserved to what it was before the recent changes.

	#jira UE-29595 - Console autocomplete behavior is non-intuitive / frustrating

Change 2952655 on 2016/04/22 by Jamie.Dale

	Changed the class filter to use an expression evaluator

	This makes it consistent with the other filters in the editor

	#jira UE-29811

Change 2952647 on 2016/04/22 by Allan.Bentham

	Back out changelist 2951539
	#jira UE-29777

Change 2952618 on 2016/04/22 by Benn.Gallagher

	Fixed naming error in rotation multiplier node
	#jira UE-29583

Change 2952612 on 2016/04/22 by Thomas.Sarkanen

	Fix garbage collection and undo/redo issues with anim instance proxy

	UObject-based properties are now cached each update on the proxy and nulled-out outside of evaluate/update phases.
	Moved some initialization code for CurrentAsset/CurrentVertexAnim from the proxy back to the instance (as its is encapsulated there now).

	#jira UE-29308 - Fix crash from GC-ed animation asset

Change 2952608 on 2016/04/22 by Richard.TalbotWatkin

	Changed 'Recently Used Levels' and 'Favorite Levels' to hold long package names instead of absolute paths. This means they are now project-relative and will remain valid even if the project location changes.
	#jira UE-29731 - Editor map recent files are not project relative, leading to missing links when moving projects.

Change 2952599 on 2016/04/22 by Dmitriy.Dyomin

	Disabled vulkan pipeline cache as it causes rendering artifacts right now
	#jira UE-29807

Change 2952540 on 2016/04/22 by Maciej.Mroz

	#jira UE-29787 Obsolete nativized files are never removed
	merged from Dev-Blueprints 2952531

Change 2952372 on 2016/04/21 by Josh.Adams

	- Fixed Vk memory allocations when reusing free pages
	#lockdown nick.penwarden
	#jira ue-29802

Change 2952350 on 2016/04/21 by Eric.Newman

	Added support for UEReleaseTesting backends to Orion and Ocean
	#jira op-3640

Change 2952140 on 2016/04/21 by Dan.Oconnor

	Demoted back to warning to fix regressions in content examples, in main we've added the ability to elevate warnings to errors, but no reason to rush that feature into 4.12
	#jira UE-28971

Change 2952135 on 2016/04/21 by Jeff.Farris

	Fixed issue in PlayerCameraManager where the priority-based sorting of CameraModifiers wasn't sorting properly.
	Manual re-implementation of CL 2948123 in 4.12 branch.
	#jira UE-29634

Change 2952121 on 2016/04/21 by Lee.Clark

	PS4 - 4.12 - Fix staging and deploying of system prxs

	#jira UE-29801

Change 2952120 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Move descriptor allocation to BSS
	#jira UE-21840

Change 2952027 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Fix descriptor sets lifetimes
	- Fix crash with null texture
	#jira UE-28140

Change 2951890 on 2016/04/21 by Eric.Newman

	Updating locked common dependencies for OrionService
	#jira OP-3640

Change 2951863 on 2016/04/21 by Eric.Newman

	Updating locked dependencies for UE 4.12 OrionService
	#jira OP-3640

Change 2951852 on 2016/04/21 by Owen.Stupka

	Fixed meteors destruct location
	#jira UE-29714

Change 2951739 on 2016/04/21 by Max.Chen

	Sequencer: Follow up for integral keys.

	#jira UE-29791

Change 2951717 on 2016/04/21 by Rolando.Caloca

	UE4.12 - Fix shader platform names
	#jira UE-28140

Change 2951714 on 2016/04/21 by Max.Chen

	Sequencer: Fix setting a key if it already exists at the current time.

	#jira UE-29791

Change 2951708 on 2016/04/21 by Rolando.Caloca

	UE4.12 - vk - Separate upload cmd buffer
	#jira UE-28140

Change 2951653 on 2016/04/21 by Marc.Audy

	If a child actor component is destroyed during garbage collection, do not rename, instead clear the caching mechanisms so that a new name is chosen if a new child is created in the future
	Remove now unused bRenameRequired parameter
	#jira UE-29612

Change 2951619 on 2016/04/21 by Chris.Babcock

	Move bCreateRenderStateForHiddenComponents out of WITH_EDITOR
	#jira UE-29786
	#ue4

Change 2951603 on 2016/04/21 by Cody.Albert

	#jira UE-29785
	Revert Github readme page back to original

Change 2951599 on 2016/04/21 by Ryan.Gerleve

	Fix assert when attempting to record a replay when the map has a placed actor that writes replay external data (such as ACharacter)

	#jira UE-29778

Change 2951558 on 2016/04/21 by Chris.Babcock

	Always rename destroyed child actor
	#jira UE-29709
	#ue4

Change 2951552 on 2016/04/21 by James.Golding

	Remove old code for handling 'show collision' in game, uses same method as editor now, fixes hidden meshes showing up in game when doing 'show collision'
	#jira UE-29303

Change 2951539 on 2016/04/21 by Allan.Bentham

	Use screenuv for distortion with ES2/31.
	#jira UE-29777

Change 2951535 on 2016/04/21 by Max.Chen

	We need to test if the hmd is enabled if it exists. Otherwise, this will return true even if we aren't rendering in stereo if there's an hmd plugin loaded.

	#jira UE-29711

Change 2951521 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-29746 Replaced Deprecated Time Handler node in GameLevel_GM

Change 2951492 on 2016/04/21 by Jeremiah.Waldron

	Fix for Android IAP information reporting back incorrectly.
	#jira UE-29776

Change 2951486 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-29741 Updated Infiltrator Demo Project to open with the correct Map

Change 2951450 on 2016/04/21 by Gareth.Martin

	Fix non-editor build
	#jira UE-16525

Change 2951380 on 2016/04/21 by Gareth.Martin

	Fix Landscape layer blend nodes not updating connections correctly when an input is changed from weight/alpha (one input) to height blend (two inputs) or vice-versa
	#jira UE-16525

Change 2951357 on 2016/04/21 by Richard.TalbotWatkin

	Fixed a crash when pushing a new menu leads to a window activation change which would result in the old root menu being dismissed.
	#jira UE-27981 - [CrashReport] Crash When Attempting to Select Variable Type After Clearing the Name Field

Change 2951352 on 2016/04/21 by Richard.TalbotWatkin

	Added slider bar thickness as a new property in FSliderStyle.
	#jira UE-19173 - SSlider is not fully stylable

Change 2951344 on 2016/04/21 by Gareth.Martin

	Fix bounds calculation for landscape splines that was causing the first landscape spline point to be invisible and later points to flicker.
	- Also fixes landscape spline lines not showing up on a flat landscape
	#jira UE-25114

Change 2951326 on 2016/04/21 by Taizyd.Korambayil

	#jira UE-28477 Resaving Maps

Change 2951271 on 2016/04/21 by Jamie.Dale

	Fixed a crash when pasting a path containing a class into the asset view of the Content Browser

	#jira UE-29616

Change 2951237 on 2016/04/21 by Jack.Porter

	Fix black screen on PC due to planar reflections

	#jira UE-29664

Change 2951184 on 2016/04/21 by Jamie.Dale

	Fixed crash in FCurveStructCustomization when no objects were selected for editing

	#jira UE-29638

Change 2951177 on 2016/04/21 by Ben.Marsh

	Fix hot reload from IDE failing when project is up to date. UBT returns an exit code of 2, and any non-zero exit code is treated as an error by Visual Studio. Build.bat was not correctly forwarding on the exit code at all prior to CL 2790858.

	#jira UE-29757

Change 2951171 on 2016/04/21 by Matthew.Griffin

	Fixed issue with Rebuild not working when installed in Program Files (x86)
	The brackets seem to cause lots of problems in combination with the if/else ones
	#jira UE-29648

Change 2951163 on 2016/04/21 by Jamie.Dale

	Changed the text customization to use the property handle functions to get/set the text value

	That ensures that it both transacts and notifies correctly.

	Added new functions to deal with multiple objects selection efficiently with the existing IEditableTextProperty API:
	  - FPropertyHandleBase::SetPerObjectValue
	  - FPropertyHandleBase::GetPerObjectValue
	  - FPropertyHandleBase::GetNumPerObjectValues

	These replace the need to cache the raw pointers.

	#jira UE-20223

Change 2951103 on 2016/04/21 by Thomas.Sarkanen

	Un-deprecated blueprint functions for attachment/detachment

	Renamed functions to <FuncName> (Deprecated).
	Hid functions in the BP context menu so new ones cant be added.

	#jira UE-23216 - "Snap to Target, Keep World Scale" when attaching doesn't work properly if parent is scaled.

Change 2951101 on 2016/04/21 by Allan.Bentham

	Enable mobile HQ DoF
	#jira UE-29765

Change 2951097 on 2016/04/21 by Thomas.Sarkanen

	Standalone games now benefit from parallel anim update if possible

	We now simply use the fact we want root motion to determine if we need to run immediately.

	#jira UE-29431 - Parallel anim update does not work in non-multiplayer games

Change 2951036 on 2016/04/21 by Lee.Clark

	PS4 - Fix WinDualShock working with VS2015

	#jira UE-29088

Change 2951034 on 2016/04/21 by Jack.Porter

	ProtoStar: Removed content not needed by remaining maps, resaved all content to fix version 0 issues

	#jira UE-29666

Change 2950995 on 2016/04/21 by Jack.Porter

	ProtoStar - delete unneeded maps

	#jira UE-29665

Change 2950787 on 2016/04/20 by Nick.Darnell

	SuperSearch - Moving the settings object into a seperate plugin to avoid there needing to be a circular dependency between SuperSearch and UnrealEd.

	#jira UE-29749
	#codeview Ben.Marsh

Change 2950786 on 2016/04/20 by Nick.Darnell

	Back out changelist 2950769 - Going to re-enable super search - about to move the settings into a plugin to prevent the circular reference.

	#jira UE-29749

Change 2950769 on 2016/04/20 by Ben.Marsh

	Comment out editor integration for super search to fix problems with the circular dependencies breaking hot reload and compiling QAGame in binary release.

Change 2950724 on 2016/04/20 by Lina.Halper

	Support for negative scaling for mirroring

	- Merging CL 2950718 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira: UE-27453

Change 2950293 on 2016/04/20 by andrew.porter

	Correcting sequencer test content

	#jira UE-29618

Change 2950283 on 2016/04/20 by Marc.Audy

	Don't route FlushPressedKeys on PIE shut down
	#jira UE-28734

Change 2950071 on 2016/04/20 by mason.seay

	Adjusted translation retargeting on head bone of UE4_Mannequin

	-Needed for anim bp test.  Tested animations and did not see any fallout from change.  If there is, it can be reverted.

	#jira UE-29618

Change 2950049 on 2016/04/20 by Mark.Satterthwaite

	Undo CL #2949690 and instead on Mac where we want to be able to capture videos of gameplay we just insert an intermediate texture as the back-buffer and use a manual blit to the drawable prior to present. This also changes the code to enforce that the back-buffer render-target should never be nil as the code & Metal API itself assumes that this situation cannot occur but it would appear from continued crashes inside PrepareToDraw that it actually can in the field. This will address another potential cause of UE-29006.
	#jira UE-29006
	#jira UE-29140

Change 2949977 on 2016/04/20 by Max.Chen

	Sequencer: Add FieldOfView to default tracks for CameraActor. Add FieldOfView to exclusion list for CineCameraActor.

	#jira UE-29660

Change 2949836 on 2016/04/20 by Gareth.Martin

	Fix landscape components flickering when perfectly flat (bounds size is 0)
	- This often happens for newly created landscapes
	#jira UE-29262

Change 2949768 on 2016/04/20 by Thomas.Sarkanen

	Moving parent & grouped child actors now does not result in deltas being applied twice

	Grouping and attachment now interact correctly.
	Also fixed up according to coding standard.

	Discovered and proposed by David.Bliss2 (Rocksteady).

	#jira UE-29233 - Delta applied twice when moving parent and grouped child actors
	From UDN: https://udn.unrealengine.com/questions/286537/moving-parent-grouped-child-actors-results-in-delt.html

Change 2949759 on 2016/04/20 by Thomas.Sarkanen

	Fix split pins not working as anim graph node inputs

	Limit surface area of this change by only modifying the anim BP compiler. A better version might be to move the call in the general blueprint compiler but it is riskier.

	#jira UE-12326 - Splitting a struct in an Anim Blueprint does not work

Change 2949739 on 2016/04/20 by Thomas.Sarkanen

	Fix layered bone per blend accessed from a struct in the fast-path

	Made sure that the fallback event is always built (logic was still split so if PatchFunctionNamesAndCopyRecordsInto aborted because of some unhandled case if might not have an event to call).
	Covered struct source->array dest case.
	Indicator icon is now built from the copy record itself, ensuring it is accurate to actual runtime data.

	#jira UE-29389 - Fast-Path: Layered Blend per Bone node failing to grab updated values from struct.

Change 2949715 on 2016/04/20 by Max.Chen

	Sequencer: Fix mouse wheel zoom so it defaults to zooming in on the current time/frame. This is a toggleable option in the Editor Preferences (Zoom Position = Current Time or Mouse Position)

	#jira UE-29661

Change 2949712 on 2016/04/20 by Taizyd.Korambayil

	#jira UE-28544 adjusted Player crosshair to be centered

Change 2949710 on 2016/04/20 by Alexis.Matte

	#jira UE-29477
	Pixel Inspector, UI get polish and adding "scene color" inspect property

Change 2949706 on 2016/04/20 by Alexis.Matte

	#jira UE-29475
	#jira UE-29476
	Favorite allow all UProperty to be favorite (the FStruct is now supported)
	Favorite scrollig is auto adjust to avoid scrolling when adding/removing a favorite

Change 2949691 on 2016/04/20 by Mark.Satterthwaite

	Fix typo from previous commit - retain not release...
	#jira UE-29140

Change 2949690 on 2016/04/20 by Mark.Satterthwaite

	Double-buffer the Metal viewport's back-buffer so that we can access the contents of the back-buffer after EndDrawingViewport is called until BeginDrawingViewport is called again on this viewport, this makes it possible to capture movies on Metal.
	#jira UE-29140

Change 2949616 on 2016/04/20 by Marc.Audy

	'Merge' latest version of Vulkan from Dev-Rendering to Release-4.12
	#jira UE-00000

Change 2949572 on 2016/04/20 by Jamie.Dale

	Fixed crash undoing a text property changed caused by a null entry in the array

	#jira UE-20223

Change 2949562 on 2016/04/20 by Alexis.Matte

	#jira UE-29447
	Fix the batch fbx import "not show options" dialog where some option can be different.

Change 2949560 on 2016/04/20 by Alexis.Matte

	#jira UE-28898
	Avoid importing multiple static mesh in the same package

Change 2949547 on 2016/04/20 by Mark.Satterthwaite

	You must use STENCIL_COMPONENT_SWIZZLE  to access the stencil component of a texture - not all APIs can swizzle it into .g automatically.
	#jira UE-29672

Change 2949443 on 2016/04/20 by Allan.Bentham

	Disable sRGB textures when ES31 feature level is set.
	Only use vk's sRGB formats when feature level > ES3_1

	#jira UE-29623

Change 2949428 on 2016/04/20 by Allan.Bentham

	Back out changelist 2949405
	#jira UE-29623

Change 2949405 on 2016/04/20 by Allan.Bentham

	Disable sRGB textures when ES31 feature level is set.
	Only use vk's sRGB formats when feature level > ES3_1

	#jira UE-29623

	Merging using Dev-Mobile_->_Release-4.12

Change 2949391 on 2016/04/20 by Richard.TalbotWatkin

	PIE with multiple windows now starts focused on Client 1, or the server if not a dedicated server. Added a new virtual call UEditorEngine::OnLoginPIEAllComplete, called when all clients have been successfully logged in when starting PIE. The default behavior is to set focus to the first client.
	#jira UE-26037 - Cumbersome workflow when running PIE with 2 clients
	#jira UE-26905 - First client window does not gain focus or mouse control when launching two clients

Change 2949389 on 2016/04/20 by Richard.TalbotWatkin

	Fixed regression which was saving the viewport config settings incorrectly.  Viewports are keyed by their layout on the same key as the config key, hence we do not need to prepend the SpecificLayoutString when saving out the config data when iterating through a layout's viewports.
	#jira UE-29058 - Viewport settings are not saved after shutting down editor

Change 2949388 on 2016/04/20 by Richard.TalbotWatkin

	Change auto-reimport settings so that "Detect Changes on Startup" defaults to true. Also removed the warning of potential unwanted behaviour when working in conjunction with source control; this is no longer necessary now that there is a prompt prior to auto-reimport.
	#jira UE-29257 - Auto import does not import assets

Change 2949203 on 2016/04/19 by Max.Chen

	Sequencer: Fix spawnables not getting default tracks.

	#jira UE-29644

Change 2949202 on 2016/04/19 by Max.Chen

	Sequencer: Fix particles not firing on loop.

	#jira UE-27881

Change 2949201 on 2016/04/19 by Max.Chen

	Sequencer: Fix multiple labels support

	#jira UE-26812

Change 2949200 on 2016/04/19 by Max.Chen

	Sequencer: Expose settings sequencer settings in the Editor Preferences page. Note, UMG and Niagara have separate sequencer settings pages.

	#jira UE-29516

Change 2949197 on 2016/04/19 by Max.Chen

	Sequencer: Fix unwind rotation when keying rotation so that rotations are always set to the nearest.

	#jira UE-22228

Change 2949196 on 2016/04/19 by Max.Chen

	Sequencer: Disable selection range drawing if it's empty so that playback range dragging can take precedence when they overlap. This fixes a bug where you can't drag the starting playback range when sequencer starts up.

	#jira UE-29657

Change 2949195 on 2016/04/19 by Max.Chen

	MovieSceneCapture: Default image compression quality to 100 (rather than 75).

	#jira UE-29657

Change 2949194 on 2016/04/19 by Max.Chen

	Sequencer: Matinee to Level Sequence fix for mapping properties correctly. This fixes focus distance not getting set properly on the conversion.

	#jira UETOOL-467

Change 2949193 on 2016/04/19 by Max.Chen

	Sequencer - Fix issues with level visibility.
	+ Don't mark sub-levels as dirty when the track evaluates.
	+ Fix an issue where sequencer gets into a refresh loop because drawing thumbnails causes levels to be added which was rebuilding the tree, which was redrawing thumbnails.
	+ Null check for when an objects world is null but the track is still evaluating.
	+ Remove UnrealEd references.

	#jira UE-25668

Change 2948990 on 2016/04/19 by Aaron.McLeran

	#jira UE-29654 FadeIn invalidates Audio Components in 4.11

Change 2948890 on 2016/04/19 by Jamie.Dale

	Downgraded an assert in SPathView::LoadSettings to avoid a common crash when a saved path no longer exists

	#jira UE-28858

Change 2948860 on 2016/04/19 by Mike.Beach

	Mirroring CL 2940334 (from Dev-Blueprints):
	Bettering CreateEvent node errors, so users are able to recover from API changes (not clearing the function name field, calling out the function by name in the error, etc.)

	#jira UE-28911

Change 2948857 on 2016/04/19 by Jamie.Dale

	Added an Asset Localization context menu to the Content Browser

	This allows you to create, edit, and view localized assets from any source asset, as well as edit and view source assets from any localized asset.

	#jira UE-29493

Change 2948854 on 2016/04/19 by Jamie.Dale

	UAT now stages all project translation targets

	#jira UE-20248

Change 2948831 on 2016/04/19 by Mike.Beach

	Mirroring CL 2945994 (from Dev-Blueprints):
	Pasting EdGraphNodes will no longer query sub-nodes for compatibility if the root cannot be pasted (for things like collapsed graphs, and anim state-machine nodes).

	#jira UE-29035

Change 2948825 on 2016/04/19 by Jamie.Dale

	Fixed shadow warning

	#jira UE-29212

Change 2948812 on 2016/04/19 by Marc.Audy

	Gracefully handle failure to load configurable engine classes
	#jira UE-26527

Change 2948791 on 2016/04/19 by Jamie.Dale

	Fixed regression in SEditableText bIsCaretMovedWhenGainFocus when using auto-complete
	Fixed regression in FSlateEditableTextLayout::SetText that caused it to call OnTextChanged when nothing had changed

	#jira UE-29494
	#jira UE-28886

Change 2948761 on 2016/04/19 by Jamie.Dale

	Sub-fonts are now only used when they contain the character to be rendered

	#jira UE-29212

Change 2948718 on 2016/04/19 by Jamie.Dale

	Fixed an issue where FEnginePackageLocalizationCache could be initialized before CoreUObject was ready

	This is now done lazily, either when the first CDO tries to load an asset (which is after CoreUObject is ready), or after the first call to ProcessNewlyLoadedUObjects (if no CDO loads an asset).

	#jira UE-29649

Change 2948717 on 2016/04/19 by Jamie.Dale

	Removed the AssetRegistry's dependency on MessageLog

	It was only there to add a category that was only ever used by the AssetTools module.

	#jira UE-29649

Change 2948683 on 2016/04/19 by Phillip.Kavan

	[UE-18419] Fix GetClassDefaults nodes to update properly in response to structural BP class changes.

	change summary:
	- modified UK2Node_GetClassDefaults::CreateOutputPins() to bind/unbind delegate handlers for the OnChanged() & OnCompile() events for BP class types.

	#jira UE-18419

Change 2948681 on 2016/04/19 by Phillip.Kavan

	[UE-17794] The "Delete Unused Variable" feature now considers the GetClassDefaults node as well.

	change summary:
	- added external linkage to UK2Node_GetClassDefaults::FindClassPin().
	- added an include for the K2Node_GetClassDefaults header file to BlueprintGraphDefinitions.h.
	- added UK2Node_GetClassDefaults::GetInputClass() as a public API w/ external linkage; moved default 'nullptr' param logic into this impl.
	- modified FBlueprintEditorUtils::IsVariableUsed() to add an extra check for a GetClassDefaults node with a visible output pin for the variable that's also connected.
	- modified UK2Node_GetClassDefaults::GetInputClass() to return the generated skeleton class for Blueprint class types.

	#jira UE-17794

Change 2948638 on 2016/04/19 by Lee.Clark

	PS4 - Fix SDK compile warnings

	#jira UE-29647

Change 2948401 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-29250 Revuilt Lighting for Landscapes Map

Change 2948398 on 2016/04/19 by Mark.Satterthwaite

	Add a Mac Metal ES2 shader platform to allow the various ES2 emulation modes to work in the Editor. Fix various issues with the shader code to ensure that Metal can run with ES2 shader code at least in my limited test cases in QAGame.
	#jira UE-29170

Change 2948366 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-29109 Replaced Box Mesh with BSP Floor

Change 2948360 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947488

	#jira UE-29115 Nativized BulletTrain - cannot shoot targets in intro tutorial
	#jira UE-28965 Packaging Project with Nativize Blueprint Assets Prevents Overlap Events from Firing
	#jira UE-29559
	- fixed private enum access
	- fixed private bitfield access
	- removed forced PostLoad
	- add BodyInstance.FixupData call to fix ResponseChannels
	- ignored RelativeLocation and RelativeRotation in converted root component
	- fixed AttachToComponent (UE-29559)

Change 2948358 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947953

	#jira UE-29605 Wrong bullet trails in nativized ShowUp
	Fixed USimpleConstructionScript::GetSceneRootComponentTemplate.

Change 2948357 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2947984

	#jira UE-29374 Crash when hovering over Create Widget node in blueprints

	Safe UK2Node_ConstructObjectFromClass::GetPinHoverText.

Change 2948353 on 2016/04/19 by Maciej.Mroz

	merged from Dev-Blueprints 2948095

	#jira UE-29246 ExpandEnumAsExecs + UMETA(Hidden) Crashes Blueprint Compile
	"Hidden" and "Spacer" elementa from an enum does not generated exec pins for "ExpandEnumAsExecs"

Change 2948332 on 2016/04/19 by Benn.Gallagher

	Fixed old pins being left as non-transactional
	#jira UE-13801

Change 2948203 on 2016/04/19 by Lee.Clark

	PS4 - Use SDK 3.508.031

	#jira UEPLAT-1225

Change 2948168 on 2016/04/19 by mason.seay

	Updating test content:

	-Added Husk AI to level to test placed AI

	-Updated Spawn Husk BP to destroy itself to prevent spawn spamming

	#jira UE-29618

Change 2948153 on 2016/04/19 by Benn.Gallagher

	Missed mesh update for Owen IK fix.

	#jira UE-22540

Change 2948130 on 2016/04/19 by Benn.Gallagher

	Fixed old Owen punch IK setup so it no longer jitters when placing the hands on the surface.

	#jira UE-22540

Change 2948117 on 2016/04/19 by Taizyd.Korambayil

	#jira UE-28477 Resaved Template Map's to fix Warning Toast on Templates

Change 2948063 on 2016/04/19 by Lina.Halper

	- Anim composite notify change for better
	 - Fixed all nested anim notify

	- Merging CL 2944396 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira : UE-29101

Change 2948060 on 2016/04/19 by Lina.Halper

	Fix for composite section metadata saving for montage

	Merging CL 2944397 using //UE4/Dev-Framework_to_//UE4/Release-4.12

	#jira : UE-29228

Change 2948029 on 2016/04/19 by Ben.Marsh

	EC: Prevent automatically pushing CIS builds to the launcher; the changelist might be run more than once.

Change 2947986 on 2016/04/19 by Benn.Gallagher

	Fixed BP callable functions that affect skeletal mesh component transforms not working when simulating physics.
	#jira UE-27783

Change 2947976 on 2016/04/19 by Mark.Satterthwaite

	Duplicate CL #2943702 from 4.11.2: Change the way Metal validates the render-target state so that in FMetalContext::PrepareToDraw it can issue a last-ditch attempt to restore the render-targets. This won't fix the cause of the Mac Metal crashes but it might mitigate some of them and provide more information about why they are occurring.
	#jira UE-29006

Change 2947975 on 2016/04/19 by Mark.Satterthwaite

	Duplicate CL #2945061 from UE4-UT: Address UT issue UE-29150 directly in the UT branch: users without a sufficiently up-to-date Xcode won't have the 'metal' offline shader compiler so will have to use the slower online compiled text shader format.
	#jira UE-29150

Change 2947679 on 2016/04/19 by Jack.Porter

	Fixed 4.12 branch not compiling with the 1.0.8 Vulkan SDK
	#jira UE-29601

Change 2947657 on 2016/04/18 by Jack.Porter

	Update protostar reflection capture contents

	#jira UE-29600

Change 2947301 on 2016/04/18 by Ben.Marsh

	EC: Fix trigger ready emails failing to send due to recipient list being a space-separated list of addresses rather than an array reference.

Change 2947263 on 2016/04/18 by Marc.Audy

	Merging CL# 2945921 //UE4/Release-4.11 to //UE4/Release-4.12

	Ensure that all OwnedComponents in an Actor are duplicated for PIE even if not referenced by a property, unless that component is explicitly transient
	#jira UE-29209

Change 2946984 on 2016/04/18 by Ben.Marsh

	GUBP: Allow Ocean cooks in the release branch (fixes build startup failures)

Change 2946870 on 2016/04/18 by Ben.Marsh

	Remaking CL 2946810 to fix compile error in ShooterGame editor.

Change 2946859 on 2016/04/18 by Ben.Marsh

	GUBP: Don't exclude Ocean from builds in the release branch.

Change 2946847 on 2016/04/18 by Ben.Marsh

	GUBP: Fix warning on every build step due to OrionGame_Win32_Mono no longer existing.

Change 2946771 on 2016/04/18 by Ben.Marsh

	EC: Correct initial agent type for release branches. Causing full branch syncs on all agents.

Change 2946641 on 2016/04/18 by Ben.Marsh

	EC: Remove rogue comma causing branch definition parsing to fail.

Change 2946592 on 2016/04/18 by Ben.Marsh

	EC: Adding branch definition for 4.12 release

#lockdown Nick.Penwarden

[CL 2962354 by Ben Marsh in Main branch]
2016-05-01 17:37:41 -04:00

1822 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_BlendSpace1D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Blueprint) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CameraAnim) );
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_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) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_VertexAnimation) );
// 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) );
}
bool bEnableNiagara = false;
GConfig->GetBool(TEXT("Niagara"), TEXT("EnableNiagara"), bEnableNiagara, GEngineIni);
if ( bEnableNiagara )
{
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_NiagaraScript) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_NiagaraEffect) );
}
}
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 && 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 )
{
void* ParentWindowWindowHandle = nullptr;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() )
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
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;
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);
// 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);
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}'"), 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) )
{
void* ParentWindowWindowHandle = nullptr;
IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked<IMainFrameModule>(TEXT("MainFrame"));
const TSharedPtr<SWindow>& MainFrameParentWindow = MainFrameModule.GetParentWindow();
if ( MainFrameParentWindow.IsValid() && MainFrameParentWindow->GetNativeWindow().IsValid() )
{
ParentWindowWindowHandle = MainFrameParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
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