Files
UnrealEngineUWP/Engine/Source/Developer/AssetTools/Private/AssetTools.cpp
Marc Audy 22f58737f9 Copying //UE4/Dev-Framework to //UE4/Dev-Main (Source: //UE4/Dev-Framework @ 3431384)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3252833 on 2017/01/10 by Ori.Cohen

	Refactor constraint so that it can be used for external solvers. (Copying //Tasks/UE4/Dev-ImmediateModePhysics to Dev-Framework (//UE4/Dev-Framework))

Change 3256288 on 2017/01/12 by Ori.Cohen

	Undo constraint refactor as we found a way around it and it made the code much harder to read/debug

Change 3373195 on 2017/03/30 by Mike.Beach

	For nativization, changing it so we key off of the target platform-info struct instead of the platform (in preparation for defining the nativized plugin's platform whitelist).

Change 3381178 on 2017/04/05 by Dan.Oconnor

	Make sure we don't inherit the NATIVE func flag when generating skeleton functions, also make sure all bojects outer'd to the skeleton class are marked transient
	#jira UE-43616

Change 3381532 on 2017/04/05 by Marc.Audy

	(4.16) Fix various cases where built lighting on child actors could be lost when loading a level
	#jira UE-43553

Change 3381586 on 2017/04/05 by Mike.Beach

	Now generating TArrayCaster conversions for nativized UClass arrays that need it (to handle different TSubclassOf arrays).

	#jira UE-42676, UE-43257

Change 3381682 on 2017/04/05 by mason.seay

	Some more changes to test map

Change 3381844 on 2017/04/05 by Dan.Oconnor

	Match existing logic for CPF_ReturnParm/CPF_OutParm. Fixes compilation error in BP_TurbineBlades when using compilation manager

Change 3382054 on 2017/04/05 by Zak.Middleton

	#ue4 - Optimize CharacterMovementComponent::GetPredictionData_Client_Character() and GetPredictionData_Server_Character() to remove virtual calls.

	#jira UE-30998

Change 3382703 on 2017/04/06 by Lukasz.Furman

	fixed missing links between navmesh polys when there are more than 4 neighbor connections
	#jira UE-43524

Change 3383357 on 2017/04/06 by Marc.Audy

	(4.16) Make SetHiddenInGame propagate consistently with SetVisibility
	#jira UE-43709

Change 3383359 on 2017/04/06 by Dan.Oconnor

	Fix last errant SKEL reference when cooking Odin

Change 3383591 on 2017/04/06 by Mike.Beach

	Prevent users from setting object variables as 'config' properties (disallowed by UHT). This prevents some errors that could happen later when users nativize the Blueprint.

	#jira UE-42085

Change 3384762 on 2017/04/07 by Zak.Middleton

	#ue4 - Fix SpringArmComponent not restoring relative transform when bUsePawnControlRotation is turned off. Fixes the editor interaction ignoring transform of the component in the viewport after bUsePawnControlRotation is toggled on then off, since by then the world transform had been overwritten (from tick in editor) and nothing would drive transform changes from the editable value.

	Toggling bUsePawnControlRotation off at runtime now restores the rotation to the initial relative rotation, not stomping it with the current pawn rotation, allowing toggling between the editable/desired base rotation and the control rotation.

	#jira UE-24850

Change 3384948 on 2017/04/07 by Dan.Oconnor

	Prevent GForceDisableBlueprintCompileOnLoad from causing all sorts of badness when dependencies are loaded as part of a Diff operation. Instead of setting a global flag we flag the package as LOAD_DisableCompileOnLoad

Change 3385267 on 2017/04/07 by Michael.Noland

	Graph Editing: Pushed some node diffing code down from UAIGraphNode into UEdGraphNode so nodes with details panel properties will diff correctly (e.g., various animation nodes and BP switch nodes)

	#jira UE-21724

Change 3385473 on 2017/04/07 by Phillip.Kavan

	#jira UE-43067 - Fix broken pin wires after an Expand Node operation, along with some misc. cleanup.

	Change summary:
	- Fixed to use correct string for "Expand Node" transaction name.
	- Modified FBlueprintEditor::OnExpandNodes() to consolidate some redundant code.
	- Fixed to generate a unique node GUID for cases where the source graph is not removed after expansion.

Change 3385583 on 2017/04/07 by Dan.Oconnor

	Handle CreatePropertyOnScope nullptr return values (happens for structs missing a struct property)

	#jira UE-43746

Change 3386581 on 2017/04/10 by Michael.Noland

	Blueprints: Further hardening FBlueprintActionInfo::GetOwnerClass()
	#jira UE-43824

Change 3386615 on 2017/04/10 by Marc.Audy

	Instanced properties can now properly be set on a per-instance basis in blueprint added components.
	#jira UE-42066

Change 3387000 on 2017/04/10 by Marc.Audy

	Fix includes for CIS

Change 3387229 on 2017/04/10 by mason.seay

	More changes to TM-Gameplay

	Added Save Game test (with blueprint)

	Tick Interval test (with blueprint)

	BP logic cleanup

	Level organization

Change 3388437 on 2017/04/11 by Mike.Beach

	Adding support for map/set literals in the backend (so you can use set nodes for structs containing sets/maps, without having to connect a RHS input - resets to struct defaults).

	#jira UE-42617

Change 3388532 on 2017/04/11 by mason.seay

	Submitting latest changes for crash repro

Change 3389026 on 2017/04/11 by Ben.Zeigler

	Performance and bug fixes for incremetal cooking with asset registry, duplicate of several changes made on //Fortnite/Main
	Fix it so AssetRegistry.ScanPathsAndFilesSynchronous won't scan subdirectories inside already scanned directories, this cuts down on the number of cache files
	Fix 2 second stall when shutting down AssetSourceFilenameCache if it had never been previously created

Change 3389163 on 2017/04/11 by Ben.Zeigler

	#jira UE-42922 Fix it so connecting function input node output pins does not clear default value, we only want to clear the value when connecting an input pin. Properly testing this fix depends on UE-43883

Change 3389205 on 2017/04/11 by Marc.Audy

	Protect against a handful of GEditor usages that can now be hit in standalone

Change 3389220 on 2017/04/11 by Marc.Audy

	Don't borrow ClassWithin to masquerade as ParentClass during compilation and instead just set the super struct immediately

Change 3389222 on 2017/04/11 by Michael.Noland

	Framework: Adding a cvar (t.TickComponentLatentActionsWithTheComponent) to allow users to revert to the old behavior on when component latent actions tick
	- Non-zero values behave the same way as actors do, ticking pending latent action when the component ticks, instead of later on in the frame (default behavior in 4.16 and beyond)
	- Prior to 4.16, components behaved as if the value were 0, which meant their latent actions behaved differently to actors

	This CVar will be removed in a future version, defaulting to on

	#jira UE-43661

Change 3389276 on 2017/04/11 by Marc.Audy

	Spelling fix and NULL to nullptr

Change 3389303 on 2017/04/11 by Mieszko.Zielinski

	Made sure AIController::Posses doesn't get called when compiling Pawn BP #UE4

	#jira UE-43873

Change 3390215 on 2017/04/12 by mason.seay

	Removed some tests, will need further review

Change 3390638 on 2017/04/12 by Mike.Beach

	Generalizing the omission of the CoerceProperty (in EmitTerm) - previously we were only omitting properties for our custom array lib. For wildcards, a coerce property should not be used as its type will not match.

	NOTE: There is a slight behavior change in UEdGraphSchema_K2::ConvertPropertyToPinType(), as it will return 'wildcard' for params marked as 'ArrayTypeDependentParams' (previously would have returned 'int').

	#jira UE-42747

Change 3390774 on 2017/04/12 by Ben.Zeigler

	#jira UE-43911 Fix several issues with saving a runtime asset registry containing redirectors that caused crashes in cook on the fly. Don't resolve redirectors on incoming links because it will make a circular link, and fix an issue where chained redirectors would break the for loop iteration and return a bad dependency
	Fix it so the asset registry written out at the beginning of CookOnTheFly uses the registry generator, otherwise it will include all of the stripped editor only tags

Change 3390778 on 2017/04/12 by Ben.Zeigler

	Fix UCookOnTheFlyServer::CollectFilesToCook to check for initial unsolicited packages up front. This is required in iterative mode because it may skip cooking all explicit packages and thus miss a new startup loaded package

Change 3390782 on 2017/04/12 by Ben.Zeigler

	Change RunProjectCommand to not imply -nomcp, and allow reading -clientcmdline to override setting the map parameter to 127.0.0.1 by default
	Fix RunProjectCommand to remove ios-specific checks to not pass weird platform parameters, and instead never pass them
	Fix PS4Platform to pass along command line when calling build cook run, args needs to be the last parameter so explicitly set -target=

Change 3390859 on 2017/04/12 by Mike.Beach

	T3D class fields now export with the class's fully qualified path name (to avoid abiguity). Since we can have multiple classes with the same name (Blueprints in different folders), we have to use the class's fully qualified object path.

	#jira UE-28048

Change 3390914 on 2017/04/12 by Lukasz.Furman

	fixed missing navlink component's transform in exported navigation data
	#jira  UE-43688

Change 3391122 on 2017/04/12 by Ben.Zeigler

	Add new PreloadPrimaryAssets call to AssetManager that stream the desired assets without modifying the official load/unload state. This is useful if you want to preload things in case the might be used in the future, and it also supports recursion
	Fix crash calling GetAssetDataForPath with null path

Change 3391494 on 2017/04/12 by Dan.Oconnor

	Fix bad references in deep object (widget) hierarchies

	#jira UE-43802

Change 3391529 on 2017/04/12 by Dan.Oconnor

	Fix log spam, accidently submitted

	#rnx

Change 3391756 on 2017/04/12 by Dan.Oconnor

	LinkExternalDependencies needs to be performed before we RefreshVariables

	#jira UE-43843

Change 3392542 on 2017/04/13 by Marc.Audy

	Ensure that initialized actors get cleaned up when removed from world even if that world hasn't begun play.
	#jira UE-43879

Change 3392746 on 2017/04/13 by Marc.Audy

	(4.16) When duplicating a blueprint node, correctly make the new node a sibling of the duplicated node, not a child of it (unless duplicating the root component).
	Also resets scale of a duplicated root component to 1 to avoid a squaring of the scale for that component.
	#jira UE-40218
	#jira UE-42086

Change 3393253 on 2017/04/13 by Dan.Oconnor

	Make sure calculated meta data is correctly set on functions generated by the compilation manager (SKEL_ class functions)

	#jira UE-43883

Change 3393509 on 2017/04/13 by Mike.Beach

	Removing hack'ish ResetLoaders() call that was causing undesired side-effects (resetting of a loaded package that other objects were relying on). This was originally intended to release file handles so separate editor processes could make updates and save the file (from CL 1712376). Using ResetLoaders() for this is bad though, as it has too many side effects. Instead we have to wait for GC to run. This also makes sure that GC should run as intended as the CookOnTheFly sever is idling.

	#jira UE-37284

Change 3394350 on 2017/04/14 by Michael.Noland

	Core: Making FDateTime and FTimespan actually reflected, so they get duplicated properly in CopyPropertiesForUnrelatedObjects, etc...
	#jira UE-39921

Change 3395985 on 2017/04/17 by Phillip.Kavan

	#jira UE-38280 - Fix invalid custom type selections on member fields in the User-Defined Structure Editor after a reload.

	Change summary:
	- Ensure that the 'SubCategoryObject' member in a UDS variable descriptor has been loaded when converting to an FEdGraphPinType.

Change 3396152 on 2017/04/17 by Marc.Audy

	TickableGameObjects that have IsTickableInEditor false should not tick in the editor
	#jira UE-40421

Change 3396279 on 2017/04/17 by Phillip.Kavan

	#jira UE-43968 - Fix failed validation of bitmask enum types when serializing bitmask literal nodes.

Change 3396299 on 2017/04/17 by Dan.Oconnor

	Fix resintancing issues exposed by running TM-Gameplay with -game. We cannot reinstance actors in levels on load because the scene is not created.

	#jira UE-43859

Change 3396712 on 2017/04/17 by Marc.Audy

	Call PostLoad on subobjects before copying for unrelated properties to avoid cases where an out of date object patched over in the linker has not been brought up to date
	#jira UE-38234

Change 3396718 on 2017/04/17 by Mike.Beach

	Adding a search bar to the components tree for Blueprints.

	#epicfriday
	#jira UE-17620

Change 3396999 on 2017/04/17 by Mike.Beach

	In generated code, call event '_Implementation' functions directly for interface functions being invoked on self (avoids a UHT runtime error).

	#jira UE-44018

Change 3397700 on 2017/04/18 by Marc.Audy

	UT struct BlueprintType fixups

Change 3397701 on 2017/04/18 by Marc.Audy

	Odin struct BlueprintType fixups

Change 3397703 on 2017/04/18 by Marc.Audy

	Ocean struct BlueprintType fixups

Change 3397704 on 2017/04/18 by Marc.Audy

	WEX struct BlueprintType fixups

Change 3397705 on 2017/04/18 by Marc.Audy

	Additional UT blueprint type struct fixups

Change 3397706 on 2017/04/18 by Marc.Audy

	Fortnite struct BlueprintType fixups

Change 3397708 on 2017/04/18 by Marc.Audy

	Fixup Engine BlueprintType markup of structs

Change 3397709 on 2017/04/18 by Marc.Audy

	Sample Game struct BlueprintType fixups

Change 3397711 on 2017/04/18 by Marc.Audy

	Mark AnimNodes as BlueprintType and BlueprintInternalUseOnly

Change 3397712 on 2017/04/18 by Marc.Audy

	Paragon struct BlueprintType fixups

Change 3397735 on 2017/04/18 by Marc.Audy

	Definition pieces of BlueprintInternalUseOnly to fix UHT errors with structs already marked to use it

Change 3397912 on 2017/04/18 by Mike.Beach

	Fix for CIS warnings about shadowed variables (fallout from CL 3396718).

Change 3398455 on 2017/04/18 by Marc.Audy

	Make less critical errors log an error rather than immediately throwing allowing multiple errors to be reported in the same compile

Change 3398491 on 2017/04/18 by Marc.Audy

	BPRW/BPRO in a non-BlueprintType is now a UHT error

Change 3398539 on 2017/04/18 by Marc.Audy

	Fixup live link struct markups

Change 3399412 on 2017/04/19 by Marc.Audy

	Fix Match3 blueprint type struct markups

Change 3399509 on 2017/04/19 by Phillip.Kavan

	#jira UE-38574 - Fix AnimBlueprint function graphs marked as 'const' to treat 'self' as read-only when compiling.

	Change summary:
	- Modified FKismetCompilerContext::ProcessOneFunctionGraph() to use the function graph schema rather than the compiler context schema for both the function context's schema as well as testing the function for 'const'-ness. For AnimBPs, the compiler context and the function graph context can differ, so we need to make sure we are using the right one when making queries for a specific function context during compilation.
	- Minor cleanup: changed the function context schema to be 'const' in order to be consistent with the function graph GetSchema() API's result. Added a few 'const' qualifiers where needed to match.
	- Added a new object version in order to avoid breaking compilation of existing AnimBP function graphs that may already be violating the 'const' rule (this is the same thing that was done when 'const' was first added to "normal" BP function graphs). Just as with normal function graphs in place before the addition, a warning will be generated for existing AnimBP function graphs if they violate 'const' correctness, and an error will be generated for all new ones.

Change 3399749 on 2017/04/19 by Mike.Beach

	Hiding the Nativized Blueprints plugin from the in-editor browser (prevent users from disabling it).

Change 3399774 on 2017/04/19 by Marc.Audy

	ConditionalPostLoad is already called on StaticMesh earlier in the function

	#rnx

Change 3400313 on 2017/04/19 by Mike.Beach

	Mirroring CL 3398673 from 4.16

	Now, with ICWYU, making sure that the coresponding header gets included first in nativized Blueprint files (else we get a UHT error). Had to fixup some ShooterGame specific files as a result (they had missing includes and forward declarations).

	#jira UE-44124

Change 3400328 on 2017/04/19 by Mike.Beach

	Missing file from mirrored change (CL 3400313 - mirroring CL 3398673 from 4.16)

	#jira UE-44124

Change 3400415 on 2017/04/19 by Chad.Garyet

	adding physx switch build to framework

Change 3400514 on 2017/04/19 by Mike.Beach

	Back out changelist 3400313 / 3400328 (mirrored from CL 3398673 in 4.16), as it was producing "include PCH first" errors. Likely, CL 3398673 was a fix for a 4.16 specific change, altering the expected include order. We'll have to wait for this one to be integrated back.

Change 3400552 on 2017/04/19 by Marc.Audy

	Undo the calling of post load prior to the CPFUO as dependent objects may not yet be loaded. Instead copy the need load flag to the new CDO subobject, similarly to how the top level CDO object copies its flags over.
	#jira UE-44150

Change 3400815 on 2017/04/19 by Marc.Audy

	Spelling fix (part of PR #3490)

	#rnx

Change 3400918 on 2017/04/19 by Marc.Audy

	Partial pull of PR #3490: Improved remapping game controls support (Contributed by projectgheist)
	This portion brings in the exposure of the bindings to blueprint
	#jira UE-44122

Change 3401550 on 2017/04/20 by Marc.Audy

	fix kitedemo blueprint type markup

	#rnx

Change 3401702 on 2017/04/20 by Mike.Beach

	Make it so plugins added to a project through the .uproject's 'AdditionalPluginDirectories' list get folded into the generated code project (for visual studio, etc.).

Change 3401720 on 2017/04/20 by Mike.Beach

	Add white and black lists for target type (game, client, server, etc.) to plugin module descriptors.

Change 3401725 on 2017/04/20 by Mike.Beach

	Whitelisting the nativized Blueprint plugin for only the targets it was built for (game, server, or client).

Change 3401800 on 2017/04/20 by Ben.Zeigler

	Add Algo::BinarySearch, LowerBound, and UpperBound. These are setup to allow binary searching a presorted array, and allow for specifying projection and sort predicates. Convert some engine code to use it
	Add TSortedMap, which is a map data structure that has the same API as TMap, but is backed by a sorted array. It uses half the memory and performance is faster below n=10
	Add FName::CompareIndexes so a SortedMap with FNames can be used without doing very slow string compares, and FNameSortIndexes predicate to sort by it
	Add code to Algo and Container tests. Split up container tests so the new ones aren't run in smoketest as they are a bit slow
	Add RemoveCurrent and SetToEnd to ArrayIterator

Change 3401849 on 2017/04/20 by Marc.Audy

	Partial pull of PR #3490: Improved remapping game controls support (Contributed by projectgheist)

	This portion brings bug fixes and improvements to InputKeySelector UMG widgets.
	#jira UE-44122

Change 3402088 on 2017/04/20 by Marc.Audy

	Focus the search box when expanding the map value type
	#jira UE-44211

Change 3402251 on 2017/04/20 by Ben.Zeigler

	Fix issue where SortedMap needs to be resorted after serialization, because the sorting may have changed from when it was saved out

Change 3402335 on 2017/04/20 by Ben.Zeigler

	Significant changes to FAssetData serialization and memory, cuts memory significantly but will break code that was using some of the internal API that was not properly hidden before
	Both Editor and Runtime cache now use the same FAssetRegistryVersion, which is now registered as a custom version
	Rename FAssetData and FAssetPackage operator<< to SerializeForCache to make it clear that it isn't safe to use for general serialization
	Remove GroupNames from FAssetData, it has not been useful since the UE4 package structure changed around 4.0
	Rename generic-sounding but not actually generic SharedMapView class to AssetDataTagMapSharedView to indicate what it is actually used for
	Change TagsAndValues to use a new array-backed TSortedMap as the base structure instead of a hash map. Also, it only allocates the map on demand, which saves significant memory at runtime as many packages have no tags
	Add bFilterAssetDataWithNoTags to [AssetRegistry] ini section, if set it will only save cooked asset data if it has tags, off by default but saves significant memory if your whitelist is set up properly
	Fix issue where asset registry tags updated by loading assets during cook were not being reflected in the cooked registry
	Add AssetRegistry::GetAllocatedSize and add to MemReport output

Change 3402457 on 2017/04/20 by Ben.Zeigler

	Enable asset registry iteration and stripping unused asset data in Fortnite. Registry iteration is already on in //Fortnite/Main, stripping is a new feature I want to test

Change 3402498 on 2017/04/20 by Ben.Zeigler

	CIS fix. Why did this compile locally?

Change 3402537 on 2017/04/20 by Ben.Zeigler

	Remove ensure for making AssetData for subobjects, the editor does this for thumbnail creation in some cases

Change 3402600 on 2017/04/20 by Ben.Zeigler

	Add bShouldGuessTypeAndNameInEditor to manager settings, can be set false for games where type cannot be safely implied and content must be resaved
	Fix up some bool setting code inside asset manager, and fix const correctness and for iterator issues
	AssetManager can now discover any BlueprintCore type when bHasBlueprintClasses=true
	Add AssetManager.DumpAssetRegistryInfo to output detailed asset registry usage stats
	Add Primary Name to asset audit window by default

Change 3403556 on 2017/04/21 by Marc.Audy

	Fix Orion input key selector override class

	#rnx

Change 3404090 on 2017/04/21 by mason.seay

	Applying Forcefeedback to test map

Change 3404093 on 2017/04/21 by mason.seay

	Changing text in level

Change 3404139 on 2017/04/21 by mason.seay

	Added Force Feedback test and made some tweaks.

Change 3404146 on 2017/04/21 by mason.seay

	Added source reference to Instanced Variable test

Change 3404154 on 2017/04/21 by mason.seay

	More minor tweaks

Change 3404155 on 2017/04/21 by Marc.Audy

	Remove auto

	#rnx

Change 3404188 on 2017/04/21 by Marc.Audy

	Fixed crash changing variable type when any type other than map
	#jira UE-44249

	#rnx

Change 3404463 on 2017/04/21 by Ben.Zeigler

	Fix asset data code to not ensure when loading an object with invalid exports, and instead print warning with name of package that needs to be resaved
	Resave a map that had a redirector from a DIFFERENT package saved in it's exports. I do not understand how this happened, but it appears to be related to the lightmap BuiltData transition when old maps are opened

Change 3404465 on 2017/04/21 by Ben.Zeigler

	Fix issue with trying to load editor-only asset classes in a cooked build
	Fix issues with renaming or changing template Ids of assets from the editor
	Always print the Duplicate Asset ID error, as if you have more than one the ensuremsg only goes off once

Change 3404481 on 2017/04/21 by Dan.Oconnor

	Remove unneeded walk up hierarchy - prevent stale entries in action database if we compile a BP but don't compile its children

Change 3404510 on 2017/04/21 by Phillip.Kavan

	#jira UE-35727 - Collapsed graphs containing a local variable node will no longer cause a compile error when the parent graph is renamed.

Change 3404590 on 2017/04/21 by Michael.Noland

	Editor: Fixed incorrect filtering of abstract/deprecated UDeveloperSettings and UContentBrowserFrontEndFilterExtension classes caused by a typo (HasAnyCastFlags versus HasAnyClassFlags)

Change 3404593 on 2017/04/21 by Marc.Audy

	Fixed another crash to do with input pin secondary combo box
	#jira UE-44269

	#rnx

Change 3404600 on 2017/04/21 by Michael.Noland

	Core: Allow UE_GC_TRACK_OBJ_AVAILABLE to be set externally
	#rnx

Change 3404602 on 2017/04/21 by Michael.Noland

	Engine: Switched from an include to a forward declaration of SWidget in UDeveloperSettings to keep it slim
	#rnx

Change 3404608 on 2017/04/21 by Michael.Noland

	Core: Marked TNumericLimits as constexpr so they can be used in static asserts

Change 3404659 on 2017/04/21 by Michael.Noland

	Engine: Adding includes back to two UDeveloperSettings subclasses

Change 3405289 on 2017/04/24 by Marc.Audy

	Remove auto

	#rnx

Change 3405446 on 2017/04/24 by Marc.Audy

	Fix Win32 unsigned compile issue

Change 3405512 on 2017/04/24 by Mike.Beach

	Piping through NativizationOptions to filename generation (so we're able to gen different files names per target: client vs. server).

Change 3406080 on 2017/04/24 by Ben.Zeigler

	Deprecate UEngine::OnPostEngineInit and move to FCoreDelegates, clean up comments for the initialization delegates
	Call OnPostEngineInit from commandlet initialization as well as normal execution. I thought about making a wrapper function, but the commandlet calls EditorInit directly so it wouldn't work
	Bind delegate to refresh the AssetRegistry native class hierarchy after engine init so it picks up game/plugin classes. Undo ini change that was required to hack around this

Change 3406381 on 2017/04/24 by Ben.Zeigler

	#jira UE-23768 Enable Run Physics With No Controller for montage test pawn. The montage pawn has no controller so wasn't correctly running physics when the root motion stopped. This flag needs to be set to allow it to correctly stop after the montage is over

Change 3406438 on 2017/04/24 by Ben.Zeigler

	Fix deprecation warning

Change 3406519 on 2017/04/24 by Phillip.Kavan

	#jira UE-43612 - Suppress array "Get" node fixup notifications on load when the BP Compilation Manager is enabled.

	Change summary:
	- Wrapped BPCM calls to FBlueprintEditorUtils::ReconstructAllNodes() and ReplaceDeprecatedNodes() duirng compile-on-load with bIsRegeneratingOnLoad = true. This matches the BP's state during compile-on-load when the BPCM is not enabled.

Change 3406565 on 2017/04/24 by Dan.Oconnor

	Make sure all interface functions are added to skeleton

	#jira UE-44152

Change 3407489 on 2017/04/25 by Ben.Zeigler

	#jira UE-44317 Fix game-only TickableGameObjects to correctly tick in PIE

Change 3407558 on 2017/04/25 by Ben.Zeigler

	Fix Fortnite cook warnings, issue had to do with the CDO being registered as a Primary Asset in conflict with the Class being registered
	Fix issue with renaming a BP primary asset not finding the old name

Change 3407701 on 2017/04/25 by Dan.Oconnor

	Remove unneeded null check, static analysis doen't like the inconsistency

Change 3407995 on 2017/04/25 by Marc.Audy

	Fixed maps and sets not working correctly with split pin.
	#jira UE-43857

Change 3408124 on 2017/04/25 by Ben.Zeigler

	#jira UE-39586 Change it so the blueprint String/Name/Object to Text node creates culture invariant text, and also have them show as an expanded node with a comment explaining this
	Fix Transform to actually return in the format specified in the comment, and fix comments on many text conversions

Change 3408134 on 2017/04/25 by Marc.Audy

	Graph pin container type now represented by an enumeration (EPinContainerType) rather than 3 "independent" booleans.
	FEdGraphPinType constructor, UEdGraphNode::CreatePin, and FKismetCompilerContext::SpawnInternalVariable that took 3 booleans deprecated and replaced with a version that takes EPinContainerType.
	UEdGraphNode::CreatePin parameters reorganized so that PinName is before ContainerType and bIsReference, which default to None and false respectively

Change 3408256 on 2017/04/25 by Michael.Noland

	Core: Changed UClass::ClassFlags to be of type EClassFlags for improved type safety

Change 3408282 on 2017/04/25 by Marc.Audy

	(4.16) Fix incorrect positioning of instance components after duplication
	#jira UE-44314

Change 3408404 on 2017/04/25 by Mike.Beach

	Adding and removing the nativized plugin to/from the project when we alter the packaging nativization setting (so it gets picked up by project generation).

Change 3408445 on 2017/04/25 by Marc.Audy

	Fix up missed deprecation cases

	#rnx

Change 3409354 on 2017/04/26 by Marc.Audy

	Fix Linux CIS failure

	#rnx

Change 3409487 on 2017/04/26 by Marc.Audy

	When dragging assets in to the SCS create them as siblings, not nested
	#jira UE-43041

Change 3409776 on 2017/04/26 by Ben.Zeigler

	#jira UE-44401 Fix issue with cooking a map containing a reparented component. In that case the child component may think it's not editor only, but it's archetype is editor only. This is not allowed in EDL, so now the child is marked as editor only as well

Change 3410168 on 2017/04/26 by Dan.Oconnor

	Avoid calling virtual functions in the middle of compile
	#jira UE-44243

Change 3410252 on 2017/04/26 by Lukasz.Furman

	adjusted WITH_GAMEPLAY_DEBUGGER checks after IWYU changes
	#ue4

Change 3410385 on 2017/04/26 by Marc.Audy

	ChildActorComponent SetClass no longer fails when setting at runtime.
	#jira UE-43356

Change 3410466 on 2017/04/26 by Michael.Noland

	Core: Ensuring EClassFlags is 32 bit in a different way (underlying type of the enum is coming out signed even though all members are unsigned, long term fix is probably to move it to an enum class)
	#rnx

Change 3410476 on 2017/04/26 by Michael.Noland

	Automation: Deleting some commented out methods
	#rnx

Change 3411070 on 2017/04/27 by Marc.Audy

	Properly complete deprecation of old attachment API

Change 3411338 on 2017/04/27 by mason.seay

	Map for Latent Action Tick Bug

Change 3411637 on 2017/04/27 by Ben.Zeigler

	Back out CL #3381532 as it was causing crashes when adding new variables to blueprints, as the transaction array was being recursively modified while it was being added to

Change 3412052 on 2017/04/27 by mason.seay

	Updated jump test map and pawn

Change 3412231 on 2017/04/27 by Ben.Zeigler

	Fix issue where running SearchAllAssets multiple times after mounting new paths would throw away the asset registry cache, which slowed down incremental cooking substantially because the cooker mounts the autosave folder
	Duplicate of CL #3411860

Change 3412233 on 2017/04/27 by Ben.Zeigler

	Made FStreamableHandle::GetLoadedCount much faster by taking advantage of existing progress counter
	Duplicate of CL #3411778

Change 3412235 on 2017/04/27 by Ben.Zeigler

	Add code to FStringAssetReferenceThreadContext and FStringAssetReferenceSerializationScope which allows setting package name and collect options for string asset references serialized via something other than linker load
	Make RedirectCollector threadsafe to avoid issues with async loading asset references
	Fix it so ProcessStringAssetReferencePackageList will remove entries from the string asset array like resolve did, and rename function to indicate that
	Fix it so string asset references created by asset labels do not automatically get cooked, and significantly improve the speed of labels with lots of assets
	Add code to cooker and asset manager to explicitly mark non-cookable assets as NeverVook, this stops labels from ending up in the build if set that way
	Added option to not recurse package dependency changes more than one level when hashes change. This ended up not being significantly faster in a realistic case so left disabled
	Duplicate of CL #3412080

Change 3412352 on 2017/04/27 by Marc.Audy

	Refix lighting getting wrong position when getting component instance data

Change 3412426 on 2017/04/27 by Marc.Audy

	Take first steps to making ComponentToWorld private and force use of accessor
	Make bWorldToComponentUpdated private
	Make ComponentToWorld and bWorldToComponentUpdated mutable
	Add a SetComponentToWorld function for the (likely ill-advised) places that were setting it directly.

Change 3412468 on 2017/04/27 by Marc.Audy

	Remove last remnants of deprecated (4.11) custom location system

Change 3413398 on 2017/04/28 by Marc.Audy

	Fix up missed deprecated attachment API  uses

Change 3413403 on 2017/04/28 by Marc.Audy

	Fix Orion compile error

	#rnx

Change 3413448 on 2017/04/28 by Marc.Audy

	Fix up kite demo component to world privataization warnings

	#rnx

Change 3413792 on 2017/04/28 by Ben.Zeigler

	Fix many bugs with blueprint pin default values, and add "Reset to Default Value" option to pin context menu
	Deprecate and rename SetPinDefaultValue because it actually sets the Autogenerated default. This was being called in bad places and destroying the stored autogenerated defaults
	#jira UE-40101 Fix expose on spawn pins to correctly update when the spawned object's defaults change
	#jira UE-21642 Fix struct pin default values to properly update when the struct is changed
	#jira UE-39418 Fix changed function/macro default values to properly update in already placed call nodes

Change 3413839 on 2017/04/28 by samuel.proctor

	Added some Blueprint focused tests for TM-Gameplay

Change 3414030 on 2017/04/28 by Ben.Zeigler

	Enable use of AssetPtr variables with Config, for native and blueprint
	This incorporates CL #3302487 but also enables for blueprint usage as that code is new to framework branch

Change 3414229 on 2017/04/28 by Marc.Audy

	Fixup virtuals not calling their Super
	Remove some autos

	#rnx

Change 3414451 on 2017/04/28 by Lukasz.Furman

	static analysis fix for gameplay debugger

Change 3414482 on 2017/04/28 by Ben.Zeigler

	Fix crash found where changing pin type on ConvertAsset accessed an array while deleting it

Change 3414609 on 2017/04/28 by Ben.Zeigler

	#jira UE-18146 Refresh graph when disconnecting a resolve asset id node

Change 3415852 on 2017/05/01 by Marc.Audy

	Remove unused code

	#rnx

Change 3415856 on 2017/05/01 by Marc.Audy

	auto removal

	#rnx

Change 3415858 on 2017/05/01 by Marc.Audy

	Fix function taking an input as reference when unneeded and causing (still unclear why it suddenly started showing up) error in cooking

	#rnx

Change 3415946 on 2017/05/01 by Marc.Audy

	Have K2Node_StructOperation skip the K2Node_Variable validation as it doesn't need a property (per CL# 1756451)

	#rnx

Change 3415988 on 2017/05/01 by Lukasz.Furman

	renamed WorldContext param in AI related static blueprint functions to remove load/cook warnings
	#jira UE-44544

Change 3416030 on 2017/05/01 by Ben.Zeigler

	Fix issue with WorldContext pins being broken by my pin value refactor, partial paths like "WorldContext" need to be stored as strings and not as broken object references.

Change 3416230 on 2017/05/01 by Marc.Audy

	Fix spelling error

	#rnx

Change 3416419 on 2017/05/01 by Phillip.Kavan

	#jira UE-44213 - Nativizing a Blueprint class with a non-nativized Blueprint class subobject dependency will no longer lead to a crash at load time.

	Change summary:
	- Modified the FFakeImportTableHelper ctor to inject subobject CDOs into the 'SerializeBeforeCreateCDODependencies' array. This in turn ensures that EDL will serialize those subobject CDOs (if necessary) before we create the subobject's nativized owner's CDO at load time.
	- Modified FEmitDefaultValueHelper::GenerateCustomDynamicClassInitialization() to emit MiscConvertedSubobject instantiations AFTER we emit the FillUsedAssetsInDynamicClass() call. This is now consistent with the code emitted for other subobjects (all of which assumes that the UsedAssets array has been initialized).
	- Modified FFindAssetsToInclude::HandleObjectReference() to add UField owner CDOs in addition to the owner class to the asset dependency list. This ensures that owner CDOs will be emitted alongside the class to both the nativized asset dependency table as well as to the fake import table associated with the UDynamicClass linker for the nativized BP asset.

Change 3416425 on 2017/05/01 by Phillip.Kavan

	#jira UE-44219 - Nativizing a Blueprint class with a nativized DOBP class dependency will no longer lead to a compile error at cook/nativization time.

	- Modified the FGatherConvertedClassDependencies ctor to properly handle DOBPs in exclusive mode that have been explicitly enabled for nativization. Previously, this code wasn't taking that possibility into account, and as a result could lead to a missing header file in a dependent nativized class body's include set.
	- Modified FGatherConvertedClassDependencies::GetFirstNativeOrConvertedClass() to remove the 'bExcludeBPDataOnly' parameter, as it was primarily just being used for a redundant exclusion check when called from the FGatherConvertedClassDependencies ctor. That call site has now been modified to start searching from the super class instead. Additionally, any DOBPs will already fail the preceding WillClassBeConverted() check if they have not been explicitly enabled for nativization in exclusive mode, and will always fail if nativizing in inclusive mode. The extra check was breaking the explicitly-enabled case, so it was removed to allow explicitly-enabled DOBPs to pass.

	Notes:
	- Allowing for explicitly-enabled DOBPs in exclusive mode may be removed in a future change, but since it is currently supported, the changes noted above will at least ensure that the generated code will compile properly for now.

Change 3416570 on 2017/05/01 by mason.seay

	Added UMG test to map.  Tweaked force feedback test

Change 3416580 on 2017/05/01 by mason.seay

	Resubmitting sub levels

Change 3416597 on 2017/05/01 by Dan.Oconnor

	Compilation manager iteration, adds machinery for individual blueprint compilation, adds comments, cleans up duplicated code

Change 3416636 on 2017/05/01 by Phillip.Kavan

	#jira UE-44505 - Potential fix for a low-repro crash tied to the Blueprint graph context menu.

	Change summary:
	- Switched FBlueprintActionInfo::ActionOwner to be a weak object reference.

Change 3416960 on 2017/05/01 by Dan.Oconnor

	Use compilation manager when clicking the compile button, PIE'ing, etc

Change 3417207 on 2017/05/01 by Ben.Zeigler

	Fix issue with None strings causing default value parsing failures
	Add SetPinDefaultValueAtConstruction needed by some other changes

Change 3417519 on 2017/05/01 by Ben.Zeigler

	Fix BP compile errors caused by local variables with invalid default values. There's no reason to set autogenerated here because the nodes are transient and invisible in the UI.
	There is still a problem here, local variables are not getting their default values validated when type is changed, so you end up with an integer that has the default value of a struct.

Change 3418659 on 2017/05/02 by Ben.Zeigler

	#jira UE-44534 Fix it so animation node pins get properly created autogenerated default values that are based on the node struct defaults. This fixes issues when they are reset to other defaults
	#jira UE-44532 Fix it so connecting an animation asset pin on a node player resets the pin value to the autogenerated default instead of the cached asset. This was causing old unused assets to get unnecessarily cooked
	Fix it so any animation node with an exposed pin that is an object property will reset that object propery when the pin is exposed. This fixes UE-31015 in a generic way
	Change the OptionalPinManager to take a Defaults address as well as a current address, to allow setting autogenerated defaults properly
	Remove Import/ExportKismetDefaultValueToProperty as they were redundant with PropertyValueFromString and were using the wrong pin setting functions, replaced with PropertyValueFromString_Direct and calling the schema pin set functions
	I need to write some backward compatibility code to fix existing nodes, I'll do that in a later checkin

Change 3418700 on 2017/05/02 by Ben.Zeigler

	Actually fix None object paths for real this time. I did not test sufficiently before

Change 3418811 on 2017/05/02 by Ben.Zeigler

	Fix existing animation blueprint nodes with dead asset references duplicated by pins. This code can be applied independent of the other change to fix specific games

Change 3419165 on 2017/05/02 by Dan.Oconnor

	Add misc. functionality from FKismetEditorUtilities::CompileBlueprint

Change 3419202 on 2017/05/02 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3417825

	#rnx

Change 3419236 on 2017/05/02 by mason.seay

	Removed OnPressed event from Widget BP

Change 3419314 on 2017/05/02 by Marc.Audy

	Fix bad auto-resolve

	#rnx

Change 3419524 on 2017/05/02 by Marc.Audy

	PR #3528: Improved Input BP library node display names (Contributed by projectgheist)
	#jira UE-44587
	#rn Improved Input BP library node display names

Change 3419570 on 2017/05/02 by Zak.Middleton

	#ue4 - Fix typo in TFunctionRef comment/example.

Change 3419709 on 2017/05/02 by Dan.Oconnor

	Fix missing category metadata on SkeletonGeneratedClass when using compilation manager

Change 3419756 on 2017/05/02 by Dan.Oconnor

	Remove unintentional verbosity increase

Change 3420875 on 2017/05/03 by Marc.Audy

	Make IsExecPin static
	Minor optimization to IsMetaPin

	#rnx

Change 3420981 on 2017/05/03 by Marc.Audy

	Change tagging temporarily until other changes are done so that we don't have warnings in the meantime

	#rnx

Change 3421367 on 2017/05/03 by Marc.Audy

	Manually introduce changes from CL# 3398673 in 4.16 that failed to make it to Dev-Framework as a result of the integration submitted as CL# 3401725.

	#rnx

Change 3421685 on 2017/05/03 by Ben.Zeigler

	#jira UE-23001 Convert literal Asset ID/Class ID pins to store path as string instead of as hard object reference. Old pins are fixed on load, after resaving the hard references will go away
	Refactor the way that FStringAssetReference and FAssetPtr are serialized, it now does the various fixups in FStringAssetReference::SerializePath, which is called from archivers
	Change it so the asset registry reads in a list of all scanned redirectors and adds them to GRedirectCollector, this means that saving a string asset reference will automatically fix it up to point to the redirector destination
	Change the default behavior of FAssetPtr serialize on ArchiveUObject to match what most of it's children want, and remove several special case hacks. It now serializes as asset reference when saving/loading, and as object for other cases
	Deprecate StringAssetReferenceLoaded/StringAssetReferenceSaving delegates, replace with PreSavePath and PostLoadPath on FStringAssetReference
	Make AssetLongPathname private on FStringAssetReference, it was deprecated in 4.9

Change 3421728 on 2017/05/03 by Phillip.Kavan

	Mirror CL 3408285 from //UE4/Release-4.16.

	#jira UE-44124

	#rnx

Change 3422370 on 2017/05/03 by Dan.Oconnor

	Mirror 3422359

	Implement UBlueprintGeneratedClass::NeedsLoadForEditorGame to match UBlueprint, also tag a class's CDO as NeedsLoadForEditorGame.

	This prevents us from failing to load a UBlueprint's GeneratedClass when running the editor with -server.

	#jira UE-44659

Change 3423192 on 2017/05/04 by Ben.Zeigler

	CIS Fix

Change 3423305 on 2017/05/04 by Ben.Zeigler

	Fix "Missing opening parenthesis" warnings for Vector and Rotator the same way they were fixed for Transform

Change 3423358 on 2017/05/04 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3422809

	#rnx

Change 3423766 on 2017/05/04 by Ben.Zeigler

	#jira UE-44680 Delete some corrupted redirectors that are no longer in use

Change 3423804 on 2017/05/04 by Dan.Oconnor

	Honor SaveIntermediateCompilerResults when using compilation manager

Change 3424010 on 2017/05/04 by Marc.Audy

	Validate that switch string cases are unique

Change 3424011 on 2017/05/04 by Marc.Audy

	Re-fix switch node default pin not appearing as an exec output
	Remove unused boolean

Change 3424071 on 2017/05/04 by Ben.Zeigler

	Delete FixupRedirects commandlet, replace with -FixupRedirects/FixupRedirectors option on ResavePackages. This new method is much faster than the old commandlet as it uses the asset registry vs loading all packages, fixing up all redirectors in Fortnite only took about an hour vs 12+ hours the old way
	Removed some hacky bits in Core that only existed to support FixupRedirects
	Change it so the AssetRegistry listens to DirectoryWatcher callbacks in commandlets now that commandlets use the asset registry properly. This won't do anything unless you tick directory watcher the way that ResavePackages does

Change 3424313 on 2017/05/04 by Dan.Oconnor

	Address missing property flags on SkeletonGeneratedClass when using compilation manager
	#jira UE-44705

Change 3424325 on 2017/05/04 by Phillip.Kavan

	#jira UE-44222 - Move nativized UDS implementation details into its own .cpp file in order to avoid circular dependencies.

	Change summary:
	- Modified IKismetCompilerInterface::GenerateCppCodeForStruct() to include an output parameter for CPP source and modified FKismet2CompilerModule to match the updated API.
	- Modified IBlueprintCompilerCppBackend::GenerateCodeFromStruct() to include an output parameter for CPP source and modified FBlueprintCompilerCppBackendBase to match the updated API.
	- Modified FBlueprintNativeCodeGenUtils::GenerateCppCode() to adjust the call to GenerateCppCodeForStruct() to include CPP source output.
	- Modified FGatherConvertedClassDependencies::DependenciesForHeader() to switch UDS property dependencies to be forward declarations rather than includes (for default value init code).
	- Modified FEmitDefaultValueHelper::GenerateGetDefaultValue() to emit implementation details to the 'Body' container, and adjust the header content to be a declaration only.
	- Modified FIncludeHeaderHelper::EmitInner() to exclude a potentially-redundant line for the module's .h file, for the case when the caller has included the base filename in the 'AlreadyIncluded' set.
	- Modified FEmitterLocalContext::FindGloballyMappedObject() to limit the 'TryUsedAssetsList' path to UClass conversions only (since that requires a UDynamicClass target to work).
	- Modified FGatherConvertedClassDependencies::DependenciesForHeader() to only include BPGC fields if they are also being converted. Eliminates an issue with missing header files in generated code.

Change 3424359 on 2017/05/04 by Ben.Zeigler

	Fix issue where StreamableManager would break when requesting an async load that failed the first time. Because our game supports downloading assets during gameplay it's not safe to assume it will never load again.
	Port of CL #3424159

Change 3424367 on 2017/05/04 by Ben.Zeigler

	Fix some asset manager warnings to not go off in invalid cases

Change 3425270 on 2017/05/05 by Marc.Audy

	Pack booleans/enums in UEdGraphNode and FOptionalPinFromProperty

	#rnx

Change 3425696 on 2017/05/05 by Ben.Zeigler

	#jira UE-44672 Fix it so select node option pins get populated with default values properly
	#jira UE-43927 Fix it so select node opion pin type is correctly maintained accross node recreation, as opposed to deriving from the attached pins
	#jira UE-44675 Fix it to correctly refresh select node when switching from bool to integer index

Change 3425833 on 2017/05/05 by Ben.Zeigler

	#jira UE-31749 Fix it so Undo works properly when modifying a local variable
	#jira UE-44736 Fix it so changing the type of a local variable correctly resets the default value

Change 3425890 on 2017/05/05 by Marc.Audy

	Fix Copy/Paste of child actor components losing the template
	#jira UE-44566

Change 3425947 on 2017/05/05 by Ben.Zeigler

	This was meant to be part of last checkin

Change 3425959 on 2017/05/05 by Ben.Zeigler

	#jira UE-44692 Fix it so only the sequentially last node can be removed from a Switch On Int, and for Switch On Name stop it from removing an exec pin if it's the only non-default one

Change 3425979 on 2017/05/05 by Dan.Oconnor

	PVS fix

Change 3425985 on 2017/05/05 by Phillip.Kavan

	Fix an uninitialized variable.

	#rnx

Change 3426043 on 2017/05/05 by Ben.Zeigler

	#jira UE-35583 Correctly refresh array node UI when connecting pins that change it away from wildcard

Change 3426174 on 2017/05/05 by Zak.Middleton

	#ue4 - Avoid call to virtual getSimulationFilterData() to only use it when needed in PreFilter if we actually have items in the IgnoreComponents list (which is rare). The sim filter data 'word2' stores the component ID.

Change 3426621 on 2017/05/05 by Phillip.Kavan

	#jira UE-44708 - Fix an issue that re-introduced component data loss in a non-nativized child Blueprint class with a nativized parent Blueprint class.

	Change summary:
	- Removed an unnecessary additional check I had for the presence of "-NativizeAssets" switch on the command line in UBlueprint::BeginCacheForCookedPlatformData(). This check was failing because the usage was recently changed to include an optional value. It was not needed anyway so I just removed it.

	#rnx

Change 3426906 on 2017/05/05 by Ben.Zeigler

	#jira UE-11189 Fix function/macro input default values to show as a pin customization instead of as a broken text box that doesn't work correctly for most types. This fixes enums and provide validation for other types
	Types that don't have a customization (most structs) will now show any more, they did not work before either
	#jira UE-21754 Hide function default values if pass by reference is set
	Fix it so changing input parameter will also reset default value, to avoid having the wrong type value set and to work the same as local variables

Change 3426941 on 2017/05/05 by Dan.Oconnor

	Fix determinstic cooking of LoadAssetClass nodes in macros

Change 3427021 on 2017/05/05 by Dan.Oconnor

	Build fix, make initialization order in source match artifact

	#rnx

Change 3427135 on 2017/05/05 by Phillip.Kavan

	#jira UE-44702 - Restore code-based interface classes to Blueprint editor UI.

	Change summary:
	- Partially backed out CL# 3348513 to return to previous behavior for 4.16. The UI is no longer filtering on the __is_abstract() type trait for interface classes.
	- Modified FNativeClassHeaderGenerator::ExportClassFromSourceFileInner() to emit the _getUObject() declaration for native interface types as a default implementation that returns NULL rather than as a pure virtual declaration.

	#rnx

Change 3427144 on 2017/05/06 by Marc.Audy

	Fix init order

	#rnx

Change 3427146 on 2017/05/06 by Marc.Audy

	remove stray semicolon

	#rnx

Change 3427242 on 2017/05/06 by Phillip.Kavan

	#jira UE-44744 - Fix a regression in which a UMG Widget Blueprint property not explicitly marked as a variable would cause Blueprint nativization to fail at package time.

	Change summary:
	- Modified FWidgetBlueprintCompiler::CreateClassVariablesFromBlueprint() to only add 'Category' metadata when we set the 'CPF_BlueprintVisible' flag on the UProperty, which in is now tied to whether or not the property has been explcitly marked as a variable. This avoids a UHT warning when compiling the nativized codegen that would cause packaging to fail.

	#rnx

Change 3427720 on 2017/05/08 by Dan.Oconnor

	Backing out 3419202

	#rnx

Change 3427725 on 2017/05/08 by Dan.Oconnor

	SA fix

	#rnx

Change 3427734 on 2017/05/08 by Dan.Oconnor

	More exhaustive GEditor null checks, to appease SA

	#rnx

Change 3427882 on 2017/05/08 by Marc.Audy

	Properly order all booleans in intialization

	#rnx

Change 3428049 on 2017/05/08 by Marc.Audy

	Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 3427804

	#rnx

Change 3428523 on 2017/05/08 by Ben.Zeigler

	#jira UE-44781 Refresh function input UI when blueprint graph refreshes, needed as pins may have gone away

Change 3428563 on 2017/05/08 by Ben.Zeigler

	#jira UE-44783 If setting a hard reference pin type from a string, load the referenced object.

Change 3428595 on 2017/05/08 by Dan.Oconnor

	Avoid node reconstruction when we're compiling a blueprint with no linker (e.g., a duplicated blueprint)

	#jira UE-44777

Change 3428599 on 2017/05/08 by Ben.Zeigler

	#jira UE-44789 Fix string asset renamer to not mark IsPersistent becuase that crashes in lightmap code, change it so the path fixup doesn't require the persistent flag

Change 3428609 on 2017/05/08 by Dan.Oconnor

	Improved fix for UE-44777

	#jira UE-44777
	#rnx

Change 3429176 on 2017/05/08 by Phillip.Kavan

	#jira UE-44755 - Fix nativization build errors when packaging a game project that is not IWYU-compliant for a build target that disables PCH files.

	- Mirrored from //UE4/Release-4.16 (CL# 3429030).

	#rnx

Change 3429198 on 2017/05/08 by Phillip.Kavan

	CIS fix.

	#rnx

Change 3429583 on 2017/05/08 by Ben.Zeigler

	Fix SGraphPinClass to work properly after my changes to allow unloaded assets. For Class pins we need to store separate Runtime and Editor asset data objects, as one has _C and refers to the class, and the other doesn't and refers to the blueprint. The content browser wants the editor path, the pin defaults want the runtime path.
	Change default value widgets to look more like properties widgets by forcing them to act as highlighted and disabling black background

Change 3429640 on 2017/05/08 by Marc.Audy

	Fix issues with select nodes in macros connected to wildcard pins.
	#jira UE-44799

	#rnx

Change 3429890 on 2017/05/08 by Ben.Zeigler

	Fix function/macro defaults to properly propagate when changed using the new edit UI
	Refactor some code out of the details customization into the k2 schema
	Disable defaults UI for object/class/interface hard references as it is disabled in KismetCompiler

Change 3429947 on 2017/05/08 by Michael.Noland

	Core: Backing out CL# 3394352 (marking FDateTime and FTimespan nonexport member Tick with UPROPERTY()), which will re-break UE-39921 but fix UE-44418
	There appears to be a more serious underlying issue with how the CDO is instanced which needs to be addressed
	#jira UE-44418

	#reimplementing 3411681 from Release 4.16

Change 3429987 on 2017/05/08 by Ben.Zeigler

	#jira UE-44798 Do a better job of validating object paths saved as default values, due to an old bug with local variables some object paths are saved as struct exportext
	At load time clear invalid default value for local variables
	Add IsValidObjectPath to FPackageName that validates the passed in path would be valid to load with LoadObject

Change 3430392 on 2017/05/09 by Marc.Audy

	Fix SA CIS error

	#rnx

Change 3430747 on 2017/05/09 by Ben.Zeigler

	#jira UE-44836 Don't reconstruct node during callback for param value changing, this can happen during a reconstruction and recursive reconstruction is unsafe
	Don't call ModifyUserDefinedPinDefaultValue unless the default value has actually changed

Change 3431027 on 2017/05/09 by Marc.Audy

	Fix BPRW mark up causing Ocean warnings

	#rnx

Change 3431353 on 2017/05/09 by Marc.Audy

	Fix UHT error due to exposing FJsonObjectWrapper to blueprints

	#rnx

[CL 3431398 by Marc Audy in Main branch]
2017-05-09 17:15:32 -04:00

1948 lines
74 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "AssetTools.h"
#include "Factories/Factory.h"
#include "Misc/MessageDialog.h"
#include "HAL/FileManager.h"
#include "Misc/FileHelper.h"
#include "Misc/Paths.h"
#include "Misc/ScopedSlowTask.h"
#include "UObject/UObjectHash.h"
#include "UObject/UObjectIterator.h"
#include "Engine/Blueprint.h"
#include "Exporters/Exporter.h"
#include "Editor/EditorEngine.h"
#include "ISourceControlOperation.h"
#include "SourceControlOperations.h"
#include "ISourceControlModule.h"
#include "Editor/UnrealEdEngine.h"
#include "Settings/EditorLoadingSavingSettings.h"
#include "ThumbnailRendering/ThumbnailManager.h"
#include "Editor.h"
#include "EditorDirectories.h"
#include "FileHelpers.h"
#include "UnrealEdGlobals.h"
#include "AssetToolsLog.h"
#include "AssetToolsModule.h"
#include "Framework/MultiBox/MultiBoxBuilder.h"
#include "IClassTypeActions.h"
#include "AssetTypeActions/AssetTypeActions_Blueprint.h"
#include "AssetTypeActions/AssetTypeActions_Curve.h"
#include "AssetTypeActions/AssetTypeActions_MaterialInterface.h"
#include "AssetTypeActions/AssetTypeActions_SkeletalMesh.h"
#include "AssetTypeActions/AssetTypeActions_FbxSceneImportData.h"
#include "AssetTypeActions/AssetTypeActions_Texture.h"
#include "AssetTypeActions/AssetTypeActions_TextureRenderTarget.h"
#include "AssetTypeActions/AssetTypeActions_VectorField.h"
#include "AssetTypeActions/AssetTypeActions_AnimationAsset.h"
#include "AssetTypeActions/AssetTypeActions_AnimBlueprint.h"
#include "AssetTypeActions/AssetTypeActions_AnimComposite.h"
#include "AssetTypeActions/AssetTypeActions_AnimMontage.h"
#include "AssetTypeActions/AssetTypeActions_AnimSequence.h"
#include "AssetTypeActions/AssetTypeActions_BlendSpace.h"
#include "AssetTypeActions/AssetTypeActions_AimOffset.h"
#include "AssetTypeActions/AssetTypeActions_BlendSpace1D.h"
#include "AssetTypeActions/AssetTypeActions_AimOffset1D.h"
#include "AssetTypeActions/AssetTypeActions_CameraAnim.h"
#include "AssetTypeActions/AssetTypeActions_TextureRenderTarget2D.h"
#include "AssetTypeActions/AssetTypeActions_CanvasRenderTarget2D.h"
#include "AssetTypeActions/AssetTypeActions_CurveFloat.h"
#include "AssetTypeActions/AssetTypeActions_CurveTable.h"
#include "AssetTypeActions/AssetTypeActions_CurveVector.h"
#include "AssetTypeActions/AssetTypeActions_CurveLinearColor.h"
#include "AssetTypeActions/AssetTypeActions_DataAsset.h"
#include "AssetTypeActions/AssetTypeActions_DataTable.h"
#include "AssetTypeActions/AssetTypeActions_DestructibleMesh.h"
#include "AssetTypeActions/AssetTypeActions_Enum.h"
#include "AssetTypeActions/AssetTypeActions_Class.h"
#include "AssetTypeActions/AssetTypeActions_Struct.h"
#include "AssetTypeActions/AssetTypeActions_Font.h"
#include "AssetTypeActions/AssetTypeActions_FontFace.h"
#include "AssetTypeActions/AssetTypeActions_ForceFeedbackEffect.h"
#include "AssetTypeActions/AssetTypeActions_SubsurfaceProfile.h"
#include "AssetTypeActions/AssetTypeActions_InstancedFoliageSettings.h"
#include "AssetTypeActions/AssetTypeActions_InterpData.h"
#include "AssetTypeActions/AssetTypeActions_LandscapeLayer.h"
#include "AssetTypeActions/AssetTypeActions_LandscapeGrassType.h"
#include "AssetTypeActions/AssetTypeActions_Material.h"
#include "AssetTypeActions/AssetTypeActions_MaterialFunction.h"
#include "AssetTypeActions/AssetTypeActions_MaterialInstanceConstant.h"
#include "AssetTypeActions/AssetTypeActions_MaterialParameterCollection.h"
#include "AssetTypeActions/AssetTypeActions_ObjectLibrary.h"
#include "AssetTypeActions/AssetTypeActions_ParticleSystem.h"
#include "AssetTypeActions/AssetTypeActions_PhysicalMaterial.h"
#include "AssetTypeActions/AssetTypeActions_PhysicsAsset.h"
#include "AssetTypeActions/AssetTypeActions_PoseAsset.h"
#include "AssetTypeActions/AssetTypeActions_PreviewMeshCollection.h"
#include "AssetTypeActions/AssetTypeActions_ProceduralFoliageSpawner.h"
#include "AssetTypeActions/AssetTypeActions_Redirector.h"
#include "AssetTypeActions/AssetTypeActions_Rig.h"
#include "AssetTypeActions/AssetTypeActions_Skeleton.h"
#include "AssetTypeActions/AssetTypeActions_SlateBrush.h"
#include "AssetTypeActions/AssetTypeActions_SlateWidgetStyle.h"
#include "AssetTypeActions/AssetTypeActions_StaticMesh.h"
#include "AssetTypeActions/AssetTypeActions_Texture2D.h"
#include "AssetTypeActions/AssetTypeActions_TextureCube.h"
#include "AssetTypeActions/AssetTypeActions_TextureRenderTargetCube.h"
#include "AssetTypeActions/AssetTypeActions_TextureLightProfile.h"
#include "AssetTypeActions/AssetTypeActions_TouchInterface.h"
#include "AssetTypeActions/AssetTypeActions_VectorFieldAnimated.h"
#include "AssetTypeActions/AssetTypeActions_VectorFieldStatic.h"
#include "AssetTypeActions/AssetTypeActions_World.h"
#include "SDiscoveringAssetsDialog.h"
#include "AssetFixUpRedirectors.h"
#include "ObjectTools.h"
#include "PackageTools.h"
#include "AssetRegistryModule.h"
#include "DesktopPlatformModule.h"
#include "IContentBrowserSingleton.h"
#include "ContentBrowserModule.h"
#include "SPackageReportDialog.h"
#include "EngineAnalytics.h"
#include "AnalyticsEventAttribute.h"
#include "Interfaces/IAnalyticsProvider.h"
#include "Logging/MessageLog.h"
#include "UnrealExporter.h"
#include "Framework/Notifications/NotificationManager.h"
#include "Framework/Application/SlateApplication.h"
#include "Widgets/Notifications/SNotificationList.h"
#include "AutomatedAssetImportData.h"
#define LOCTEXT_NAMESPACE "AssetTools"
FAssetTools::FAssetTools()
: AssetRenameManager( MakeShareable(new FAssetRenameManager) )
, AssetFixUpRedirectors( MakeShareable(new FAssetFixUpRedirectors) )
, NextUserCategoryBit( EAssetTypeCategories::FirstUser )
{
// Register the built-in advanced categories
AllocatedCategoryBits.Add(TEXT("_BuiltIn_0"), FAdvancedAssetCategory(EAssetTypeCategories::Animation, LOCTEXT("AnimationAssetCategory", "Animation")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_1"), FAdvancedAssetCategory(EAssetTypeCategories::Blueprint, LOCTEXT("BlueprintAssetCategory", "Blueprints")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_2"), FAdvancedAssetCategory(EAssetTypeCategories::MaterialsAndTextures, LOCTEXT("MaterialAssetCategory", "Materials & Textures")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_3"), FAdvancedAssetCategory(EAssetTypeCategories::Sounds, LOCTEXT("SoundAssetCategory", "Sounds")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_4"), FAdvancedAssetCategory(EAssetTypeCategories::Physics, LOCTEXT("PhysicsAssetCategory", "Physics")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_5"), FAdvancedAssetCategory(EAssetTypeCategories::UI, LOCTEXT("UserInterfaceAssetCategory", "User Interface")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_6"), FAdvancedAssetCategory(EAssetTypeCategories::Misc, LOCTEXT("MiscellaneousAssetCategory", "Miscellaneous")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_7"), FAdvancedAssetCategory(EAssetTypeCategories::Gameplay, LOCTEXT("GameplayAssetCategory", "Gameplay")));
AllocatedCategoryBits.Add(TEXT("_BuiltIn_8"), FAdvancedAssetCategory(EAssetTypeCategories::Media, LOCTEXT("MediaAssetCategory", "Media")));
EAssetTypeCategories::Type BlendablesCategoryBit = RegisterAdvancedAssetCategory(FName(TEXT("Blendables")), LOCTEXT("BlendablesAssetCategory", "Blendables"));
// Register the built-in asset type actions
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AnimationAsset) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AnimBlueprint) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AnimComposite) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AnimMontage) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AnimSequence) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AimOffset) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_AimOffset1D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_BlendSpace) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_PoseAsset));
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_BlendSpace1D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Blueprint) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CameraAnim) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CanvasRenderTarget2D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Curve) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CurveFloat) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CurveTable) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CurveVector) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_CurveLinearColor) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DataAsset) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DataTable) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_DestructibleMesh) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Enum) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Class) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Struct) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SceneImportData));
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Font) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_FontFace) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_ForceFeedbackEffect) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_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_ObjectLibrary) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_ParticleSystem) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_PhysicalMaterial) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_PhysicsAsset) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_PreviewMeshCollection) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_ProceduralFoliageSpawner) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Redirector) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Rig) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SkeletalMesh) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Skeleton) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SlateBrush) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_SlateWidgetStyle) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_StaticMesh) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Texture) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_Texture2D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureCube) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureRenderTarget) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureRenderTarget2D) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureRenderTargetCube) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TextureLightProfile) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_TouchInterface) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_VectorField) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_VectorFieldAnimated) );
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_VectorFieldStatic) );
// Note: Please don't add any more actions here! They belong in an editor-only module that is more tightly
// coupled to your new system, and you should not create a dependency on your new system from AssetTools.
if ( UEditorEngine::IsUsingWorldAssets() )
{
RegisterAssetTypeActions( MakeShareable(new FAssetTypeActions_World) );
}
}
FAssetTools::~FAssetTools()
{
}
void FAssetTools::RegisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& NewActions)
{
AssetTypeActionsList.Add(NewActions);
}
void FAssetTools::UnregisterAssetTypeActions(const TSharedRef<IAssetTypeActions>& ActionsToRemove)
{
AssetTypeActionsList.Remove(ActionsToRemove);
}
void FAssetTools::GetAssetTypeActionsList( TArray<TWeakPtr<IAssetTypeActions>>& OutAssetTypeActionsList ) const
{
for (auto ActionsIt = AssetTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
{
OutAssetTypeActionsList.Add(*ActionsIt);
}
}
TWeakPtr<IAssetTypeActions> FAssetTools::GetAssetTypeActionsForClass( UClass* Class ) const
{
TSharedPtr<IAssetTypeActions> MostDerivedAssetTypeActions;
for (int32 TypeActionsIdx = 0; TypeActionsIdx < AssetTypeActionsList.Num(); ++TypeActionsIdx)
{
TSharedRef<IAssetTypeActions> TypeActions = AssetTypeActionsList[TypeActionsIdx];
UClass* SupportedClass = TypeActions->GetSupportedClass();
if ( Class->IsChildOf(SupportedClass) )
{
if ( !MostDerivedAssetTypeActions.IsValid() || SupportedClass->IsChildOf( MostDerivedAssetTypeActions->GetSupportedClass() ) )
{
MostDerivedAssetTypeActions = TypeActions;
}
}
}
return MostDerivedAssetTypeActions;
}
EAssetTypeCategories::Type FAssetTools::RegisterAdvancedAssetCategory(FName CategoryKey, FText CategoryDisplayName)
{
EAssetTypeCategories::Type Result = FindAdvancedAssetCategory(CategoryKey);
if (Result == EAssetTypeCategories::Misc)
{
if (NextUserCategoryBit != 0)
{
// Register the category
Result = (EAssetTypeCategories::Type)NextUserCategoryBit;
AllocatedCategoryBits.Add(CategoryKey, FAdvancedAssetCategory(Result, CategoryDisplayName));
// Advance to the next bit, or store that we're out
if (NextUserCategoryBit == EAssetTypeCategories::LastUser)
{
NextUserCategoryBit = 0;
}
else
{
NextUserCategoryBit = NextUserCategoryBit << 1;
}
}
else
{
UE_LOG(LogAssetTools, Warning, TEXT("RegisterAssetTypeCategory(\"%s\", \"%s\") failed as all user bits have been exhausted (placing into the Misc category instead)"), *CategoryKey.ToString(), *CategoryDisplayName.ToString());
}
}
return Result;
}
EAssetTypeCategories::Type FAssetTools::FindAdvancedAssetCategory(FName CategoryKey) const
{
if (const FAdvancedAssetCategory* ExistingCategory = AllocatedCategoryBits.Find(CategoryKey))
{
return ExistingCategory->CategoryType;
}
else
{
return EAssetTypeCategories::Misc;
}
}
void FAssetTools::GetAllAdvancedAssetCategories(TArray<FAdvancedAssetCategory>& OutCategoryList) const
{
AllocatedCategoryBits.GenerateValueArray(OutCategoryList);
}
void FAssetTools::RegisterClassTypeActions(const TSharedRef<IClassTypeActions>& NewActions)
{
ClassTypeActionsList.Add(NewActions);
}
void FAssetTools::UnregisterClassTypeActions(const TSharedRef<IClassTypeActions>& ActionsToRemove)
{
ClassTypeActionsList.Remove(ActionsToRemove);
}
void FAssetTools::GetClassTypeActionsList( TArray<TWeakPtr<IClassTypeActions>>& OutClassTypeActionsList ) const
{
for (auto ActionsIt = ClassTypeActionsList.CreateConstIterator(); ActionsIt; ++ActionsIt)
{
OutClassTypeActionsList.Add(*ActionsIt);
}
}
TWeakPtr<IClassTypeActions> FAssetTools::GetClassTypeActionsForClass( UClass* Class ) const
{
TSharedPtr<IClassTypeActions> MostDerivedClassTypeActions;
for (int32 TypeActionsIdx = 0; TypeActionsIdx < ClassTypeActionsList.Num(); ++TypeActionsIdx)
{
TSharedRef<IClassTypeActions> TypeActions = ClassTypeActionsList[TypeActionsIdx];
UClass* SupportedClass = TypeActions->GetSupportedClass();
if ( Class->IsChildOf(SupportedClass) )
{
if ( !MostDerivedClassTypeActions.IsValid() || SupportedClass->IsChildOf( MostDerivedClassTypeActions->GetSupportedClass() ) )
{
MostDerivedClassTypeActions = TypeActions;
}
}
}
return MostDerivedClassTypeActions;
}
bool FAssetTools::GetAssetActions( const TArray<UObject*>& InObjects, FMenuBuilder& MenuBuilder, bool bIncludeHeading )
{
bool bAddedActions = false;
if ( InObjects.Num() )
{
// Find the most derived common class for all passed in Objects
UClass* CommonClass = InObjects[0]->GetClass();
for (int32 ObjIdx = 1; ObjIdx < InObjects.Num(); ++ObjIdx)
{
while (!InObjects[ObjIdx]->IsA(CommonClass))
{
CommonClass = CommonClass->GetSuperClass();
}
}
// Get the nearest common asset type for all the selected objects
TSharedPtr<IAssetTypeActions> CommonAssetTypeActions = GetAssetTypeActionsForClass(CommonClass).Pin();
// If we found a common type actions object, get actions from it
if ( CommonAssetTypeActions.IsValid() && CommonAssetTypeActions->HasActions(InObjects) )
{
if ( bIncludeHeading )
{
MenuBuilder.BeginSection("GetAssetActions", FText::Format( LOCTEXT("AssetSpecificOptionsMenuHeading", "{0} Actions"), CommonAssetTypeActions->GetName() ) );
}
// Get the actions
CommonAssetTypeActions->GetActions(InObjects, MenuBuilder);
if ( bIncludeHeading )
{
MenuBuilder.EndSection();
}
bAddedActions = true;
}
}
return bAddedActions;
}
struct FRootedOnScope
{
UObject* Obj;
FRootedOnScope(UObject* InObj) : Obj(nullptr)
{
if (InObj && !InObj->IsRooted())
{
Obj = InObj;
Obj->AddToRoot();
}
}
~FRootedOnScope()
{
if (Obj)
{
Obj->RemoveFromRoot();
}
}
};
UObject* FAssetTools::CreateAsset(const FString& AssetName, const FString& PackagePath, UClass* AssetClass, UFactory* Factory, FName CallingContext)
{
FRootedOnScope DontGCFactory(Factory);
// Verify the factory class
if ( !ensure(AssetClass || Factory) )
{
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("MustSupplyClassOrFactory", "The new asset wasn't created due to a problem finding the appropriate factory or class for the new asset.") );
return nullptr;
}
if ( AssetClass && Factory && !ensure(AssetClass->IsChildOf(Factory->GetSupportedClass())) )
{
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("InvalidFactory", "The new asset wasn't created because the supplied factory does not support the supplied class.") );
return nullptr;
}
const FString PackageName = PackageTools::SanitizePackageName(PackagePath + TEXT("/") + AssetName);
// Make sure we can create the asset without conflicts
if ( !CanCreateAsset(AssetName, PackageName, LOCTEXT("CreateANewObject", "Create a new object")) )
{
return nullptr;
}
UClass* ClassToUse = AssetClass ? AssetClass : (Factory ? Factory->GetSupportedClass() : nullptr);
UPackage* Pkg = CreatePackage(nullptr,*PackageName);
UObject* NewObj = nullptr;
EObjectFlags Flags = RF_Public|RF_Standalone|RF_Transactional;
if ( Factory )
{
NewObj = Factory->FactoryCreateNew(ClassToUse, Pkg, FName( *AssetName ), Flags, nullptr, GWarn, CallingContext);
}
else if ( AssetClass )
{
NewObj = NewObject<UObject>(Pkg, ClassToUse, FName(*AssetName), Flags);
}
if( NewObj )
{
// Notify the asset registry
FAssetRegistryModule::AssetCreated(NewObj);
// analytics create record
FAssetTools::OnNewCreateRecord(AssetClass, false);
// Mark the package dirty...
Pkg->MarkPackageDirty();
}
return NewObj;
}
UObject* FAssetTools::CreateAsset(UClass* AssetClass, UFactory* Factory, FName CallingContext)
{
if (Factory != nullptr)
{
// Determine the starting path. Try to use the most recently used directory
FString AssetPath;
const FString DefaultFilesystemDirectory = FEditorDirectories::Get().GetLastDirectory(ELastDirectory::NEW_ASSET);
if (DefaultFilesystemDirectory.IsEmpty() || !FPackageName::TryConvertFilenameToLongPackageName(DefaultFilesystemDirectory, AssetPath))
{
// No saved path, just use the game content root
AssetPath = TEXT("/Game");
}
FString PackageName;
FString AssetName;
CreateUniqueAssetName(AssetPath / Factory->GetDefaultNewAssetName(), TEXT(""), PackageName, AssetName);
return CreateAssetWithDialog(AssetName, AssetPath, AssetClass, Factory, CallingContext);
}
return nullptr;
}
UObject* FAssetTools::CreateAssetWithDialog(const FString& AssetName, const FString& PackagePath, UClass* AssetClass, UFactory* Factory, FName CallingContext)
{
FSaveAssetDialogConfig SaveAssetDialogConfig;
SaveAssetDialogConfig.DialogTitleOverride = LOCTEXT("SaveAssetDialogTitle", "Save Asset As");
SaveAssetDialogConfig.DefaultPath = PackagePath;
SaveAssetDialogConfig.DefaultAssetName = AssetName;
SaveAssetDialogConfig.ExistingAssetPolicy = ESaveAssetDialogExistingAssetPolicy::AllowButWarn;
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
FString SaveObjectPath = ContentBrowserModule.Get().CreateModalSaveAssetDialog(SaveAssetDialogConfig);
if (!SaveObjectPath.IsEmpty())
{
FEditorDelegates::OnConfigureNewAssetProperties.Broadcast(Factory);
if (Factory->ConfigureProperties())
{
const FString SavePackageName = FPackageName::ObjectPathToPackageName(SaveObjectPath);
const FString SavePackagePath = FPaths::GetPath(SavePackageName);
const FString SaveAssetName = FPaths::GetBaseFilename(SavePackageName);
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::NEW_ASSET, PackagePath);
return CreateAsset(SaveAssetName, SavePackagePath, AssetClass, Factory, CallingContext);
}
}
return nullptr;
}
UObject* FAssetTools::DuplicateAssetWithDialog(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject)
{
FSaveAssetDialogConfig SaveAssetDialogConfig;
SaveAssetDialogConfig.DialogTitleOverride = LOCTEXT("DuplicateAssetDialogTitle", "Duplicate Asset As");
SaveAssetDialogConfig.DefaultPath = PackagePath;
SaveAssetDialogConfig.DefaultAssetName = AssetName;
SaveAssetDialogConfig.ExistingAssetPolicy = ESaveAssetDialogExistingAssetPolicy::AllowButWarn;
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
FString SaveObjectPath = ContentBrowserModule.Get().CreateModalSaveAssetDialog(SaveAssetDialogConfig);
if (!SaveObjectPath.IsEmpty())
{
const FString SavePackageName = FPackageName::ObjectPathToPackageName(SaveObjectPath);
const FString SavePackagePath = FPaths::GetPath(SavePackageName);
const FString SaveAssetName = FPaths::GetBaseFilename(SavePackageName);
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::NEW_ASSET, PackagePath);
return DuplicateAsset(SaveAssetName, SavePackagePath, OriginalObject);
}
return nullptr;
}
UObject* FAssetTools::DuplicateAsset(const FString& AssetName, const FString& PackagePath, UObject* OriginalObject)
{
// Verify the source object
if ( !OriginalObject )
{
FMessageDialog::Open( EAppMsgType::Ok, LOCTEXT("InvalidSourceObject", "The new asset wasn't created due to a problem finding the object to duplicate.") );
return nullptr;
}
const FString PackageName = PackagePath + TEXT("/") + AssetName;
// Make sure we can create the asset without conflicts
if ( !CanCreateAsset(AssetName, PackageName, LOCTEXT("DuplicateAnObject", "Duplicate an object")) )
{
return nullptr;
}
ObjectTools::FPackageGroupName PGN;
PGN.PackageName = PackageName;
PGN.GroupName = TEXT("");
PGN.ObjectName = AssetName;
TSet<UPackage*> ObjectsUserRefusedToFullyLoad;
UObject* NewObject = ObjectTools::DuplicateSingleObject(OriginalObject, PGN, ObjectsUserRefusedToFullyLoad);
if(NewObject != nullptr)
{
if ( ISourceControlModule::Get().IsEnabled() )
{
// Save package here if SCC is enabled because the user can use SCC to revert a change
TArray<UPackage*> OutermostPackagesToSave;
OutermostPackagesToSave.Add(NewObject->GetOutermost());
const bool bCheckDirty = false;
const bool bPromptToSave = false;
FEditorFileUtils::PromptForCheckoutAndSave(OutermostPackagesToSave, bCheckDirty, bPromptToSave);
// now attempt to branch, we can do this now as we should have a file on disk
SourceControlHelpers::BranchPackage(NewObject->GetOutermost(), OriginalObject->GetOutermost());
}
// analytics create record
FAssetTools::OnNewCreateRecord(NewObject->GetClass(), true);
}
return NewObject;
}
void FAssetTools::RenameAssets(const TArray<FAssetRenameData>& AssetsAndNames) const
{
AssetRenameManager->RenameAssets(AssetsAndNames);
}
TArray<UObject*> FAssetTools::ImportAssets(const FString& DestinationPath)
{
TArray<UObject*> ReturnObjects;
FString FileTypes, AllExtensions;
TArray<UFactory*> Factories;
// Get the list of valid factories
for( TObjectIterator<UClass> It ; It ; ++It )
{
UClass* CurrentClass = (*It);
if( CurrentClass->IsChildOf(UFactory::StaticClass()) && !(CurrentClass->HasAnyClassFlags(CLASS_Abstract)) )
{
UFactory* Factory = Cast<UFactory>( CurrentClass->GetDefaultObject() );
if( Factory->bEditorImport )
{
Factories.Add( Factory );
}
}
}
TMultiMap<uint32, UFactory*> FilterIndexToFactory;
// Generate the file types and extensions represented by the selected factories
ObjectTools::GenerateFactoryFileExtensions( Factories, FileTypes, AllExtensions, FilterIndexToFactory );
FileTypes = FString::Printf(TEXT("All Files (%s)|%s|%s"),*AllExtensions,*AllExtensions,*FileTypes);
// Prompt the user for the filenames
TArray<FString> OpenFilenames;
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
bool bOpened = false;
int32 FilterIndex = -1;
if ( DesktopPlatform )
{
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
bOpened = DesktopPlatform->OpenFileDialog(
ParentWindowWindowHandle,
LOCTEXT("ImportDialogTitle", "Import").ToString(),
FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_IMPORT),
TEXT(""),
FileTypes,
EFileDialogFlags::Multiple,
OpenFilenames,
FilterIndex
);
}
if ( bOpened )
{
if ( OpenFilenames.Num() > 0 )
{
UFactory* ChosenFactory = nullptr;
if (FilterIndex > 0)
{
ChosenFactory = *FilterIndexToFactory.Find(FilterIndex);
}
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_IMPORT, OpenFilenames[0]);
ReturnObjects = ImportAssets(OpenFilenames, DestinationPath, ChosenFactory);
}
}
return ReturnObjects;
}
TArray<UObject*> FAssetTools::ImportAssetsAutomated(const UAutomatedAssetImportData& ImportData) const
{
FAssetImportParams Params;
Params.bAutomated = true;
Params.bForceOverrideExisting = ImportData.bReplaceExisting;
Params.bSyncToBrowser = false;
Params.SpecifiedFactory = ImportData.Factory;
Params.ImportData = &ImportData;
return ImportAssetsInternal(ImportData.Filenames, ImportData.DestinationPath, nullptr, Params);
}
void 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.Emplace(Filename, DestinationPath);
}
}
}
TArray<UObject*> FAssetTools::ImportAssets(const TArray<FString>& Files, const FString& RootDestinationPath, UFactory* SpecifiedFactory, bool bSyncToBrowser, TArray<TPair<FString, FString>> *FilesAndDestinations) const
{
const bool bForceOverrideExisting = false;
FAssetImportParams Params;
Params.bAutomated = false;
Params.bForceOverrideExisting = false;
Params.bSyncToBrowser = bSyncToBrowser;
Params.SpecifiedFactory = SpecifiedFactory;
return ImportAssetsInternal(Files, RootDestinationPath, FilesAndDestinations, Params);
}
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 = 0;
bool bObjectExists = false;
int32 CharIndex = SanitizedBaseAssetName.Len() - 1;
while (CharIndex >= 0 && SanitizedBaseAssetName[CharIndex] >= TEXT('0') && SanitizedBaseAssetName[CharIndex] <= TEXT('9'))
{
--CharIndex;
}
FString TrailingInteger;
FString TrimmedBaseAssetName = SanitizedBaseAssetName;
if (SanitizedBaseAssetName.Len() > 0 && CharIndex == -1)
{
// This is the all numeric name, in this case we'd like to append _number, because just adding a number isn't great
TrimmedBaseAssetName += TEXT("_");
IntSuffix = 2;
}
if (CharIndex >= 0 && CharIndex < SanitizedBaseAssetName.Len() - 1)
{
TrailingInteger = SanitizedBaseAssetName.RightChop(CharIndex + 1);
TrimmedBaseAssetName = SanitizedBaseAssetName.Left(CharIndex + 1);
IntSuffix = FCString::Atoi(*TrailingInteger);
}
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
do
{
bObjectExists = false;
if ( IntSuffix < 1 )
{
OutAssetName = SanitizedBaseAssetName;
}
else
{
FString Suffix = FString::Printf(TEXT("%d"), IntSuffix);
while (Suffix.Len() < TrailingInteger.Len())
{
Suffix = TEXT("0") + Suffix;
}
OutAssetName = FString::Printf(TEXT("%s%s"), *TrimmedBaseAssetName, *Suffix);
}
OutPackageName = PackagePath + TEXT("/") + OutAssetName;
FString ObjectPath = OutPackageName + TEXT(".") + OutAssetName;
// Use the asset registry if possible to find existing assets without loading them
if ( !AssetRegistryModule.Get().IsLoadingAssets() )
{
FAssetData AssetData = AssetRegistryModule.Get().GetAssetByObjectPath(*ObjectPath);
if(AssetData.IsValid())
{
bObjectExists = true;
}
}
else
{
bObjectExists = LoadObject<UObject>(nullptr, *ObjectPath, nullptr, LOAD_NoWarn | LOAD_NoRedirects) != nullptr;
}
IntSuffix++;
}
while (bObjectExists != false);
}
bool 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))
{
// Try and load that package
UPackage* TempPackage = LoadPackage(nullptr, *TempFileName, LOAD_ForDiff|LOAD_DisableCompileOnLoad);
if(TempPackage != nullptr)
{
// Grab the old asset from that old package
UObject* OldObject = FindObject<UObject>(TempPackage, *InPackageName);
if(OldObject != nullptr)
{
/* Set the revision information*/
FRevisionInfo OldRevision;
OldRevision.Changelist = Revision->GetCheckInIdentifier();
OldRevision.Date = Revision->GetDate();
OldRevision.Revision = Revision->GetRevision();
FRevisionInfo NewRevision;
NewRevision.Revision = TEXT("");
DiffAssets(OldObject, InObject, OldRevision, NewRevision);
}
}
}
}
}
}
}
void 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);
}
}
TArray<UObject*> FAssetTools::ImportAssetsInternal(const TArray<FString>& Files, const FString& RootDestinationPath, TArray<TPair<FString, FString>> *FilesAndDestinationsPtr, const FAssetImportParams& Params) const
{
UFactory* SpecifiedFactory = Params.SpecifiedFactory;
const bool bForceOverrideExisting = Params.bForceOverrideExisting;
const bool bSyncToBrowser = Params.bSyncToBrowser;
const bool bAutomatedImport = Params.bAutomated || GIsAutomationTesting;
TArray<UObject*> ReturnObjects;
TMap< FString, TArray<UFactory*> > ExtensionToFactoriesMap;
FScopedSlowTask SlowTask(Files.Num(), LOCTEXT("ImportSlowTask", "Importing"));
SlowTask.MakeDialog();
TArray<TPair<FString, FString>> FilesAndDestinations;
if (FilesAndDestinationsPtr == nullptr)
{
ExpandDirectories(Files, RootDestinationPath, FilesAndDestinations);
}
else
{
FilesAndDestinations = (*FilesAndDestinationsPtr);
}
if(SpecifiedFactory == nullptr)
{
// First instantiate one factory for each file extension encountered that supports the extension
// @todo import: gmp: show dialog in case of multiple matching factories
for(TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
if(!(*ClassIt)->IsChildOf(UFactory::StaticClass()) || ((*ClassIt)->HasAnyClassFlags(CLASS_Abstract)) || (*ClassIt)->IsChildOf(USceneImportFactory::StaticClass()))
{
continue;
}
UFactory* Factory = Cast<UFactory>((*ClassIt)->GetDefaultObject());
if(!Factory->bEditorImport)
{
continue;
}
TArray<FString> FactoryExtensions;
Factory->GetSupportedFileExtensions(FactoryExtensions);
for(auto& FileDest : FilesAndDestinations)
{
const FString FileExtension = FPaths::GetExtension(FileDest.Key);
// Case insensitive string compare with supported formats of this factory
if(FactoryExtensions.Contains(FileExtension))
{
TArray<UFactory*>& ExistingFactories = ExtensionToFactoriesMap.FindOrAdd(FileExtension);
// Do not remap extensions, just reuse the existing UFactory.
// There may be multiple UFactories, so we will keep track of all of them
bool bFactoryAlreadyInMap = false;
for(auto FoundFactoryIt = ExistingFactories.CreateConstIterator(); FoundFactoryIt; ++FoundFactoryIt)
{
if((*FoundFactoryIt)->GetClass() == Factory->GetClass())
{
bFactoryAlreadyInMap = true;
break;
}
}
if(!bFactoryAlreadyInMap)
{
// We found a factory for this file, it can be imported!
// Create a new factory of the same class and make sure it doesn't get GCed.
// The object will be removed from the root set at the end of this function.
UFactory* NewFactory = NewObject<UFactory>(GetTransientPackage(), Factory->GetClass());
if(NewFactory->ConfigureProperties())
{
NewFactory->AddToRoot();
ExistingFactories.Add(NewFactory);
}
}
}
}
}
}
else if(SpecifiedFactory->bEditorImport && !bAutomatedImport)
{
TArray<FString> FactoryExtensions;
SpecifiedFactory->GetSupportedFileExtensions(FactoryExtensions);
for(auto FileIt = Files.CreateConstIterator(); FileIt; ++FileIt)
{
const FString FileExtension = FPaths::GetExtension(*FileIt);
// Case insensitive string compare with supported formats of this factory
if(!FactoryExtensions.Contains(FileExtension))
{
continue;
}
TArray<UFactory*>& ExistingFactories = ExtensionToFactoriesMap.FindOrAdd(FileExtension);
// Do not remap extensions, just reuse the existing UFactory.
// There may be multiple UFactories, so we will keep track of all of them
bool bFactoryAlreadyInMap = false;
for(auto FoundFactoryIt = ExistingFactories.CreateConstIterator(); FoundFactoryIt; ++FoundFactoryIt)
{
if((*FoundFactoryIt)->GetClass() == SpecifiedFactory->GetClass())
{
bFactoryAlreadyInMap = true;
break;
}
}
if(!bFactoryAlreadyInMap)
{
// We found a factory for this file, it can be imported!
// Create a new factory of the same class and make sure it doesnt get GCed.
// The object will be removed from the root set at the end of this function.
UFactory* NewFactory = NewObject<UFactory>(GetTransientPackage(), SpecifiedFactory->GetClass());
if(NewFactory->ConfigureProperties())
{
NewFactory->AddToRoot();
ExistingFactories.Add(NewFactory);
}
}
}
}
// We need to sort the factories so that they get tested in priority order
for(auto& ExtensionToFactories : ExtensionToFactoriesMap)
{
ExtensionToFactories.Value.Sort(&UFactory::SortFactoriesByPriority);
}
// Some flags to keep track of what the user decided when asked about overwriting or replacing
bool bOverwriteAll = false;
bool bReplaceAll = false;
bool bDontOverwriteAny = false;
bool bDontReplaceAny = false;
TArray<UFactory*> UsedFactories;
// Now iterate over the input files and use the same factory object for each file with the same extension
for(int32 FileIdx = 0; FileIdx < FilesAndDestinations.Num(); ++FileIdx)
{
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;
// Assume that for automated import, the user knows exactly what factory to use if it exists
if(bAutomatedImport && SpecifiedFactory && SpecifiedFactory->FactoryCanImport(Filename))
{
Factory = SpecifiedFactory;
}
else if(FactoriesPtr)
{
const TArray<UFactory*>& Factories = *FactoriesPtr;
// Handle the potential of multiple factories being found
if(Factories.Num() > 0)
{
Factory = Factories[0];
for(auto FactoryIt = Factories.CreateConstIterator(); FactoryIt; ++FactoryIt)
{
UFactory* TestFactory = *FactoryIt;
if(TestFactory->FactoryCanImport(Filename))
{
Factory = TestFactory;
break;
}
}
}
}
else
{
if(FEngineAnalytics::IsAvailable())
{
TArray<FAnalyticsEventAttribute> Attribs;
Attribs.Add(FAnalyticsEventAttribute(TEXT("FileExtension"), FileExtension));
FEngineAnalytics::GetProvider().RecordEvent(TEXT("Editor.Usage.ImportFailed"), Attribs);
}
const FText Message = FText::Format(LOCTEXT("ImportFailed_UnknownExtension", "Failed to import '{0}'. Unknown extension '{1}'."), FText::FromString(Filename), FText::FromString(FileExtension));
FNotificationInfo Info(Message);
Info.ExpireDuration = 3.0f;
Info.bUseLargeFont = false;
Info.bFireAndForget = true;
Info.bUseSuccessFailIcons = true;
FSlateNotificationManager::Get().AddNotification(Info)->SetCompletionState(SNotificationItem::CS_Fail);
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
}
if(Factory != nullptr)
{
// Reset the 'Do you want to overwrite the existing object?' Yes to All / No to All prompt, to make sure the
// user gets a chance to select something when the factory is first used during this import
if (!UsedFactories.Contains(Factory))
{
Factory->ResetState();
UsedFactories.AddUnique(Factory);
}
UClass* ImportAssetType = Factory->SupportedClass;
bool bImportSucceeded = false;
bool bImportWasCancelled = false;
FDateTime ImportStartTime = FDateTime::UtcNow();
FString Name = ObjectTools::SanitizeObjectName(FPaths::GetBaseFilename(Filename));
FString PackageName = FPaths::Combine(*DestinationPath, *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));
if(!bAutomatedImport)
{
FMessageDialog::Open(EAppMsgType::Ok, Message);
}
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
UPackage* Pkg = CreatePackage(nullptr, *PackageName);
if(!ensure(Pkg))
{
// Failed to create the package to hold this asset for some reason
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
// Make sure the destination package is loaded
Pkg->FullyLoad();
// Check for an existing object
UObject* ExistingObject = StaticFindObject(UObject::StaticClass(), Pkg, *Name);
if(ExistingObject != nullptr)
{
// If the existing object is one of the imports we've just created we can't replace or overwrite it
if(ReturnObjects.Contains(ExistingObject))
{
if(ImportAssetType == nullptr)
{
// The factory probably supports multiple types and cant be determined yet without asking the user or actually loading it
// We just need to generate an unused name so object should do fine.
ImportAssetType = UObject::StaticClass();
}
// generate a unique name for this import
Name = MakeUniqueObjectName(Pkg, ImportAssetType, *Name).ToString();
}
else
{
// If the object is supported by the factory we are using, ask if we want to overwrite the asset
// Otherwise, prompt to replace the object
if(Factory->DoesSupportClass(ExistingObject->GetClass()))
{
// The factory can overwrite this object, ask if that is okay, unless "Yes To All" or "No To All" was already selected
EAppReturnType::Type UserResponse;
if(bForceOverrideExisting || bOverwriteAll || GIsAutomationTesting)
{
UserResponse = EAppReturnType::YesAll;
}
else if(bDontOverwriteAny)
{
UserResponse = EAppReturnType::NoAll;
}
else
{
UserResponse = FMessageDialog::Open(
EAppMsgType::YesNoYesAllNoAll,
FText::Format(LOCTEXT("ImportObjectAlreadyExists_SameClass", "Do you want to overwrite the existing asset?\n\nAn asset already exists at the import location: {0}"), FText::FromString(PackageName)));
bOverwriteAll = UserResponse == EAppReturnType::YesAll;
bDontOverwriteAny = UserResponse == EAppReturnType::NoAll;
}
const bool bWantOverwrite = UserResponse == EAppReturnType::Yes || UserResponse == EAppReturnType::YesAll;
if(!bWantOverwrite)
{
// User chose not to replace the package
bImportWasCancelled = true;
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
}
else if(!bAutomatedImport)
{
// The factory can't overwrite this asset, ask if we should delete the object then import the new one. Only do this if "Yes To All" or "No To All" was not already selected.
EAppReturnType::Type UserResponse;
if(bReplaceAll)
{
UserResponse = EAppReturnType::YesAll;
}
else if(bDontReplaceAny)
{
UserResponse = EAppReturnType::NoAll;
}
else
{
UserResponse = FMessageDialog::Open(
EAppMsgType::YesNoYesAllNoAll,
FText::Format(LOCTEXT("ImportObjectAlreadyExists_DifferentClass", "Do you want to replace the existing asset?\n\nAn asset already exists at the import location: {0}"), FText::FromString(PackageName)));
bReplaceAll = UserResponse == EAppReturnType::YesAll;
bDontReplaceAny = UserResponse == EAppReturnType::NoAll;
}
const bool bWantReplace = UserResponse == EAppReturnType::Yes || UserResponse == EAppReturnType::YesAll;
if(bWantReplace)
{
// Delete the existing object
int32 NumObjectsDeleted = 0;
TArray< UObject* > ObjectsToDelete;
ObjectsToDelete.Add(ExistingObject);
// If the user forcefully deletes the package, all sorts of things could become invalidated,
// the Pkg pointer might be killed even though it was added to the root.
TWeakObjectPtr<UPackage> WeakPkg(Pkg);
// Dont let the package get garbage collected (just in case we are deleting the last asset in the package)
Pkg->AddToRoot();
NumObjectsDeleted = ObjectTools::DeleteObjects(ObjectsToDelete, /*bShowConfirmation=*/false);
// If the weak package ptr is still valid, it should then be safe to remove it from the root.
if(WeakPkg.IsValid())
{
Pkg->RemoveFromRoot();
}
const FString QualifiedName = PackageName + TEXT(".") + Name;
FText Reason;
if(NumObjectsDeleted == 0 || !IsUniqueObjectName(*QualifiedName, ANY_PACKAGE, Reason))
{
// Original object couldn't be deleted
const FText Message = FText::Format(LOCTEXT("ImportDeleteFailed", "Failed to delete '{0}'. The asset is referenced by other content."), FText::FromString(PackageName));
FMessageDialog::Open(EAppMsgType::Ok, Message);
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
else
{
// succeed, recreate package since it has been deleted
Pkg = CreatePackage(nullptr, *PackageName);
}
}
else
{
// User chose not to replace the package
bImportWasCancelled = true;
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
}
}
}
// Check for a package that was marked for delete in source control
if(!CheckForDeletedPackage(Pkg))
{
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
continue;
}
Factory->SetAutomatedAssetImportData(Params.ImportData);
ImportAssetType = Factory->ResolveSupportedClass();
UObject* Result = Factory->ImportObject(ImportAssetType, Pkg, FName(*Name), RF_Public | RF_Standalone | RF_Transactional, Filename, nullptr, bImportWasCancelled);
Factory->SetAutomatedAssetImportData(nullptr);
// Do not report any error if the operation was canceled.
if(!bImportWasCancelled)
{
if(Result)
{
ReturnObjects.Add(Result);
// Notify the asset registry
FAssetRegistryModule::AssetCreated(Result);
GEditor->BroadcastObjectReimported(Result);
bImportSucceeded = true;
}
else
{
const FText Message = FText::Format(LOCTEXT("ImportFailed_Generic", "Failed to import '{0}'. Failed to create asset '{1}'.\nPlease see Output Log for details."), FText::FromString(Filename), FText::FromString(PackageName));
if(!bAutomatedImport)
{
FMessageDialog::Open(EAppMsgType::Ok, Message);
}
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *Message.ToString());
}
}
// Refresh the supported class. Some factories (e.g. FBX) only resolve their type after reading the file
ImportAssetType = Factory->ResolveSupportedClass();
OnNewImportRecord(ImportAssetType, FileExtension, bImportSucceeded, bImportWasCancelled, ImportStartTime);
}
else
{
// A factory or extension was not found. The extension warning is above. If a factory was not found, the user likely canceled a factory configuration dialog.
}
}
// Clean up and remove the factories we created from the root set
for(auto ExtensionIt = ExtensionToFactoriesMap.CreateConstIterator(); ExtensionIt; ++ExtensionIt)
{
for(auto FactoryIt = ExtensionIt.Value().CreateConstIterator(); FactoryIt; ++FactoryIt)
{
(*FactoryIt)->CleanUp();
(*FactoryIt)->RemoveFromRoot();
}
}
// Sync content browser to the newly created assets
if(ReturnObjects.Num() && (bSyncToBrowser != false))
{
FAssetTools::Get().SyncBrowserToAssets(ReturnObjects);
}
return ReturnObjects;
}
FAssetTools& FAssetTools::Get()
{
FAssetToolsModule& Module = FModuleManager::GetModuleChecked<FAssetToolsModule>("AssetTools");
return static_cast<FAssetTools&>(Module.Get());
}
void FAssetTools::SyncBrowserToAssets(const TArray<UObject*>& AssetsToSync)
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
}
void FAssetTools::SyncBrowserToAssets(const TArray<FAssetData>& AssetsToSync)
{
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
ContentBrowserModule.Get().SyncBrowserToAssets( AssetsToSync, /*bAllowLockedBrowsers=*/true );
}
bool FAssetTools::CheckForDeletedPackage(const UPackage* Package) const
{
if ( ISourceControlModule::Get().IsEnabled() )
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
if ( SourceControlProvider.IsAvailable() )
{
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState(Package, EStateCacheUsage::ForceUpdate);
if ( SourceControlState.IsValid() && SourceControlState->IsDeleted() )
{
// Creating an asset in a package that is marked for delete - revert the delete and check out the package
if (!SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), Package))
{
// Failed to revert file which was marked for delete
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("RevertDeletedFileFailed", "Failed to revert package which was marked for delete."));
return false;
}
if (!SourceControlProvider.Execute(ISourceControlOperation::Create<FCheckOut>(), Package))
{
// Failed to check out file
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("CheckOutFileFailed", "Failed to check out package"));
return false;
}
}
}
else
{
FMessageLog EditorErrors("EditorErrors");
EditorErrors.Warning(LOCTEXT( "DeletingNoSCCConnection", "Could not check for deleted file. No connection to source control available!"));
EditorErrors.Notify();
}
}
return true;
}
bool FAssetTools::CanCreateAsset(const FString& AssetName, const FString& PackageName, const FText& OperationText) const
{
// @todo: These 'reason' messages are not localized strings!
FText Reason;
if (!FName(*AssetName).IsValidObjectName( Reason )
|| !FPackageName::IsValidLongPackageName( PackageName, /*bIncludeReadOnlyRoots=*/false, &Reason ) )
{
FMessageDialog::Open( EAppMsgType::Ok, Reason );
return false;
}
// We can not create assets that share the name of a map file in the same location
if ( FEditorFileUtils::IsMapPackageAsset(PackageName) )
{
FMessageDialog::Open( EAppMsgType::Ok, FText::Format( LOCTEXT("AssetNameInUseByMap", "You can not create an asset named '{0}' because there is already a map file with this name in this folder."), FText::FromString( AssetName ) ) );
return false;
}
// Find (or create!) the desired package for this object
UPackage* Pkg = CreatePackage(nullptr,*PackageName);
// Handle fully loading packages before creating new objects.
TArray<UPackage*> TopLevelPackages;
TopLevelPackages.Add( Pkg );
if( !PackageTools::HandleFullyLoadingPackages( TopLevelPackages, OperationText ) )
{
// User aborted.
return false;
}
// We need to test again after fully loading.
if (!FName(*AssetName).IsValidObjectName( Reason )
|| !FPackageName::IsValidLongPackageName( PackageName, /*bIncludeReadOnlyRoots=*/false, &Reason ) )
{
FMessageDialog::Open( EAppMsgType::Ok, Reason );
return false;
}
// Check for an existing object
UObject* ExistingObject = StaticFindObject( UObject::StaticClass(), Pkg, *AssetName );
if( ExistingObject != nullptr )
{
// Object already exists in either the specified package or another package. Check to see if the user wants
// to replace the object.
bool bWantReplace =
EAppReturnType::Yes == FMessageDialog::Open(
EAppMsgType::YesNo,
FText::Format(
NSLOCTEXT("UnrealEd", "ReplaceExistingObjectInPackage_F", "An object [{0}] of class [{1}] already exists in file [{2}]. Do you want to replace the existing object? If you click 'Yes', the existing object will be deleted. Otherwise, click 'No' and choose a unique name for your new object." ),
FText::FromString(AssetName), FText::FromString(ExistingObject->GetClass()->GetName()), FText::FromString(PackageName) ) );
if( bWantReplace )
{
// Replacing an object. Here we go!
// Delete the existing object
bool bDeleteSucceeded = ObjectTools::DeleteSingleObject( ExistingObject );
if (bDeleteSucceeded)
{
// Force GC so we can cleanly create a new asset (and not do an 'in place' replacement)
CollectGarbage( GARBAGE_COLLECTION_KEEPFLAGS );
// Old package will be GC'ed... create a new one here
Pkg = CreatePackage(nullptr,*PackageName);
}
else
{
// Notify the user that the operation failed b/c the existing asset couldn't be deleted
FMessageDialog::Open( EAppMsgType::Ok, FText::Format( NSLOCTEXT("DlgNewGeneric", "ContentBrowser_CannotDeleteReferenced", "{0} wasn't created.\n\nThe asset is referenced by other content."), FText::FromString( AssetName ) ) );
}
if( !bDeleteSucceeded || !IsUniqueObjectName( *AssetName, Pkg, Reason ) )
{
// Original object couldn't be deleted
return false;
}
}
else
{
// User chose not to replace the object; they'll need to enter a new name
return false;
}
}
// Check for a package that was marked for delete in source control
if ( !CheckForDeletedPackage(Pkg) )
{
return false;
}
return true;
}
void FAssetTools::PerformMigratePackages(TArray<FName> PackageNamesToMigrate) const
{
// Form a full list of packages to move by including the dependencies of the supplied packages
TSet<FName> AllPackageNamesToMove;
{
FScopedSlowTask SlowTask( PackageNamesToMigrate.Num(), LOCTEXT( "MigratePackages_GatheringDependencies", "Gathering Dependencies..." ) );
SlowTask.MakeDialog();
for ( auto PackageIt = PackageNamesToMigrate.CreateConstIterator(); PackageIt; ++PackageIt )
{
SlowTask.EnterProgressFrame();
if ( !AllPackageNamesToMove.Contains(*PackageIt) )
{
AllPackageNamesToMove.Add(*PackageIt);
RecursiveGetDependencies(*PackageIt, AllPackageNamesToMove);
}
}
}
// Confirm that there is at least one package to move
if ( AllPackageNamesToMove.Num() == 0 )
{
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("MigratePackages_NoFilesToMove", "No files were found to move"));
return;
}
// Prompt the user displaying all assets that are going to be migrated
{
const FText ReportMessage = LOCTEXT("MigratePackagesReportTitle", "The following assets will be migrated to another content folder.");
TArray<FString> ReportPackageNames;
for ( auto PackageIt = AllPackageNamesToMove.CreateConstIterator(); PackageIt; ++PackageIt )
{
ReportPackageNames.Add((*PackageIt).ToString());
}
SPackageReportDialog::FOnReportConfirmed OnReportConfirmed = SPackageReportDialog::FOnReportConfirmed::CreateRaw(this, &FAssetTools::MigratePackages_ReportConfirmed, ReportPackageNames);
SPackageReportDialog::OpenPackageReportDialog(ReportMessage, ReportPackageNames, OnReportConfirmed);
}
}
void FAssetTools::MigratePackages_ReportConfirmed(TArray<FString> ConfirmedPackageNamesToMigrate) const
{
// Choose a destination folder
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
FString DestinationFolder;
if ( ensure(DesktopPlatform) )
{
const void* ParentWindowWindowHandle = FSlateApplication::Get().FindBestParentWindowHandleForDialogs(nullptr);
const FString Title = LOCTEXT("MigrateToFolderTitle", "Choose a destination Content folder").ToString();
bool bFolderAccepted = false;
while (!bFolderAccepted)
{
const bool bFolderSelected = DesktopPlatform->OpenDirectoryDialog(
ParentWindowWindowHandle,
Title,
FEditorDirectories::Get().GetLastDirectory(ELastDirectory::GENERIC_EXPORT),
DestinationFolder
);
if ( !bFolderSelected )
{
// User canceled, return
return;
}
FEditorDirectories::Get().SetLastDirectory(ELastDirectory::GENERIC_EXPORT, DestinationFolder);
FPaths::NormalizeFilename(DestinationFolder);
if ( !DestinationFolder.EndsWith(TEXT("/")) )
{
DestinationFolder += TEXT("/");
}
// Verify that it is a content folder
if ( DestinationFolder.EndsWith(TEXT("/Content/")) )
{
bFolderAccepted = true;
}
else
{
// The user chose a non-content folder. Confirm that this was their intention.
const FText Message = FText::Format(LOCTEXT("MigratePackages_NonContentFolder", "{0} does not appear to be a game Content folder. Migrated content will only work properly if placed in a Content folder. Would you like to place your content here anyway?"), FText::FromString(DestinationFolder));
EAppReturnType::Type Response = FMessageDialog::Open(EAppMsgType::YesNo, Message);
bFolderAccepted = (Response == EAppReturnType::Yes);
}
}
}
else
{
// Not on a platform that supports desktop functionality
FMessageDialog::Open(EAppMsgType::Ok, LOCTEXT("NoDesktopPlatform", "Error: This platform does not support a file dialog."));
return;
}
bool bUserCanceled = false;
// Copy all specified assets and their dependencies to the destination folder
FScopedSlowTask SlowTask( 2, LOCTEXT( "MigratePackages_CopyingFiles", "Copying Files..." ) );
SlowTask.MakeDialog();
EAppReturnType::Type LastResponse = EAppReturnType::Yes;
TArray<FString> SuccessfullyCopiedFiles;
TArray<FString> SuccessfullyCopiedPackages;
FString CopyErrors;
SlowTask.EnterProgressFrame();
{
FScopedSlowTask LoopProgress(ConfirmedPackageNamesToMigrate.Num());
for ( auto PackageNameIt = ConfirmedPackageNamesToMigrate.CreateConstIterator(); PackageNameIt; ++PackageNameIt )
{
LoopProgress.EnterProgressFrame();
const FString& PackageName = *PackageNameIt;
FString SrcFilename;
if ( !FPackageName::DoesPackageExist(PackageName, nullptr, &SrcFilename) )
{
const FText ErrorMessage = FText::Format(LOCTEXT("MigratePackages_PackageMissing", "{0} does not exist on disk."), FText::FromString(PackageName));
UE_LOG(LogAssetTools, Warning, TEXT("%s"), *ErrorMessage.ToString());
CopyErrors += ErrorMessage.ToString() + LINE_TERMINATOR;
}
else if (SrcFilename.Contains(FPaths::EngineContentDir()))
{
const FString LeafName = SrcFilename.Replace(*FPaths::EngineContentDir(), TEXT("Engine/"));
CopyErrors += FText::Format(LOCTEXT("MigratePackages_EngineContent", "Unable to migrate Engine asset {0}. Engine assets cannot be migrated."), FText::FromString(LeafName)).ToString() + LINE_TERMINATOR;
}
else
{
const FString DestFilename = SrcFilename.Replace(*FPaths::GameContentDir(), *DestinationFolder);
bool bFileOKToCopy = true;
if ( IFileManager::Get().FileSize(*DestFilename) > 0 )
{
// The destination file already exists! Ask the user what to do.
EAppReturnType::Type Response;
if ( LastResponse == EAppReturnType::YesAll || LastResponse == EAppReturnType::NoAll )
{
Response = LastResponse;
}
else
{
const FText Message = FText::Format( LOCTEXT("MigratePackages_AlreadyExists", "An asset already exists at location {0} would you like to overwrite it?"), FText::FromString(DestFilename) );
Response = FMessageDialog::Open( EAppMsgType::YesNoYesAllNoAllCancel, Message );
if ( Response == EAppReturnType::Cancel )
{
// The user chose to cancel mid-operation. Break out.
bUserCanceled = true;
break;
}
LastResponse = Response;
}
const bool bWantOverwrite = Response == EAppReturnType::Yes || Response == EAppReturnType::YesAll;
if( !bWantOverwrite )
{
// User chose not to replace the package
bFileOKToCopy = false;
}
}
if ( bFileOKToCopy )
{
if ( IFileManager::Get().Copy(*DestFilename, *SrcFilename) == COPY_OK )
{
SuccessfullyCopiedPackages.Add(PackageName);
SuccessfullyCopiedFiles.Add(DestFilename);
}
else
{
UE_LOG(LogAssetTools, Warning, TEXT("Failed to copy %s to %s while migrating assets"), *SrcFilename, *DestFilename);
CopyErrors += SrcFilename + LINE_TERMINATOR;
}
}
}
}
}
FString SourceControlErrors;
SlowTask.EnterProgressFrame();
if ( !bUserCanceled && SuccessfullyCopiedFiles.Num() > 0 )
{
// attempt to add files to source control (this can quite easily fail, but if it works it is very useful)
if(GetDefault<UEditorLoadingSavingSettings>()->bSCCAutoAddNewFiles)
{
if(ISourceControlModule::Get().IsEnabled())
{
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
if(SourceControlProvider.Execute(ISourceControlOperation::Create<FMarkForAdd>(), SuccessfullyCopiedFiles) == ECommandResult::Failed)
{
FScopedSlowTask LoopProgress(SuccessfullyCopiedFiles.Num());
for(auto FileIt(SuccessfullyCopiedFiles.CreateConstIterator()); FileIt; FileIt++)
{
LoopProgress.EnterProgressFrame();
if(!SourceControlProvider.GetState(*FileIt, EStateCacheUsage::Use)->IsAdded())
{
SourceControlErrors += FText::Format(LOCTEXT("MigratePackages_SourceControlError", "{0} could not be added to source control"), FText::FromString(*FileIt)).ToString();
SourceControlErrors += LINE_TERMINATOR;
}
}
}
}
}
}
FMessageLog MigrateLog("AssetTools");
FText LogMessage = FText::FromString(TEXT("Content migration completed successfully!"));
EMessageSeverity::Type Severity = EMessageSeverity::Info;
if ( CopyErrors.Len() > 0 || SourceControlErrors.Len() > 0 )
{
FString ErrorMessage;
Severity = EMessageSeverity::Error;
if( CopyErrors.Len() > 0 )
{
MigrateLog.NewPage( LOCTEXT("MigratePackages_CopyErrorsPage", "Copy Errors") );
MigrateLog.Error(FText::FromString(*CopyErrors));
ErrorMessage += FText::Format(LOCTEXT( "MigratePackages_CopyErrors", "Copied {0} files. Some content could not be copied."), FText::AsNumber(SuccessfullyCopiedPackages.Num())).ToString();
}
if( SourceControlErrors.Len() > 0 )
{
MigrateLog.NewPage( LOCTEXT("MigratePackages_SourceControlErrorsListPage", "Source Control Errors") );
MigrateLog.Error(FText::FromString(*SourceControlErrors));
ErrorMessage += LINE_TERMINATOR;
ErrorMessage += LOCTEXT( "MigratePackages_SourceControlErrorsList", "Some files reported source control errors.").ToString();
}
if ( SuccessfullyCopiedPackages.Num() > 0 )
{
MigrateLog.NewPage( LOCTEXT("MigratePackages_CopyErrorsSuccesslistPage", "Copied Successfully") );
MigrateLog.Info(FText::FromString(*SourceControlErrors));
ErrorMessage += LINE_TERMINATOR;
ErrorMessage += LOCTEXT( "MigratePackages_CopyErrorsSuccesslist", "Some files were copied successfully.").ToString();
for ( auto FileIt = SuccessfullyCopiedPackages.CreateConstIterator(); FileIt; ++FileIt )
{
if(FileIt->Len()>0)
{
MigrateLog.Info(FText::FromString(*FileIt));
}
}
}
LogMessage = FText::FromString(ErrorMessage);
}
else if ( !bUserCanceled )
{
MigrateLog.NewPage( LOCTEXT("MigratePackages_CompletePage", "Content migration completed successfully!") );
for ( auto FileIt = SuccessfullyCopiedPackages.CreateConstIterator(); FileIt; ++FileIt )
{
if(FileIt->Len()>0)
{
MigrateLog.Info(FText::FromString(*FileIt));
}
}
}
MigrateLog.Notify(LogMessage, Severity, true);
}
void FAssetTools::RecursiveGetDependencies(const FName& PackageName, TSet<FName>& AllDependencies) const
{
FAssetRegistryModule& AssetRegistryModule = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
TArray<FName> Dependencies;
AssetRegistryModule.Get().GetDependencies(PackageName, Dependencies);
for ( auto DependsIt = Dependencies.CreateConstIterator(); DependsIt; ++DependsIt )
{
if ( !AllDependencies.Contains(*DependsIt) )
{
// @todo Make this skip all packages whose root is different than the source package list root. For now we just skip engine content.
const bool bIsEnginePackage = (*DependsIt).ToString().StartsWith(TEXT("/Engine"));
const bool bIsScriptPackage = (*DependsIt).ToString().StartsWith(TEXT("/Script"));
if ( !bIsEnginePackage && !bIsScriptPackage )
{
AllDependencies.Add(*DependsIt);
RecursiveGetDependencies(*DependsIt, AllDependencies);
}
}
}
}
void FAssetTools::FixupReferencers(const TArray<UObjectRedirector*>& Objects) const
{
AssetFixUpRedirectors->FixupReferencers(Objects);
}
#undef LOCTEXT_NAMESPACE