Hi,
Right now the only way to add widgets to viewport is to use AddViewportWidget
(or similar) function but it just adds a widget on top of the viewport. I was wondering if one could wrap game viewport with custom widget?
So what I would like to achieve is something like in Heroes of Might&Magic. https://lh3.ggpht.com/pVricu4a1S63c3fXk6hcU7s0ykd8pfpHYd5h2VSKi2vG1TqFVP7Fq2uT-vyXiHd1FQ=h900
I want game viewport to be a part of panel widget so I can surround it with other widgets. I dont want these other widgets to cover my viewport.
So for the testing purposes I managed to modify PlayLevel.cpp
and change this line
PieWindow->SetContent( PieViewportWidget.ToSharedRef() );
so it looks like this:
PieWindow->SetContent( SNew(SHorizontalBox)
+SHorizontalBox::Slot()[SNullWidget::NullWidget]
+SHorizontalBox::Slot()[PieViewportWidget.ToSharedRef()] );
The result was just what I expected ( http://i.imgur.com/dK1N4o2.png ) but this will work only for Play in New Editor Window option. What I want is to have same effect in standalone game.
So I modified GameEngine.cpp
and change GameViewportWindowPtr->SetContent(
line like this
GameViewportWindowPtr->SetContent(SNew(SHorizontalBox)
+ SHorizontalBox::Slot()[SNullWidget::NullWidget]
+ SHorizontalBox::Slot()[GameViewportWidgetRef] );
But the result was quite different than expected: http://i.imgur.com/XcNppyf.png There are now 2 viewports, one on top of the other and I cant really figure out why is that.
I was thinking that maybe it could be possible to add a function like
virtual TSharedRef<SWidget> GetGameViewportWidget(TSharedRef<SWidget> ViewportWidget);
that would allow user to wrap viewport with any widget he/she wants. So if you would like to not wrap viewport with anything you would just return ViewportWidget;
but if you would like to wrap viewport with horizontal box (like in the examples above) you would
return SNew(SHorizontalBox)
+ SHorizontalBox::Slot()[SNullWidget::NullWidget]
+ SHorizontalBox::Slot()[ViewportWidget];
How difficult would it be to implement such a functionality? GameWindow creation code is kinda scattered (between editor and game engine) and complex, so before I start doing anything I would like to ask if this kind of engine modification wont cause too much complications? How much code will I have to adjust to get this thing working?
I also have no idea where this kind of function should be implemented. GameEngine? EditorEngine? maybe GameInstance or GameMode?
Any tips and thoughts appreciated,
Thanks