Download

How do I spawn a 3D widget in C++?

What I am currently doing is the following. However this generates several errors on Compile.

.h


/** 3D Widget */
UPROPERTY(EditAnywhere, Category = Widget)
 
class UWidgetComponent* Screen; //This is the only line of Code that will compile, but only by itself.
 
 

.c


//Widget Settings
 Screen = CreateDefaultSubobject<UWidgetComponent>(TEXT("Screen"));
//Mesh is of type StaticMesh
//Camera is a Socket on StaticMesh
 Screen->AttachToComponent(Mesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, TEXT("Camera"));

Build LOG
[SPOILER]



1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: SpaceStation, Configuration: Development_Editor x64 ------
2>Using 'git status' to determine working set for adaptive non-unity build.
2>Building 1 action with 8 processes...
2>  [1/1] UE4Editor-SpaceStation.dll
2>     Creating library H:\Video Game Making\Project\SpaceStation\Intermediate\Build\Win64\UE4Editor\Development\SpaceStation\UE4Editor-SpaceStation.suppressed.lib and object H:\Video Game Making\Project\SpaceStation\Intermediate\Build\Win64\UE4Editor\Development\SpaceStation\UE4Editor-SpaceStation.suppressed.exp
2>SS_BaseInteractionActor.gen.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class UClass * __cdecl Z_Construct_UClass_UWidgetComponent_NoRegister(void)" (__imp_?Z_Construct_UClass_UWidgetComponent_NoRegister@@YAPEAVUClass@@XZ) referenced in function "void __cdecl `dynamic initializer for 'public: static struct UE4CodeGen_Private::FObjectPropertyParams const Z_Construct_UClass_***_BaseInteractionActor_Statics::NewProp_Screen''(void)" (??__E?NewProp_Screen@Z_Construct_UClass_***_BaseInteractionActor_Statics@@2UFObjectPropertyParams@UE4CodeGen_Private@@B@@YAXXZ)
2&gt;H:\Video Game Making\Project\SpaceStation\Binaries\Win64\UE4Editor-SpaceStation.dll : fatal error LNK1120: 1 unresolved externals
2&gt;UnrealBuildTool : error : UBT ERROR: Failed to produce item: H:\Video Game Making\Project\SpaceStation\Binaries\Win64\UE4Editor-SpaceStation.dll
2&gt;                        (see ../Programs/UnrealBuildTool/Log.txt for full exception trace)
2&gt;Total build time: 2.50 seconds (Parallel executor: 0.00 seconds)
2&gt;H:\Software\Visual Studio 2017\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3075: The command "D:\software\Unreal\UE_4.20\Engine\Build\BatchFiles\Build.bat SpaceStationEditor Win64 Development "H:\Video Game Making\Project\SpaceStation\SpaceStation.uproject" -WaitMutex -FromMsBuild" exited with code 5. Please verify that you have sufficient rights to run this command.
2&gt;Done building project "SpaceStation.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

[/SPOILER]

1 Like