Redirecting properties using core redirects to native parent class

I’m trying to use the core redirects in 4-26 to change a property from the blueprint class to its native c++ parent class. It just won’t redirect the property, but the funny thing is that if I right click the property in the blueprint and do replace references it will successfully replace all instances of the blueprint variable with the selected c++ variable. I have a lot of variables and really don’t want to manually replace each one in the editor. It would be greatly appreciated if anyone has a clue as to why it won’t redirect using the core redirects.

How did you write the redirects? Did you make sure to include the ‘OverrideClassName’ parameter?

No, I did not include the override class name, Looking into the source files for the redirectors it seems that you would put /Script/CoreUObject.Property. Tried this but it still doesn’t redirect my float variable. In a test project I used this redirect:

+PropertyRedirects=(OldName=“TestVarBP”, NewName=“TestVar”, OverrideClassName="/Script/CoreUObject.Property")

Still doesn’t work.

Yeah that was the “proper” was I was going to instruct on the redirect statement as I heard the Override statement was mandatory for it to work. A shame it didn’t fix it, I hope to hear the solution as well since these redirects are a common thing in a large project.

It may not work, but did you also consider fixing the redirects in your main content folder as well? Maybe those redirects are interfering with the DefaultEngine.ini redirects?

Did you try setting the MatchSubstring to true?

+PropertyRedirects=(OldName="MyOldActor.OldProperty", NewName="MyNewActor.NewProperty", MatchSubstring=true)

I’ve tried matchsubstring. Also, I’ve tried about every combination of including reference path on the oldname and newname, nothing seems to work. It will redirect fine if it’s a c++ variable to another c++ variable, but it just won’t update the BP variable. What do you mean “fix redirects in main content folder” ?

If you right click on the Content folder of your Blueprint Project, there is an option to fix the redirectors. This only works in the Blueprint Redirects, right clicking on the C++ folder only gives you the option to make a new C++ Class, which is why you need the redirectors in the .ini file. Right clicking and fixing redirectors on the content folder solves a lot of blueprint issues and may help solve this one in combination of what you’re already doing. I fix my BP redirects often, even when there may not be any. Worth a shot

Gotcha! I’m aware of that and do it anytime I mess w/ the blueprint file structure, just wasn’t sure what you were talking about. I did also try that, to no avail. Thanks for the input though. It seems that unreal just doesn’t like redirecting blueprint properties to c++. All of my projects use c++ base classes and I derive my blueprints from them. I only run into this issue when trying to convert someone elses projects because I move all of the relevant variables, enums and functions to C++. I have finally figured out enum redirection but property redirection just doesn’t seem to work. I’d love to have an unreal developers input on this…

Agreed. Sorry I couldn’t help at all. If you come across a solution please share because I’m sure I will need this at some point. I’m constantly refactoring my code, especially being new-ish to C++

I’ve done some test, and here comes the good news:

At least in UE 5.1, as long as you use the same property name in CPP(also remember the uproperty specifiers, like EditAnywhere and BlueprintReadWrite) as in the Blueprint, when you reparent the class, it automatically removes the property in the child BP class and link to the parent cpp class’ property.

So quick answer is that you don’t even need to use core redirects.

The level data remains the same. Not a big suprise to that since I guess levels serialize the property somehow based on the name.

What works out of my imagination is that the blueprint references to those properties also work out of the box.

Test Case


Here are my test cases, you can try it by yourself.

  1. Two Blueprints: BP_ReparentTestActor and BP_TestOther.
    image

  2. BP_ReparentTestActor has an Actor Reference called “ActorRef”, and an int called “ValueType”. Want to use this to test for references and value-type variables. Both of them set to Instance Editable.

  3. BP_TestOther sets the value of ActorRef and ValueType:

  4. Two Levels (to test about level serialization):
    image
    Both levels have a BP_ReparentTestActor and a BP_TestOther. linked all variables, put some level-specific values to BP_ReparentTestActor.

  5. Now simply create the cpp base class. Make sure you got the UClass specifier and UProperty specifier correct:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ReparentBaseActor.generated.h"

UCLASS(BlueprintType, Blueprintable)
class ARPGTEST_API AReparentBaseActor : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	AReparentBaseActor();
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	AActor* ActorRef;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int ValueType;

	UFUNCTION(BlueprintCallable,DisplayName="PrintFunctionTemp")
	void PrintFunction_Native(FText InText);

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;
};
  1. Go to BP_ReparentTestActor, and in class settings, set the parent class to Reparent Base Actor:
    image

  2. Voila! It just works.
    as you can see, the variables of blueprint simply disappears since they are replaced by the base class:
    image

and the level works as well (both of them):

and the other class that reference those properties compile correctly(it’s a quick test, so please ignore the spaghetti here):

Result


So simply use the same name, and it works out of the box. Love you Unreal, for making refactor this easy.

I guess the core redirect of properies are actually used when you are trying to rename properties, but not really there for reparenting I guess.

So if you want to reparent AND rename the property, you should do one thing at a time. Reparent using the same property name first, and then rename the property in C++ using core redirect.