39 UConsole* ViewportConsole = (GEngine->GameViewport !=
nullptr) ? GEngine->GameViewport->ViewportConsole :
nullptr;
44 ViewportConsole->FakeGotoState(
FName(TEXT(
"Typing")));
45 ViewportConsole->InputKey(0, Key, KeyEvent);
46 ViewportConsole->FakeGotoState(NAME_None);
51 UConsole* ViewportConsole = (GEngine->GameViewport !=
nullptr) ? GEngine->GameViewport->ViewportConsole :
nullptr;
56 ViewportConsole->AppendInputText(Text);
60 ViewportConsole->FakeGotoState(
FName(TEXT(
"Typing")));
61 ViewportConsole->InputKey(0, EKeys::Enter, EInputEvent::IE_Released);
62 ViewportConsole->FakeGotoState(NAME_None);
76 UWorld* World = GetWorld();
82 UCanvas* Canvas = World->GetCanvasForRenderingToTarget();
90 FCanvas * RenderCanvas =
new FCanvas(
91 Texture->GameThread_GetRenderTargetResource(),
96 FCanvas::CDM_ImmediateDrawing);
98 Canvas->Init(Texture->GetSurfaceWidth(), Texture->GetSurfaceHeight(),
nullptr, RenderCanvas);
110 Canvas->Canvas =
nullptr;
111 RenderCanvas->Flush_GameThread();
113 RenderCanvas =
nullptr;
146 UFont* Font = GEngine->GetSmallFont();
150 Canvas->StrLen(Font, TEXT(
"M"), xl, yl);
151 float Height = FMath::FloorToFloat(Canvas->ClipY);
155 FLinearColor BackgroundColor = FColor::Black.ReinterpretAsLinear();
156 BackgroundColor.A = 1.0f;
157 FCanvasTileItem ConsoleTile(FVector2D(0, 0.0f), GBlackTexture, FVector2D(Canvas->ClipX, Canvas->ClipY), FVector2D(0.0f, 0.0f), FVector2D(1.0f, 1.0f), BackgroundColor);
160 ConsoleTile.BlendMode = SE_BLEND_AlphaBlend;
162 Canvas->DrawItem(ConsoleTile);
164 FCanvasTextItem ConsoleText(FVector2D(0, 0 + Height - 5 - yl), FText::FromString(TEXT(
"")), Font, FColor::Emerald);
170 if(ScrollOffset > 0 && LoggedMessages.Num() > 1)
171 ScrollPos = FMath::Clamp(FMath::RoundToInt(LoggedMessages.Num() * ScrollOffset ) , 0, LoggedMessages.Num() - 1);
175 for (
int i = LoggedMessages.Num() - (1 + ScrollPos); i >= 0 && Ypos <= Height - yl; i--)
177 switch (LoggedMessages[i]->Verbosity)
180 case ELogVerbosity::Error:
181 case ELogVerbosity::Fatal: ConsoleText.SetColor(FLinearColor(0.7f,0.1f,0.1f));
break;
182 case ELogVerbosity::Warning: ConsoleText.SetColor(FLinearColor(0.5f,0.5f,0.0f));
break;
184 case ELogVerbosity::Log:
185 default: ConsoleText.SetColor(FLinearColor(0.8f,0.8f,0.8f));
189 ConsoleText.Text = FText::Format(NSLOCTEXT(
"VRLogComponent",
"ConsoleFormat",
"{0}"), FText::FromString(*LoggedMessages[i]->Message));
190 Canvas->DrawItem(ConsoleText, 0, Height - Ypos);
const TArray< TSharedPtr< FVRLogMessage > > & GetMessages() const
void AppendTextToConsole(FString Text, bool bReturnAtEnd=false)
UFUNCTION(BlueprintCallable, Category = "VRLogComponent|Console", meta = (bIgnoreSelf = "true"))
bool DrawConsoleToRenderTarget2D(EBPVRConsoleDrawType DrawType, UTextureRenderTarget2D *Texture, float ScrollOffset, bool bForceDraw)
UFUNCTION(BlueprintCallable, Category = "VRLogComponent|Console", meta = (bIgnoreSelf = "true",...