I raised this as a question here https://answers.unrealengine.com/questions/173632/creating-uwidgetcomponent-using-c.html - but the more I look at it the more it seems like a bug rather than something I’ve done wrong.
I create a new UWidgetComponent on my Character Pawn
AFFCharacter::AFFCharacter(const class FObjectInitializer& PCIP)
: Super(PCIP.SetDefaultSubobjectClass<UFFCharacterMovement>(ACharacter::CharacterMovementComponentName))
{
CapsuleHeight = 96.0f;
CapsuleRadius = 45.0f;
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(CapsuleHeight, CapsuleRadius);
// set our turn rates for input
BaseTurnRate = 45.f;
BaseLookUpRate = 45.f;
// Default offset from the character location for projectiles to spawn
GunOffset = FVector(100.0f, 30.0f, 10.0f);
// Create a CameraComponent
PlayerCameraComponent = PCIP.CreateDefaultSubobject<UCameraComponent>(this, TEXT("PlayerCamera"));
PlayerCameraComponent->AttachParent = GetCapsuleComponent();
PlayerCameraComponent->AttachSocketName = FName(TEXT("HeadCameraSocket"));
//PlayerCameraComponent->RelativeLocation = FVector(0, 0, 64.f); // Position the camera
UMeshComponent* PlayerMesh = GetMesh();
PlayerMesh->SetOnlyOwnerSee(false); // only the owning player will see this mesh
PlayerMesh->AttachParent = PlayerCameraComponent;
PlayerMesh->bCastDynamicShadow = true;
PlayerMesh->CastShadow = true;
// Create a first person mesh, so we can switch between first and third person
FirstPersonMesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("FirstPersonMesh"));
FirstPersonMesh->SetOnlyOwnerSee(true); // only the owning player will see this mesh
FirstPersonMesh->AttachParent = PlayerCameraComponent;
FirstPersonMesh->RelativeLocation = FVector(0.f, 0.f, -150.f);
FirstPersonMesh->bCastDynamicShadow = false;
FirstPersonMesh->CastShadow = false;
// Create a component for doing a 3d pointer to the source of the damage
DamageSourceWidget = PCIP.CreateDefaultSubobject<UWidgetComponent>(this, TEXT("DamageSource"));
DamageSourceWidget->SetOnlyOwnerSee(true);
DamageSourceWidget->AttachParent = PlayerCameraComponent;
DamageSourceWidget->RelativeLocation = FVector(220.0f, -50.0f, 0.0f);
DamageSourceWidget->RelativeRotation = FRotator(40.0f, 0.0f, 90.0f);
// Set that we allow crouching in this game
GetCharacterMovement()->GetNavAgentProperties()->bCanCrouch = true;
// Note: The ProjectileClass and the skeletal mesh/anim blueprints for Mesh1P are set in the
// derived blueprint asset named MyCharacter (to avoid direct content references in C++)
WallRunInitialClimbSpeed = 200;
WallRunGravityScale = 0.5;
Health = 100;
DamageScaling = 1.0f;
DoubleTapToDiveTime = 0.5f;
}
The result is that the widget is not editable in the unreal engine editor
https://dl.dropboxusercontent.com/s/b059fhas9f8h9z6/broken-widget.PNG?dl=0
When using the unreal engine editor to add a widget, the details panel has all the stuff I want to edit
https://dl.dropboxusercontent.com/s/qg8e8ryfqmuv0as/expected-widget.PNG?dl=0