Download

Can't edit default properties in PIE

Hi,

Editing default properties when playing in PIE used to be incredibly useful for tweaking, but appears to have been disabled (in version 4.8 according to a thread I found on answerhub).

https://answers.unrealengine.com/questions/242226/pie-cannot-edit-variable-defaults-of-a-blueprint-d.html

Beyond that thread I haven’t been able to find any other information on this topic.
Please can you tell me why this facility has been removed and more importantly how I can make it available again (i.e by hacking the engine source code). I don’t care if it’s a bit unstable.

The answer given on the above thread is no use in this case as there is no instance object to edit - the blueprints in question are purely being used to contain immutable data.

Thanks,
Simon

Answer to my own question which others might find useful.

I’ve discovered that there’s a concept of “const blueprints” (although someone at Epic doesn’t seem to know about them):


  C:\P4\Engine\Source\Developer\BlueprintNativeCodeGen\Private\BlueprintNativeCodeGenModule.cpp(637):				//BPTYPE_Const,		// WTF is a "const" Blueprint?


A const blueprint class is declared in c++ with this:


UCLASS(Blueprintable, BlueprintType, **Const**)
class STONES_API UMyObject : public UObject
{
	GENERATED_BODY()
};

Which seems to be what I need (pure data containers) from comments in Epic’s code:


	/** Blueprint that is const during execution (no state graph and methods cannot modify member variables). */
	BPTYPE_Const				UMETA(DisplayName="Const Blueprint Class"),


To allow these to be edited while playing the game, I’ve just changed this function:


bool FBlueprintEditor::InEditingMode() const
{
	// allow editing of const blueprints even when playing game
	UBlueprint* Blueprint = GetBlueprintObj();
	if (Blueprint && Blueprint->BlueprintType == BPTYPE_Const)
		return true;

	return !InDebuggingMode();
}

Now I can tweak my settings while playing the game and everything seems to work correctly.

Unfortunately this flag is only applied at blueprint creation time so this doesn’t immediately work for already created blueprints.
I’ve made it retrospectively apply this setting upon compilation but this is rather dangerous as it doesn’t check that the blueprint meets the const requirements so I don’t necessarily recommend it:


void FKismetEditorUtilities::CompileBlueprint(UBlueprint* BlueprintObj, bool bIsRegeneratingOnLoad, bool bSkipGarbageCollection, bool bSaveIntermediateProducts, FCompilerResultsLog* pResults, bool bSkeletonUpToDate, bool bBatchCompile, bool bAddInstrumentation)
{
	FSecondsCounterScope Timer(BlueprintCompileAndLoadTimerData); 
	BP_SCOPED_COMPILER_EVENT_STAT(EKismetCompilerStats_CompileBlueprint);

	// Wipe the PreCompile log, any generated messages are now irrelevant
	BlueprintObj->PreCompileLog.Reset();

	// Broadcast pre-compile
#if WITH_EDITOR
	{
		BP_SCOPED_COMPILER_EVENT_STAT(EKismetCompilerStats_BroadcastPrecompile);
		if(GEditor && GIsEditor)
		{
			GEditor->BroadcastBlueprintPreCompile(BlueprintObj);

**			// allow the const flag to be retrospecively applied
			if ((BlueprintObj->BlueprintType == BPTYPE_Normal) && (BlueprintObj->ParentClass->HasAnyClassFlags(CLASS_Const)))
			{
				BlueprintObj->BlueprintType = BPTYPE_Const;
			}**
		}
	}
#endif

I think the first part of this is a legitimate change so it would be nice if Epic could make it official.