# \[Slate\] slate widget UI not displaying in viewport

**URL:** <https://forums.unrealengine.com/t/slate-slate-widget-ui-not-displaying-in-viewport/1201825>\
**Category:** UI\
**Tags:** unreal-engine, question\
**Created:** [June 17, 2023, 2:20am UTC](https://forums.unrealengine.com/t/slate-slate-widget-ui-not-displaying-in-viewport/1201825 "2023-06-17T02:20:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wade0608](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wade0608](https://forums.unrealengine.com/u/wade0608)\
**Post date:** [June 17, 2023, 2:20am UTC](https://forums.unrealengine.com/t/slate-slate-widget-ui-not-displaying-in-viewport/1201825/1 "2023-06-17T02:20:17Z")

</div>

> [@\[Slate\] UI not appearing when playing in viewport](https://forums.unrealengine.com/t/slate-ui-not-appearing-when-playing-in-viewport/275503/2):
>
> a

I follow this tutorial, but I not sure where I need to add the code.

> **[Using Slate In-Game](https://docs.unrealengine.com/5.0/en-US/using-slate-in-game-in-unreal-engine/)**
>
> Using Slate UI widgets for in-game user interfaces.

The tutorial say how to add the Widget to the Viewport, and give the code like this  
"  
GEngine-\>GameViewport-\>AddViewportWidgetContent(  
SNew(MyWidgetPtr.ToSharedRef())  
);

But I don’t know where I need to add.  
please help me!  
thanks!
