Properties
To expose C# class members to Unreal Engine so they can participate in reflection, serialization, Blueprint access, and editor details panels they must:
[UClass]
public partial class AMyShowcaseClass : AActor
{
// Declares a default component which is automatically created and assigned
// when the actor is constructed. Marking it as RootComponent makes it the root.
[UProperty(DefaultComponent = true, RootComponent = true)]
public partial UStaticMeshComponent MyMesh { get; set; }
// Exposes a map to the editor and Blueprint.
// Note: TMap itself cannot currently be constructed with 'new' in C#.
[UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)]
public partial TMap<int, string> MyMap { get; set; }
[UProperty(PropertyFlags.EditAnywhere | PropertyFlags.BlueprintReadWrite)]
public partial TWeakObjectPtr<AMyShowcaseClass> MyWeakObject { get; set; }
public override void BeginPlay()
{
base.BeginPlay();
PrintString("BeginPlay called!");
// Assuming the enginehas initialized MyMap for you,
// you can use it like a normal map:
MyMap.Add(1, "First Value");
MyMap.Add(2, "Second Value");
MyWeakObject = this;
UpdateMapWithKey(2, "Updated Second Value");
}
}Last updated