Introduction
As a project grows, you may find that some logic needs to be refactored. For C++ this is relatively easy: mainstream IDEs all provide some refactoring support, so renaming and finding references are fairly convenient.
For Blueprint, however, a one-click operation is not really possible, and changing old logic directly may cause many problems. Especially for logic that already has a large number of references, a direct change may create unexpected amounts of work. In that case, one option is to build a new implementation and then gradually deprecate the old one. To do this gracefully, Unreal Engine provides several syntaxes for marking things as deprecated.
If your project uses an additional scripting language, you need to check the corresponding implementation to choose a refactoring approach.
Puerts is recommended as a type-safe scripting language; you may also want to read this article: Some knowledge about migrating from UnLua to PuerTS in Unreal Engine
Redirecting
If you need to rename something, prefer Unreal Engine’s redirect system: Relevant knowledge about redirecting in Unreal Engine.
Deprecation markers
UPROPERTY
For a property, you only need to rename the variable to the _DEPRECATED version and add the deprecation specifiers.
This does not affect the compilation of existing Blueprints, so you can remove references during that period.
| |
| |
UFUNCTION
For UFUNCTION it is simpler: just add the DeprecatedFunction meta specifier to the function.
| |
| |
UCLASS
For UCLASS, renaming is also required.
| |
| |
UENUM & USTRUCT
The DEPRECATED_ syntax above does not seem to be supported for affecting Blueprint compilation, but for C++ the engine appears to have the UE_DEPRECATED marking syntax.
It is more recommended to rename it to a deprecated name and then handle it with the redirect system: Relevant knowledge about redirecting in Unreal Engine.
UE_DEPRECATED
Probably the most common deprecation marker, usually used to mark a function or variable as deprecated as of a certain engine version.
The syntax is UE_DEPRECATED(引擎版本号, 提示消息). When a deprecated variable or function is used in C++ on a version after the one in which it was deprecated, the compiler and IDE will report it.
Custom deprecation macros
Because whether something counts as deprecated with Unreal Engine’s UE_DEPRECATED depends on the engine version, it may be inconvenient in ordinary projects, so you can wrap your own deprecation macro.
| |