Attempted to reference UserWidget
This commit is contained in:
parent
4d53a2cdda
commit
eeaf52df89
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:fb0a77b0f469d017557974965bdd05383d263fdb8e96bb7d176fd760f02c53f2
|
oid sha256:09a051db65cef4e2912e96de44ad4da440b1c6fcc0ca839236ec49dc0eb8b943
|
||||||
size 30012
|
size 29574
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:e11da137b25dda1d74cb3fcbcc1feaaa4fa3d8cffb13e8994b75a01e3691eed7
|
oid sha256:9e83d7e34f1e94c19d2edbe7aa2755b6261c1c7ddb3628e668fd77a1356b59e0
|
||||||
size 23038
|
size 23038
|
||||||
|
BIN
Content/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
BIN
Content/Merchant/BP_MerchantGameMode.uasset
(Stored with Git LFS)
Binary file not shown.
@ -13,12 +13,23 @@ ATempCharacter::ATempCharacter()
|
|||||||
{
|
{
|
||||||
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||||
PrimaryActorTick.bCanEverTick = true;
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
//WidgetRef = CreateDefaultSubobject<UUserWidget>(TEXT("Widget Reference"));
|
||||||
|
|
||||||
|
//FStringClassReference WidgetClassRef(TEXT("/Game/Merchant/BP_OPENDIAL.BP_OPENDIAL"));
|
||||||
|
//WidgetClass = WidgetClassRef.TryLoadClass<UUserWidget>();
|
||||||
|
|
||||||
|
//WidgetClass = CreateWidget<UUserWidget>(GetWorld(),WidgetClass);
|
||||||
|
if(WidgetRef)
|
||||||
|
{
|
||||||
|
WidgetRef->AddToViewport(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
void ATempCharacter::BeginPlay()
|
void ATempCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Binds the input we made in the setup player component to the forward vector
|
//Binds the input we made in the setup player component to the forward vector
|
||||||
@ -68,44 +79,14 @@ void ATempCharacter::LineTraceLogic()
|
|||||||
|
|
||||||
TraceParams.AddIgnoredActor(this);
|
TraceParams.AddIgnoredActor(this);
|
||||||
|
|
||||||
/*bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams);
|
bool bHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, TraceParams);
|
||||||
if (bHit)
|
if (bHit)
|
||||||
{
|
{
|
||||||
if (OutHit.GetActor()->ActorHasTag("MerchantTag"))
|
if (OutHit.GetActor()->ActorHasTag("MerchantTag"))
|
||||||
{
|
{
|
||||||
FStringClassReference WidgetRef(TEXT("WidgetBlueprint/Game/Merchant/BP_OPENDIAL.BP_OPENDIAL"));
|
WidgetRef->AddToViewport(0);
|
||||||
TSubclassOf<class UUserWidget> WidgetLoad = WidgetRef.TryLoadClass<UUserWidget>();
|
|
||||||
|
|
||||||
UUserWidget* TestWidget = CreateWidget<UUserWidget>(this, WidgetLoad, FName(TEXT("MyWidget")));
|
|
||||||
if(TestWidget)
|
|
||||||
{
|
|
||||||
TestWidget->AddToViewport(0);
|
|
||||||
}
|
|
||||||
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
|
DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f);
|
||||||
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// In a constructor
|
|
||||||
FStringClassReference MyWidgetClassRef(TEXT("/Game/Widgets/TestWidget.TestWidget_C"));
|
|
||||||
// Get the widget class
|
|
||||||
|
|
||||||
TSubclassOf<class UUserWidget> TestWidgetClass = MyWidgetClassRef.TryLoadClass<UUserWidget>();
|
|
||||||
|
|
||||||
// ... then to display you widget do
|
|
||||||
|
|
||||||
// Check if class was found
|
|
||||||
if (TestWidgetClass )
|
|
||||||
{
|
|
||||||
// Create the widget
|
|
||||||
UUserWidget* TestWidget= CreateWidget<UUserWidget>(this, TestWidgetClass, FName(TEXT("MyWidget")));
|
|
||||||
// Check if widget was created
|
|
||||||
if (TestWidget)
|
|
||||||
{
|
|
||||||
TestWidget->AddToViewport();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// I GIVE UP LOL!
|
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,12 @@ public:
|
|||||||
float TraceDistance = 200;
|
float TraceDistance = 200;
|
||||||
|
|
||||||
void LineTraceLogic();
|
void LineTraceLogic();
|
||||||
|
|
||||||
|
UPROPERTY(EditBlueprintReadWrite, meta = (BindWidget))
|
||||||
|
UUserWidget* WidgetRef;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
|
||||||
|
//UPROPERTY(EditDefaultsOnly)
|
||||||
|
//TSubclassOf<UUserWidget> WidgetClass;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user