en:toolworks:docs:apparatus:trait

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:toolworks:docs:apparatus:trait [2022/04/27 22:22] vladiusen:toolworks:docs:apparatus:trait [2022/06/07 10:53] (current) – Fix structure name. jispar
Line 23: Line 23:
 You should mainly refer to the official Unreal Engine manual on creating [[ue>ProgrammingAndScripting/GameplayArchitecture/Structs/UsingStructs|UStructs]]. You should mainly refer to the official Unreal Engine manual on creating [[ue>ProgrammingAndScripting/GameplayArchitecture/Structs/UsingStructs|UStructs]].
  
-You basically create a header (.h) file and optionally a source (.cpp) file. An example of such header-only Trait would be:<code cpp>+You basically create a header (''.h'') file and optionally a source (''.cpp'') file. An example of such header-only Trait would be:<code cpp>
 #pragma once #pragma once
  
 #include "CoreMinimal.h" #include "CoreMinimal.h"
-#include "MyTrait.generated.h"+#include "Moving.generated.h"
  
 /** /**
- + The state of being moved with a certain velocity.
  */  */
 USTRUCT(BlueprintType) USTRUCT(BlueprintType)
-struct MY_API FMyTrait+struct MY_API FMoving
 { {
  GENERATED_BODY()  GENERATED_BODY()
Line 48: Line 48:
  
 You could omit the [[ue>ProgrammingAndScripting/GameplayArchitecture/Properties|UPROPERTY]] specifications but You could omit the [[ue>ProgrammingAndScripting/GameplayArchitecture/Properties|UPROPERTY]] specifications but
-with the fields exposed like that you can now use ''MyTrait'' both in your C++ code and within BPs.+with the fields exposed like that you can now use ''FMoving'' both in your C++ code and within BPs.
  
 +==== Blueprint Workflow ====
  
 +As basically every Unreal Engine's ''USTRUCT'' is actually a Trait creating one through the Editor is quite simple. Rigth-Click on some empty space inside the Content Browser and choose **Blueprints** → **Structure**.
 +
 +{{ :en:toolworks:docs:apparatus:ue-create-bp-struct.png?nolink |}}
 +
 +This will create a new asset file right inside the designated folder. You should give it an appropriate name after that.
 +
 +{{ :en:toolworks:docs:apparatus:ue-name-bp-struct.png?nolink |}}
 +
 +That's basically it and from now on the created structure can be used right inside your [[en:toolworks:docs:apparatus:filter|Filters]].
  • en/toolworks/docs/apparatus/trait.1651087359.txt.gz
  • Last modified: 2022/04/27 22:22
  • by vladius