Download

Problem with Function calls on PostEditChangeProperty

Hello dear community,

I have a door class in c++ with a boolean bOpen to define that the door is open or closed at the beginning (makes sense, doesnt it?)

When i place a door into the world i can edit this property since it an EditInstanceOnly UPROPERTY.

When you then click on the checkbox bOpen PostEditChangeProperty is called and i check the property’s name if its
“bOpen”.

Regarding its state i simply call Open() or Close() and inside those i call other functions which do the desired rotation for me (enabling tick events, set up timelines and delegates a.s.o).
While those rotation functions are called by some miracle, Open() and Close() are not called and though i dont get the desired result.

However, when i place the same behaviour inside BeginPlay() everything works fine and the door rotates regarding bOpen.

I got a hint from a friend that the compiler might inline Open() and Close(), so they are not valid when in Editor-Mode.

If so can someone tell me how i can prevent functions from being inlined?

I tried UFUNTION() above those two, but it doesnt changed anything.

best regards
Wallhalla

no ideas??

PostEditChangeProperty is valid only when dealing with editor, it won’t be called at game runtime.

Or perhaps I didn’t quite understand what you’re trying to achieve.

hey thanks for the reply,

well imagine to have a door you place into the scene(in Editormode)

It is closed by default, but you want it to be open for this specific door-instance.
So you open the doordetails of your instanced door and check the bOpen state to true.

PostEditChangeProperty is called…

now i want to set the door to open (still in Editor) so you can “see” it to be open.

Did you manage to solve this? Having a similar issue.

hey,

no unfortunately not…

perhaps if you post your code… :slight_smile:

Unfortunately i cant upload my code. But however i just updated UE4 to 4.8.2

and the functions are called…

Now i have the problem that my helper class isnt called:

This one i can show you:




class AnimationTransformHelper
{
public:


	
	static FTransform MakeTransform
		(
		FTimeline* Timeline,
		ETransformType TransformType,
		TEnumAsByte<EAxis::Type> Axis,
		UCurveFloat* FloatCurve,
		int32 TransformFactor
		);
};



i only placed this class inside the door class manually. But the static function is not being called.

So i thought maybe it needs some UCLASS specifier and i tried:



UCLASS(abstract, NotBlueprintable, NotPlaceable)
class UAnimationTransformHelper : public UObject
{
public:

	GENERATED_BODY()	
	
	static FTransform MakeTransform
		(
		FTimeline* Timeline,
		ETransformType TransformType,
		TEnumAsByte<EAxis::Type> Axis,
		UCurveFloat* FloatCurve,
		int32 TransformFactor
		);
};



but its the same.

Is it even possible to create simple classes like helpers within visual studio instead of “Add Code to Project”?

actually I’d just need to see how you overloaded the PostEditChangeProperty() function in your code

hey there,

sorry for the delay…



void ADoor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
{	
	Super::PostEditChangeProperty(e);	

	FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
	
	if (PropertyName == GET_MEMBER_NAME_CHECKED(ADoor, bOpen)) 
	{		
		this->SetActorTickEnabled(true);
		if (bOpen)
		{
			this->Open();
		}
		else
		{
			this->Close();
		}		
	}
}


so when i click the boolean checkbox in Editor nothing happens to the door,

when i click it a second time i get an access violation and i need to restart.

When you’re asking for help, you’re not going to get anywhere if you don’t post your code. You should be showing us the relevant functions. Open(), Close(), PostEditChangeProperty(), etc. Otherwise no one can magically know your problem.

Don’t use “this”, you very rarely ever use that. It’s best to use that only when you’re passing the instance of yourself (aka: “this instance”) to another function in another class. SomeOtherClass->SetOwner(this) for example.

On top of that using logging methods in your function to see where the code breaks. Open YourGame.H (main file) and add a Log category like so




#pragma once

#include "Engine.h"
#include "UnrealNetwork.h"


DEFINE_LOG_CATEGORY_STATIC(LogName, All, All);


now you can call upon that Log Type throughout your code to test things. Putting them in various places to see how they make or break your game. Like this,.



void ADoor::PostEditChangeProperty(struct FPropertyChangedEvent& e)
{	
	Super::PostEditChangeProperty(e);	

        UE_LOG(LogName,All,TEXT("Logging PostEditChangeProperty()"));
	FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
	
	if (PropertyName == GET_MEMBER_NAME_CHECKED(ADoor, bOpen)) 
	{		
		this->SetActorTickEnabled(true);
		if (bOpen)
		{
                  UE_LOG(LogName,All,TEXT("Opening Door"));			
                  this->Open();
		}
		else
		{
                  UE_LOG(LogName,All,TEXT("Closing Door"));			
                  this->Close();
		}		


YourClass::Open()
{
  UE_LOG(LogName,All,TEXT("Open() Called!"));
}