- 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.
推薦閱讀
- Learning Single:page Web Application Development
- C語言程序設計(第2版)
- Windows Presentation Foundation Development Cookbook
- Python編程從0到1(視頻教學版)
- C#程序設計教程(第3版)
- 計算機應用基礎項目化教程
- Simulation for Data Science with R
- Python+Office:輕松實現Python辦公自動化
- SAP Web Dynpro for ABAP開發技術詳解:基礎應用
- 零基礎學SQL(升級版)
- Unreal Engine Game Development Cookbook
- Visual C++ 開發從入門到精通
- AngularJS by Example
- 軟件自動化測試實戰解析:基于Python3編程語言
- Scala實用指南