- Unreal Engine 4 Scripting with C++ Cookbook
- William Sherif Stephen Whittle
- 133字
- 2021-07-08 10:50:51
Unreal's garbage collection system and UPROPERTY( )
When you have an object (such as TArray< >
) as a UPROPERTY()
member of UCLASS()
, you need to declare that member as UPROPERTY()
(even if you won't edit it in blueprints), otherwise TArray
will not stay allocated properly.
How to do it...
Say we have a UCLASS()
macro as follows:
UCLASS() class MYPROJECT_API AWarrior : public AActor { //TArray< FSoundEffect > Greets; // Incorrect UPROPERTY() TArray< FSoundEffect > Greets; // Correct };
You'd have to list the TArray
member as UPROPERTY()
for it to be properly reference counted. If you don't do so, you'll get an unexpected memory error type bug sitting about in the code.
How it works…
The UPROPERTY()
declaration tells UE4 that TArray
must be properly memory managed. Without the UPROPERTY()
declaration, your TArray
won't work properly.
推薦閱讀
- FuelPHP Application Development Blueprints
- TypeScript入門與實戰
- Visual FoxPro程序設計教程
- Java程序設計與計算思維
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- Visual Basic學習手冊
- SAS數據統計分析與編程實踐
- MySQL數據庫管理與開發實踐教程 (清華電腦學堂)
- Machine Learning in Java
- 代替VBA!用Python輕松實現Excel編程
- 智能手機故障檢測與維修從入門到精通
- Mastering PowerCLI
- Web開發新體驗
- Enterprise Application Architecture with .NET Core
- 微服務設計