I have been reading through the documentation and cant really see any discussion of how Blueprint can be used to draw slate UI/Hud? Is this possible? or do you have to create it through C++ alone/first?
All I want to create is a very simple menu. It doesn’t need functioning buttons only to draw the image to camera and instruct the player as to what buttons to press that will be handled in that levels level blueprint.
Any help on this would be appreciated!
Hi, first of all, you need disconnect the SizeX and SizeY on the EventReceiveDrawHUD node. This just feeds in the actual screen width and height.
ScreenX and ScreenY is the location to draw the Material onscreen starting at the top left corner in pixels.
Screen W and Screen H is the Width and Height in pixels it will be onscreen.
You need to give your Draw Material function info for MaterialU and MaterialV, this is telling it where to clip the texture in 0 to 1 UV space. You can get this info by dividing the top left corner of where you want to clip the textures location in pixes by the width of the texture. So if you wanted to clip starting at 200 pixels from the left of the texture you would set your MaterialU to 0.3906 which is 200 divided by 512. Then do the same thing for the MaterialV, which is the vertical.
You also need to give it info for MaterialUWidth, and MaterialVHeight. This is how big of an area to clip from the texture in 0 to 1 UV space. So if you wanted to clip an area from the 512 texture that is 400 pixels wide, you would do the same formula. 400 divided by 512 would give you 0.7812.
I hope this helps.
Thanks for the help! I now have this drawing to the screen however my material is drawing solid black? I think I read somewhere else that this is a known issue to be fixed in a future release? or is this something that I am doing wrong?
Make your material Unlit and run the diffuse into the Emissive channel. If you not doing anything special in the material, you could just use DrawTexture instead of DrawMaterial. You will need to set the Tint Color for it to show up ,you can drag off of it and MakeLiteralColor, or create a variable called Line Color and hook it up here. Make sure you set the alpha to 1 unless you want it to be transparent too.
To create a HUD you want to create a Blueprint derived from the HUD class. This gives you ReceiveDrawHUD event and lots of drawing functions (DrawText, DrawTexture etc). You can set the default HUD to use in your GameInfo Blueprint (the same place you set the default Pawn class to use). In the next release HUD also allows you to create ‘clickable’ regions. We are also looking to add a simple ‘menu builder’ that will be Blueprint accessible.
Thanks for the quick reply, I am having some issues with my HUD blueprint. I have managed to construct a blueprint that is derived from the HUD class and I am attempting to get it to draw a material to the screen.
Here is the defaults of “mygame”
Sadly this isn’t displaying anything to the screen.
Is there something wrong with my blueprint setup? or is there something else I need to do to get this to render?