#slate
1 messages · Page 23 of 1
Cool - thanks. I’ll see if I can replicate this tomorrow.
UDN is the Unreal Developer Network. A bit like AnswerHub but with more responses from Epic staff. You get access to if it you’re paying for the engine
Ahh I see
But yeah even with two DrawWidget calls in my usecase where I'm generating about 240 textures using this, with widgets that contain several textboxes and some images, it performs just fine which is pretty nice :)
That’s not so bad. I’m going to be needing to do 1 per frame, maybe 2
when it comes to detail customizations, is there a way to get property handles of child objects? With structs it's pretty straight forward, but I failed whenever I tried accessing properties of child objects.
Possibly, but just any object ptrs inside.
Object A -> Object B and you are customizing A, and want to show properties of B directly (sort of how instanced works too)
@royal geode
Yeah that's what I'm wondering, either how to do that or how to access them
I've not been able to figure out how to create your own handles yet rather than just getting them from the layout builder
Or if it's feasible at all
Thats not going to be fun because frankly I have one more layer of indirection lol
ObjectA -> ObjectB-> ObjectC -> childpropertyhandle I want to have for object A
am i correct in thinking that slate runs on a separate threat? or is at least able to be run in a new thread with no interaction
@sweet steppe Not threaded, not able to be so
what could be a good way to go about smooth loading screens then if not slate?
Loading screens work well when they are a separate engine module (process) running their own Slate stuff
Maybe something like https://github.com/ue4plugins/LoadingScreen
Failing that you can investigate the DefaultMoviePlayer and fork it
IIRC it's threaded in a weird way
@quaint zealot so lets say we have a search box and its super slow due to the amount of comparisons it has to perform, we cant multi thread the search?
Sure you can !
You can multithread the search code or filtering code
Just not the Slate code
It's largely the same tick-based architecture as the game thread - you have a tick event, draw event, callbacks, all on game thread
Game UI code is usually 1) very fast and 2) very game-state-dependent so MT is not really an obvious idea
ahh ok good, thank you :) I just tested the search box of our custom asset picker with a production ready project, with over 90.000 objects.. it's slow, very slow
Yeah if the search part is the slow part, make that multithreaded and have yourt widget tick pick the latest results safely
Anyone know how to make a slate widget for a property array that looks like all the stock ones in editor?
I've been making my own with an SListView but it seems like there should be a better way.
Has anyone ran into this ensure when using rich text block decorators with global invalidation on?
https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/SlateCore/Private/Widgets/SWidget.cpp#L1272
how do you use global invalidation in the first place? I tried turning it on in packaged mode and the entire UI was ruined, all layouts broken.
I only toggle it on within a match itself. And leave it off when at menus
This is what Fortnite does as well
But yeah it's still buggy, even with 4.26 cherrypicks and is still being iterated on by Epic
Hello all! This is my first post in this channel. 🥳
Late last night, Zeblote was helping me with a problem that I had posted in as general of a form as possible, in #umg:
https://discordapp.com/channels/187217643009212416/221799467689574410/744515507188924506
He was able to help me get the results I needed, but we both agreed that it was not optimal; he said that if I wanted to do it the "correct" way, I'd have to "create a custom slate view which takes a lot of effort".
Now, I don't mind a lot of effort. Ultimately, what I do mind, however, is not doing something correctly just because I never bothered to learn the correct way.
So, I was wondering if there is a tutorial video or series of articles that y'all can direct me to that would help best to learn slate. If there are any do-good-samaritan-angels out there, of course I'd be very appreciative if anyone would follow that link I posted and check out my problem statement, but that is not necessary. Just a little guide on a first step is all I'm really after.
Thank you!
P.S. @main hedge I hope you don't take that ^ as me not appreciating the help you gave me last night; I simply want to learn the correct way, since you mentioned there being one 🙂
After some searching, I think I found a pretty good intro to it:
http://students.ceid.upatras.gr/~vpapadatos/UE4cpp_slate_1.html
hey my slate bois and gals, do you know where dock-ability for a tab is defined? Sequencer for example only lets me dock it in certain places in the main editor window, but not for example in my own asset editor toolkit that uses tabs
Does anyone have any good resources for getting started with slate?
I've been watching this video: https://www.youtube.com/watch?v=jeK6DPB5weA
But I'm getting an rvalue type conversion error when trying to add a slate widget to the HUD.
Try my C++ Survival Game Course:
http://bit.ly/unrealsurvival
Discord:
https://discord.gg/meFRZfm
Today we're going to be using the Slate Framework to do pure C++ UI in Unreal. This gives you more features, and better performance.
Is anyone familiar with how to solve this sort of error? Or perhaps have a better solution to adding a widget to the viewport/hud?
Well, where is the error ?
Ah, alright
@alpine marsh You need to use a curiously recurring template for shared ptr functionality, basically
class AMenuHud : public AHUD, public TSharedFromThis<AMenuHud >
It's a somewhat obscure C++ thing that allows quite interesting stuff
I'm still getting the same error when I try that
MenuHud.cpp(15): [C2664] 'SMainMenuWidget::FArguments::WidgetArgsType &SMainMenuWidget::FArguments::OwningHUD(TWeakObjectPtr<AMenuHUD,FWeakObjectPtr>)': cannot convert argument 1 from 'AMenuHud *' to 'TWeakObjectPtr<AMenuHUD,FWeakObjectPtr>'
Eheh
You messed up the case, @alpine marsh
Your forward decl' is uppercase HUD
So as far as C++ is concerned it's an entirely different type
Yep thats it, I cant believe I didnt spot that
Thanks so much, its always the small errors that I miss
For type related error you have to look very carefully into both types from the compiler log
It's always a technicality so every letter matters
Mhm, Thanks for the advice. I'll be sure to look more carefully
How do you use colors that aren't predefined?
More specifically, how can I set the value of FColor to a hexadecimal value?
Currently I'm doing: .ColorAndOpacity(FColor::Black) but I would much rather use a different color say, #2C3531.
Look at the signature of ColorAndOpacity, Visual Studio should autocomplete for you to show what's available
Or look at the docs
The documents aren't quite clear for using Hex
The only thing I can find is using FColor::FromHex(); but I'm still unsure of how to actually pass a hexstring to that. Just doing FColor::FromHex(#2C3531) throws an error.
its quite easy, it takes RGBA uint8 as constructor parameter
FColor foo{255, 255, 255, 255};
oh nwm didnt read the hex part
FColor foo{FColor::FromHex(FString{"2C3531"})};
Thanks ill try that out
well I'm no longer getting an error, but the color output looks like this ingame:
My expected output should have been:
yeah that happends to me aswell when using Valign- fill and halign - fill. not sure whats causing it but coloring buttons etc works as expected
hmm interesting, I figured it mightve been an opacity issue then
allso if youre following reubens tutorial wich i allso watched recently, theres some stupid stuff you can avoid
How would you recommend going about making a colored background? (Takes up the entire screen)
Yeah I followed a bit of it, hes not very clear and just copy/pastes alot of stuff
you dont have to include Engine/Engine.h just #include "Engine/GameViewportClient.h"
#include "Engine/World.h" GetWorld()->GetGameViewport()-> will do the same as the global engine pointer
Do you have any other resources you would recommend for getting started with slate?
and the MenuWidgetContainer is completely unnecesairy, not sure if he intended to do other fancy stuff with it later but you can do .ToSharedref() on the MenuWidget pointer to display it, much cleaner code
theres not many tutorials for slate sadly, engine source is the best you will find lol
Gotcha, I was hoping that wasn't the case, the documentation isn't the greatest.
IIRC there's a plugin for CSS -> Slate, so I might give that a try as well and compare the results.
about making the whole viewport colored, i guess you could try displaying an actual image instead of a color
I might try that
FColor foo{FColor::FromHex(FString{"2C3531"})};
FColor(0x31, 0x35, 0x2C, 0)
By the way the grid is Slate's default brush
Doing a solid green brush in Slate would usually be done with a solid white brush tinted green directly in the brush
is there any way to preview slate in the editor?
Maybe adding it to an UMG widget
Probably just as fast to rig a custom player controller that just shows that widget and use that in a dedicated test level, though
UMG have some special functions for preview
TSharedRef<SWidget> USimpleMpegViewerWidget::RebuildWidget()
{
if (IsDesignTime())
{
return SNew(SBox)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(LOCTEXT("Simple Mpeg Viewer", "Simple Mpeg Viewer"))
];
}
mSimpleMpegViewer = SNew(SSimpleMpegViewer);
return mSimpleMpegViewer.ToSharedRef();
}
like this
<-- Slate supernoob here
Can anyone give me their opinion of how you would qualify when you need to use Slate vs you can make it work using UMG?
I have this widget I want to build that is possible with UMG, but it requires a kind of "hacky" (in a bad way) solution that involves artificially pushing elements around using negative margins, etc.
Now, I'm not the greatest UMG wiz, either, so I'm sure there may be an even better way to do it in just UMG, but would this be a scenario where you'd normally use Slate (given that you can't find a better alternative in UMG)?
Probably best to subclass SLeafWidget and use OnPaint to draw the elements yourself
take a look at SSlider as an example
Based on your description, at least
Is there an SDelete that you have to call for every SNew in your code? I've heard that GC doesn't work for Slate, and you have to manage that manually, so I figure maybe there is an SDelete...
No - SNew returns a TSharedRef
(also, be aware of SAssignNew)
Slate is very much based around TSharedRef/TSharedPtr
I'm starting to notice
So, is there nothing that I need to do manually in order to clean up Slate stuff correctly? Don't need to put anything in the destructor, etc?
nope - not if you're pure Slate
If you make a UMG widget that contains a Slate widget, then you need to do some cleanup
okay, I see. What do you need to do in that scenario?
Nvm, don't answer that. That's hypothetical, I haven't gotten to that yet
Anyone know how to generate a USlateVectorArtData object from a static mesh? I'm having trouble making one that I can use with an SMeshWidget.
It’s ReleaseSlateResources that you care about at that point
@humble gale Were you ever able to get your SMeshWidget implementation working?
Hi, can I add material to SImage?
I can't find the definition of the operator overload for the operator+() in Slate. The .PropertyName() are properties, I assume, but what does the + do?
add children?
it adds a slot
that one in SVerticalBox but all of the ones i found are the same
ah ok
Do I need to #include "Widgets/..." for every type that I use with SNew(SWidgetType)?
k that's a yes I figured out
I am just doing a test, and at a leaf node, I have this:
// ...
SNew(SButton)
.HAlign(HAlign_Fill).VAlign(VAlign_Fill)
.Content()
[
]
// ...
Compiler says it expects something inside the empty square brackets
Do I have to put something?
I don't really want anything there
oh okay, thanks! 🙂
Or don’t include the brackets at all. When you have content inside a widget, you don’t need to do Content() - the square brackets imply that.
Also, if you’re putting more widgets inside, I’d recommend subclassing SCompoundWidget instead of SLeafWidget
It is a subclass of SCompoundWidget. I just said "leaf" like, in general. There may be, say, an image or text widget inside the button, but the button does act as like a functional leaf
in my use case, anyway
@weary eagle hi man,
Glad to listen regarding the smeshwidget, I got it working.
I still need to make it a generic system. At the moment it works with my hard-coded settings.
@gritty frigate so you're saying, this is equivalent to what I wrote above?
SNew(SButton)
.HAlign(HAlign_Fill).VAlign(Valign_Fill)
Note: I originally had a line with .Text(TEXT("BUTTON")) but that didn't compile, I erased it
Yes. Also, Text() needs an FText, so you’ll need to use LOCTEXT or INVTEXT
It is a subclass of SCompoundWidget. I just said "leaf" like, in general. There may be, say, an image or text widget inside the button, but the button does act as like a functional leaf
@livid gust cool. SLeafWidget is a specific class, which is why I thought you meant that
Yes. Also, Text() needs an FText, so you’ll need to use LOCTEXT or INVTEXT
I’m now trying to remember if a button supports text like this? I think it does, but if not you’ll need to drop an STextBlock inside it. I created all my own button subclasses.
I had another question for y'all:
I had been using this very nice beginner's Slate tutorial
http://students.ceid.upatras.gr/~vpapadatos/UE4cpp_slate_1.html
but there are two specific parts that I was a little surprised by, and I was wondering if this is standard practice or not with Slate code.
For the following example, we have a MyHUD subclass of AHUD and an SMyWidget subclass of SCompoundWidget (and, of course, anything irrelevant to the example is omitted):
// MyHUD.h
class SMyWidget;
class AMyHUD : public AHUD
{
public:
void BeginPlay(); // <-- Question 1
TSharedPtr<SMyWidget> MyWidget;
};
// MyHUD.cpp
#include "SMyWidget.h"
void AMyHUD::BeginPlay()
{
MyWidget = SNew(SMyWidget).OwnerHUD(this);
GEngine->GameViewport->AddViewportWidgetContent(
SNew(SWeakWidget).PossiblyNullContent(MyWidget.ToSharedRef())
);
MyWidget->SetVisibility(EVisibility::Visible);
}
// SMyWidget.h
#include "MyHUD.h"
class SMyWidget : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SMyWidget)
{}
SLATE_ARGUMENT(TWeakObjectPtr<AMyHUD>, OwnerHUD)
SLATE_END_ARGS()
void Construct(const FArguments& InArgs);
private:
TWeakObjectPtr<AMyHUD> OwnerHUD;
};
- Why is AMyHUD::BeginPlay() not declared as virtual and override? Was that a typo or is that normal?
- Is it normal to include HUD.h into the widget class which it will contain? This seems backward. Why does a widget need a way to access its owning HUD?
- yes, I believe that this is a typo. It doesn’t need both, though, as “override” implies “virtual”
He doesn't actually do anything with the SMyWidget::OwnerHUD member yet in that tutorial, so I'm not sure what the plan is for question 2
- this is so that the slate widget can call functions on the HUD, for example - when you click a button, you might want it to call something on your HUD that can then interact with something else in your game
except to do this:
void SMyWidget::Construct(const FArguments& InArgs)
{
OwnerHUD = InArgs._OwnerHUD;
// ...
You could do 2) instead with delegates that you pass in from the HUD, but both are options.
- this is so that the slate widget can call functions on the HUD, for example - when you click a button, you might want it to call something on your HUD that can then interact with something else in your game
@gritty frigate Okay. That clears up the issue pretty well, thank you.
Is that pretty standard?
I couldn’t say. I know it’s how I do it, but I figured out a lot of my approach on my own
That's how you do it?
Yes
okay. Thank you so much, Hugh.
You’re welcome
Oh, one last question
I know what a weak pointer is (at least what std::weak_ptr is). Is that standard as well? AFAIK, weak pointers are used to avoid a circular reference chain that would prevent the destructor from being called otherwise. Is it related to my previous questions as to the reason that is necessary? (because a child widget can reference the HUD can reference that same child widget can reference the HUD can ...)
And also (unrelated):
What is the equivalent of the "Draw As" property in a UMG WidgetBP Border widget's Appearance details panel, but in Slate?
Weak object pointer is to a garbage collected uobject what weak pointer is to a shared pointer
It’s used here so that the hud widget can check if the hud is still alive or gas been garbage collected
ah okay, I see. So it is standard to use that instead of TSharedPtr
thanks again Hugh
Regarding Draw As, I’ll have to check my code. Give me an hour or so and I’ll let you know
It’s standard to use weak object pointer when referring to uobjects from a class that doesn’t support UPROPERTY
I don't see anything similar to it in SBorder.h except maybe the .BorderImage() property?
Does this get the brush being used?:
FCoreStyle::Get().GetBrush("Border")
that's what is passed into .BorderImage() by default
in SBorder.h
Your can get it that way, yes. I created my own Style class that I could get styles from
👍
In my Style struct, I would get a core style, modify it, then store in mine.
You can always change the style elements in place though - you don’t have to do it in a whole struct unless you want a unified style
Found this regarding the brush:
https://answers.unrealengine.com/questions/421948/create-a-fbrush-for-slate.html
Cool.
@humble gale Hey man! Thanks for replying! Basically, I'm trying to set up an SMeshWidget and can't figure out how to create a USlateVectorArtData object for my mesh. I created a new class that derives from USlateVectorArtData and made it Blueprintable so that I could set the mesh in BP, then I went to set it on my SMeshWidget and the dropdown won't populate anything. It doesn't recognize the one I made. None of the examples I found talk about how to create that object. What did you do for yours?
Is there something I need to do on the material side or something like that?
@weary eagle have you tried this
https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/78062-umg-3d-widget-used-in-paragon
Build powerful visual scripts without code.
@humble gale Right, so I saw this but it doesn't cover the actual creation of the USlateVectorArtData you're planning to use. Unless I'm missing something...
I also looked at the other thread linked there where @ruby scroll was setting something up with SMeshWidget, but the same issue where this step isn't talked about.
Give me sometime, I will boot my PC and take a look on my implementation .
Thanks so much. 🙂
Approx 20 mins
It's weird because I can create a class of type USlateVectorArtData but it doesn't show up in the dropdown when I go to set it on my Widget. 🤷♂️
@weary eagle ```/**
- Turn static mesh data into Slate's simple vector art format.
*/
UCLASS()
class UMG_API USlateVectorArtData : public UObject``` The class is not BlueprintType, so it won't show in Editor.
Since you have derived your own class you can make your derived class to be blueprintable
UCLASS(Blueprintable, BlueprintType, EditInlineNew)
I don't know how I got it working. But its weird that the state asset in not blueprintable
Ohh I remember now, i first cloned the project from above forum and made things working and then migrated the stuff to my main project.
so for me the USlateVectorArtData was already created
Hmm... ok. I tried adding BlueprintType and EditInlineNew to my UCLASS declaration, but no help. Weird that the dropdown on my Widget doesn't recognize the assets I've created.
try to copy the slate asset from the example project
have you created the asset first?
import this file in your project
@crude badger What file extension should this have? UE4 won't let me import it as a .uasset
Get guys, basic question here. How do I stop my slate widget from scaling with the window?
There are some default scaling options in the project settings, but I dont know if that applies to slate as well as UMG
@civic pasture
@odd hatch Thanks for the suggestion. I don't quite see the option there. Maybe I'll try and find where the slate widget gallery code is located and reverse engineer that.
Search for 'scale' in project settings (or engine, but pretty sure it's in project) @civic pasture , you get a graph curve of resolution vs. Scale
@odd hatch Wow, that worked! Thank you!
We have a problem where a SMenuAnchor behaves different in shipped game compared to in editor. The SMenuAnchor is used in a WidgetComponent. The MenuAnchor requests the outer window to check if the popup would fit into the window to adjust the popup location. To do that the Anchor looks for the outer Window in its widget path. Here is the problem: In the shipping game, the Window returned is the GameWindow itself. In Editor the Window returned is a virtual window for the WidgetComponent (which is correct). Any ideas?
The problem has to do with using the FastWidgetPath
GSlateFastWidgetPath
console variable slate.EnableFastWidgetPath which is used in shipping but not in editor
anyone know how to disable the drop shadow of a border? The border image I'm using has no actual border, yet a shadow shows up, so I believe it's default functionality
if that's not the issue then it's probably the SGraphNode... 👀
ok figured it out, it was a shadow brush in a parent of SGraphNode. 👌
InOnLiveLinkSourceCreated.ExecuteIfBound(MakeShared<FRtmsDollySource>(InEndpoint), InEndpoint.ToString());
New to slate. Can anyone please explain what this line does? InEndpoint is passed on the function.
why not optimal?
seems to me like this could/should be replaced by just passing through whatever InEndpoint is
this is doing multiple allocations even if the delegate is unbound or the consumer doesn't need both of these
hi, is there anyone that could explain to my how to change the icon in the level editor toolbar from just being a small arrow pointing down to something custom.
I have successfully created a plugin that adds a MultiBox button to the toolbar , but I'm struggling to figure out how to modify the icon, I've looked through the engine source code where the toolbar icons are created but cant actually understand on what is going on.
This is where i get my icon - i assume that this is where something gets wrong, and I'm unsure if this is a correct way to get an icon from the style class
This is where i create my button
This is what i want to achieve
This is my dropdown MultiBox button
anyone with slate and details panel experience could help a poor man? XD
I want to add a debugging feature to the FRuntimeCurveFloat graph. I basically need to draw a debugging "dot" given a time value. That way I can see graphically in runtime where I am in the curve given a time value. For the debugging option to work I would have to select one only instance from the world outliner using the curve... a time value would be fed from the selected instance to the details pannel. That's what I would like to do, but... I have no clue how XD
@tired palm
is your buttonstyle class registered and the resource name correct? If you don't require changing icons, you can also just remove the TAttribute and just put "FSlateIcon([stylename], &[functionname]) in there. TAttribute will poll the function each frame, so if that's not needed you can directly assign a FSlateIcon object
yes, but you have to use the first name as identifier when you want to use it somewhere
ok, so without ".PluginAction"
so FSlateIcon(FMBT_Test_ButtonStyle::GetStyleSetName(), "MBT_Test_Button.PluginAction");
nope, with
you used "ButtonIcon_40x" when creating the FSlateIcon
a style takes a resource on disk like a png (ButtonIcon_40x.png), initializes it to a SlateBrush with the name you've given it, and in code you'll refer to the brush as that name. It's so you only have to change a name once in the style class if you want to swap out the png files
can you please tell me where did you learn about this
i guess it took a lot of trial and error
whatever you want to do, it helps to look for sample code when learning a new part of the code base
yup it did
i've seen a few blogs that cover the theme, but they just do the bare minimum
but it's normal to forget stuff too, so I still have to regularly look things up. It's just that the methods become more efficient
you really helped me a lot with this one, and i have a feeling that you know that because of all the trial and error 😄
I actually forgot about it and looked it up in the plugin I'm working on lol
And if I didn't have a plugin I'd have looked for a sample of another combobutton in the level editor toolbar
and no problem
@tired palm https://www.twitch.tv/unrealengine the stream is about to start, it's about navigating large code bases. Should be very useful for you in the future
@split laurel Sorry i missed that, i was outside.
i will look at it as soon as possible, thank you.
Hey uh. Question. So in fortnite. They have customized HUD with images. Like I’m going to have. I’m watching a tutorial on HP bar and such, and they are using a progress bar. Is there a way to make the progress bar with using my image?
How do I take two inputs from user in 2 separate boxes and have one ok button which will initiate a task using both the inputs? Right now I'm taking the inputs in a single box separated by :.
Please help!
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: false [File:D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\SlateCore\Public\Brushes/SlateDynamicImageBrush.h] [Line: 119]
LogOutputDevice: Error: This hack usually results in a crash during loading screens in slate. Please change any code that arrives here to not use FSlateDynamicImageBrush. In the case of loading screens, you can use FDeferredCleanupSlateBrush. Which correctly accounts for both GC lifetime, and the lifetime of the object through the slate rendering pipeline
which may be several frames after you stop using it.
Trying to create an FSlateDynamicImageBrush in URichTextBlockDecorator::CreateDecorator()
trying to do this in CreateDecorator()
though it causes a crash, most likely from the simage
I am trying to load a texture there
not using an FRichImageRow datatable
so it says that the ResourceObject is valid but the ResourceHandle is not
not sure how to use ResourceHandle
so this somehow seems to work, though I keep getting random nullpointer crashes and also the image is simply having no content
check it out when I comment setting the margin out I get a null pointer crash, what the heck
defining a struct in the local scope and then assigning it to something of a much greater scope (this->Brush) is a recipe for disaster
@wide plaza well Brush is a local var too
whatever I stopped trying to solve this, workaround will be making 160 entries in a data table
@wide plaza well thanks for the help, I just moved the making of the brush into the widget constructor and there is no more nullptr crash though the image is still empty
alright making a member on the decorator works
Is there any example available for how to create slate widget components?
and use in UMG
slate widget components? if you want to expose slate to UMG look at any of the in-built widgets
@warm vault With your Brush issue, were you passing Brush (the pointer) into an SImage? If so, the SImage will be holding onto the pointer, and will be expecting the memory behind the pointer to stick around, which it wouldn't be if brush (the value) disappears at the end of the scope
@gritty frigate yeah I thought when I define it locally and pass a pointer it will be kept in memory
Nope, it won't do that
I would just make sure you keep it as a member variable, and don't worry about storing the pointer. If you need to pass it into an SImage, just pass in &brush
that is what i did and it works
Cool stuff
well the thing is though, in the Construct function of the Slatewidget the pointer was valid
not sure how and where it failed tbh
What function was your code above in?
And what do you mean by "valid"? As in it wasn't nullptr?
URichTextBlockDecorator::CreateDecorator()
yeah+
well I think I didnt do an is valid check but I printed IsValid of members
like resourcehandle and something else
If the underlying memory has been released (by the end of the scope for a local variable), the pointer won't be reset to nullptr
it will just point to potentially garbage
I think IsValid only works on UObject subclasses...
If you do:
int* myIntPtr = nullptr;
{
int myInt = 4;
myIntPtr = &myInt;
}
if( myIntPtr )
{
// This will get here, but the data will be invalid
}```
aha interesting
It's like an address to a building that's been destroyed
it still points there, but what's there is not what you were expecting
Just because you haven't updated your address book, doesn't mean that the person still lives there 🙂
but I mean it's like this with the function I called:
int myInt = 1;
int* myIntPtr = &myInt;
myFunction(myIntPtr);
But then myFunction() held onto the pointer? And when the function that you called it from finished, myInt was destroyed
yeah I think something like this
so SImage was initialized with a valid pointer but as the local var gets destroyed the pointer becomes bad and then causes a crash? not sure if SImage keeps referencing the pointer on tick or something
yeah - SImage will need to keep the pointer to hand
as the reason it takes a pointer is because it doesn't want to be copying data everywhjere
So if you have 5 SImages with the same image, they all want to be referring to the same data, not each having their own copies of it
I'm doing something very similar to you with a material in a SlateBrush
It's a dynamic material instance, so I'm changing it on the fly, so the SImage needs to be able to continually reference it
I have my brush as a non-pointer member on my SWidget
and then do:
SAssignNew( Image, SImage )
.Image( &ScreenMaterialImageBrush )
well thank you very much for the lesson 🙂
Any recommended beginner resources for learning Slate? I'm trying to create some reusable and resizable window widgets. for displaying content and info in
Of which this has been my only lead https://forums.unrealengine.com/development-discussion/content-creation/42476-umg-reusable-draggable-windows
Talk about Level Design, Static Meshes, Physics, and more.
I also looked into SWindow but it looks like that's not meant for runtime use at all
@cunning tusk There really isn't a lot of Slate intro-level docs. UMG is what Epic considers the game API
For what it's worth you can re-implement pretty much any behaviour in UMG too
Is anyone here really confortable using Slate and specificly Tabs, Dockable Windows,... I need to someone to help me code Dockable windows. By that I mean I'm trying to create simple windows that can be next to each other, resized and the ones next to the one resized adapt themselves to fit the screen size, having tabs that you can close and open using the window menu on the top bar, moving these windows around in the scene, detach it to be a sesparate window by itself, and be able to redock it again, ... please ping me
Hey! If I've a Slate text box, how do I access the contents? Until then I've been using static functions (onValueChanged and such) to synchronize it with some variable, but that doesn't seem like a good way to do this.
SNew(SHorizontalBox) +
SHorizontalBox::Slot()
.AutoWidth()
[
SNew(SEditableTextBox)
.MinDesiredWidth(100)
.IsPassword(true)
]```
Essentially this is just a password field with a button next to it, and I'd like to check the field value when that button is clicked.
Hey
So you want to assign it to a variable
TSharedPtr<SEditableTextBox> MyTextBox;
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.AutoWidth()
[
SAssignNew(MyTextBox, SEditableTextBox)
.MinDesiredWidth(100)
.IsPassword(true)
]```
Then you've got MyTextBox->GetText() and MyTextBox->SetText(SomeText);
The other thing to note is that the UE style for this kind of thing is putting the + at the start of the line creating the slot
so:
+SHorizontalBox::Slot()```
cool stuff
Hmm I'm struggling a bit, I've got
static TSharedPtr<SEditableTextBox> PasswordBox; in my headers and using SAssignNew(PasswordBox, SEditableTextBox) in the Slate "tree", and I'm making sure to declare "PasswordBox" in my cpp aswell TSharedPtr<SEditableTextBox> PasswordBox; since it's static, but I've got a linking error:
C:\Users\Cafe\Documents\Unreal Projects\SecmaVRTemplate 4.25\Plugins\SecmaVR\Binaries\Win64\UE4Editor-SecmaVR-0004.dll : fatal error LNK1120: 1 unresolved externals```
I've made sure to import the relevant headers for SEditableTextBox too, so I'm not sure what I'm missing 🤔
Why are you defining it as a static variable?
Because the methods using it are static aswell
I'm not really carrying an instance of the EdModeToolKit (I'm pretty sure that's how the template was setup and I just kept the trend)
Right - I've not used editor modes before...
If it's static, then it sounds like you've declared the static variable, but not defined it
In your .cpp you'll need to do:
TSharedPtr<SEditableTextBox> FSecmaVREdModeToolkit::PasswordBox;```
Oh yes, I missed that you'd already put something in your .cpp
@nocturne topaz this is something I've been wanting to do as well, unfortunately no leads myself yet surprisingly.
@cunning tusk 😦
the editor has a window and tab framework
you could investigate how it's made
maybe it's even in a runtime module then you can just use it
@main hedge I'm not confortable enough with c++ to be able to see the code and uderstand it
then you're not going to be making dockable windows with slate
it will be exclusively in c++ after all
yeah I know
But I'm trying to find someone who's conforatbale with slate to help me achieve that
I’m alright with C++ but not Slate, it’s surprisingly difficult to find good resources about using it.
yeah that's really surprising
Unreal's inexcusably bad documentation doesn't help either but eh
Guess I'll try a simpler system with UMG
I want to do it with UMG but apprently there's nothing for dockable/resizeable window, and alot of people told me that I have to use Slate because there's already functions that do that
I think I came across your post on reddit from a month ago
yeah I asked the same thing on reddit but no help
That approach sounds doable though
yeah but for the we need someone who's confortable at doing that so he could guide us step by step
your best bet for that would be to pay someone like a consultant
Other than that, try to start learning stuff just head-on, like maybe follow a structured course YouTube or Udemy (when a sale is happening, never pay full price on Udemy) to actually learn the engine, and if you want to actually learn C++ then look up Cherno on YouTube for a full free series on just about almost everything C++.
What's the performance difference between Slate and UMG?
only overhead of blueprints usage
What's better choice to go with? As my whole project is C++ based, is it better to go with Slate or UMG.
I'm trying to go with options that costs me as lower performance cost as possible.
Slate, if you close with c++ the choice is Slate
but you should understand, what Slate have no visual editor
if you have designers in your team, make Slate widgets, cover them by UMG widgets, and then give to designers
I'm going through the cycle of try a layout tweak that I think might work -> compile -> run -> realise it's not quite right -> repeat
UMG is always the better choice frankly
There's zero reason to use Slate for dev of the actual game
Unless there's something not exposed to UMG
And the performance cost difference is frankly negligible, next to the cost of the game itself
there are only really two common uses for slate
- you're making fancy custom editor stuff
- you're making a new widget to expose to UMG
Slate is very much not the default choice
UMG is perfectly fine for performance
Only use Slate if you intend to re-create every single widget to have some really specific behavior
Or if your game is going to have super complex menus with a lot of custom stuff
Even then you can use Slate only for the custom stuff and keep UMG for everything else
Does anyone know how SMeshWidgets work?
bcoz lot of our UMG stuff runs on tick, which kind of gets really expansive, so was think to get something related to SMeshWidgets and switch to there
They're not easy to use
The long and short of it is you create a static mesh that determines the shape of the widget, apply special materials to it, then slate allows you to pass a few material parameters packed into remaining UV channels
So they're pretty limited on what you can do
It's more designed for drawing lots of very simple things to UI, not for replacing widgets
@zenith lotus regarding performance and UMG vs Slate it really depends on your use case. We have a large game using UMG and CPP and haven't hit too many perf issues. In the cases where we did hit them, they were solved by simplifying widgets, using pools. It's definitely not necessary to write your game only in Slate and avoid UMG just because you're using C++. I disagree with @pastel phoenix in this respect.
is there a way to bend a image?
My ultimate target would be to create a spline which can repeatingly display a small image (like a curved road from above)
@rain heron you can make a material out of an image and place it on a mesh, bcoz with spline you can bend a mesh
u can use that, in slate, but it'll get expansive
u will have to use SceneCapture
or you can try playing with translation
damn... ok expensive stuff is not so good...
or u can go with 3D widget
that's what I'd do to achive what u r trying to do
Create Slate, and then implement it in WidgetComponent into a blueprint
I dont know if you fully understand me xD
I try to make a custom slate primitive which will badically show something like a "road map" which is dynamicaly generated... so i dont want to use any 3D stuff there... just slate it self to draw just the UI widget
@zenith lotus
Ahhh I see.
is there a way to bend a image?
My ultimate target would be to create a spline which can repeatingly display a small image (like a curved road from above)
@rain heron
So for your question about bending image i don't think it's possible
you can make it feel like it's bent by playing around with translations.
or make a material with bending effect
there are only these 2 methods that I know
probably SViewport is for you
you can take dynamic texture and draw on it wherever you want
thanks for the pointers i will check if it might help ^^
i tried drawing web pages and mpeg streams
can i get some guidance here? im getting random crashes when i use the editor after doing some simple gameplay https://pastebin.pl/view/d1fae2f1
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
the only class that is using slate in my code is this https://pastebin.pl/view/c934fcc4
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
and the header is https://pastebin.pl/view/fe50a57f , it's just a button that has overrided the hover/focus events
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
It’s probably nothing to do with Slate, and your issue is uninitialised memory somewhere in your code. Do you have a pointer somewhere that you aren’t initialising to nullptr or some valid value?
im sure i have initialized all variables
@solar cedar Use the debugger to find out what happened
i am launching with VS, most of the time is a huge stack of slate calls, and now i was getting other stuff but like...80% was slate
Looking at the code I'm not sure why you'd create a button that way
It's a button class that inherits the button class and creates a new button internally ?
@quaint zealot having seen a crash like this before, the debugger was of no help
tbh, i just copied some sample code i found, but it's not even that, the editor crashes if i go straight to the gameplay and stop it it randomly crashes
I was getting a seemingly slate-related crash, and I had no custom Slate code in my project
and with gameplay i mean a template i have migrated from unreal market (Action rpg)
and even before migrating it i was starting to get random crashes
thing is that, with my previous proyect that had the same classes, it never crashed like this
Well, does it crash if you remove that code ?
haven't tried, but im not even calling anything with that code right now
it's never constructed
So it's safe to say it's entirely unrelated
i have tried that code on my other proyect and had no issues whatsoever
If you're not using that code in the first place it's not causing any crash
The scene outliner in the level editor is what crashes, btw
And it doesn't exactly seem relate to your game code
yeah, im totally lost
Is this a binary launcher build of the engine ?
Any particular plugins used ?
only the ones that the ActionRPG requires, SlateRemote and GameplayAbilities
i'll just assume that it's the demo that is not properly migrated
getting mysterious crashes in slate is usually a sign that you got memory corruption elsewhere in your code
^^
@solar cedar could be this
thanks, that's a nice catch, im still doubting it's anything at all in that code because it crashes even without invocking that widget
It's not that code.
but i will definitely add a nullcheck
Can Slate Widgets be used directly in UMG?
You'll need to create a UWidget wrapper for it
That's essentially what all UMG widgets are
@craggy holly Im using a lot of Slate but never used UWidgets. Is it more or less straight forward to do that or is there a lot of work going into making a widget UMG-compatible?
Not much to it. UOverlay is probably the simplest example, but ultimately the UWidget is then managing the lifetime and layout of the underlying slate widget.
thanks, great to hear :)
Guys how did you learn SLate ?
we watched examples in the UE$ code
Years of reverse engineering
Guys, I just released a free and opensource plugin called Async Loading Screen on Github. The plugin uses Slate framework, if you are learning Slate, you may want to take a look at it's source code:
https://github.com/truong-bui/AsyncLoadingScreen
You can ask me question on forums
https://forums.unrealengine.com/community/released-projects/1809943-async-loading-screen
sorry, my bad
https://gyazo.com/e0fb53c375de2ce1f970a137c8f81781
This widget of mine keeps on shaking when used from a graph pin. (the image in the middle is for testing purposes, to determine if the content was causing it, it's not)
I've been using the very same widget with the same configuration in details panels before and nothing ever shaked. Widget reflector also tells me it's the same size and position every time I tried to read the data
anybody got a clue what this could be?
wow ok after hours of debugging this I found out it only happens on zoom level -1 which I was on the entire time lmao
still no clue where or why this happens :d
ooook for anyone who encounters a similar issue in the future, I could track it down to the SMenuContentWrapper's actual size is off by 1 pixel from the desired size in each direction. On all other zoom levels the size would be exactly the same or the difference would be < 1 pixel (which most likely doesn't affect rendering at all, so no flickering).
I couldn't find a 'good' way to fix it but I just did what Epic is doing and that is wrap their asset picker in a fixed size box. And that only works with specific numbers, like 300x300. 300x350 does not work, same issue as above. It just has 1 px too much in its actual size.
OK some more updates:
Managed to track it down to SMenuAnchor (which is the parent of SComboButton) Tick. The window the menu resides in is continuously resized and repositioned on tick to find a good spot for the menu. And due to OS reasons they are 'speculating' some window values, which makes the thing flicker in some cases.
I fixed this by inheriting from SComboButton and overriding Tick. I mostly used the original Tick code, but changed the Window->Reshape(NewPosition, NewSize) to Window->MoveWindowTo(NewPosition)
Sorry for the spam but hope it helps someone lol
how can is set the keyboard focus drectly after creation of the widget?
(it is a editabletextbox)
hello guys - I have this code:
ChildSlot
[
SNew(SOverlay)
+ SOverlay::Slot().HAlign(HAlign_Fill).VAlign(VAlign_Fill)
[
SNew(SImage).ColorAndOpacity(FLinearColor(0.5f, 0.5f, 0.5f, 1.0f))
]
];
and I don't understand why this has transparency. This is how it looks:
In all tutorials similar code produces opaque background
how can is set the keyboard focus drectly after creation of the widget?
(it is a editabletextbox)
@rain heron I don’t have the exact code to hand (I’m on my phone) but it’s something likeFSlateApplication::Get().SetKeyboardFocus()
jeah i tried that... didnt work
Focus is incredibly hard to manage with Slate
@halcyon jetty well there's probably more to it than that, it will also depend on the opacity of the parent widget(s) too
@wide plaza I changed to https://docs.unrealengine.com/en-US/API/Runtime/Slate/Widgets/Colors/SColorBlock/index.html and it works as expected
I am trying to hilight the current player but it is displayed in a light grey:
SAssignNew(PlayerListWidget, SListView<TSharedPtr<FPlayerRow>>)
:
PlayerListWidget->SetItemSelection(PlayerRows[Idx], true, ESelectInfo::Type::OnMouseClick);
Any help is appreciated.
PlayerListWidget->SetItemHighlighted(PlayerRows[Idx], true);
SetItemHighlighted gives me the light grey color too. I am trying to get the yellow background color that appears when pressing with the mouse.
Any suggestions on how to plot a graph? Wondering if I should just draw a bunch of lines?
Probably best way would be to draw lines in OnPaint on a custom widget
What's the best way to draw text in slate?
It you take a look at STextBlock::OnPaint that's a good reference
You want to paint it directly? It's also easy enough to add a child widget that's an STextBlock
Interesting
FSlateDrawElement::MakeText() then?
Yeah I want to paint it directly I guess
Not super familiar with how to add it a as a child widget
Yup - that sounds good
Although child widget might be better
If you're doing your own painting, I don't think you can do child widgets too
I'm not certain that you can combine them both
I've got a widget where I wrote one that was a subclass of SLeafWidget and I did my own painting, and then another was a subclass of SCompoundWidget and used the painted one as a child
Actually, I lie - take a look at SBorder for an example of how to paint a background image and then have child widgets too
yes
Are you wanting to do a graph with labels?
I'd probably do it all in OnPaint for that, as if you're doing child widgets, it can be more painful to position them
Alternatively, you can subclass SCompoundWidget, have OnPaint() draw your graph, and then have an SConstraintCanvas in ChildSlot to store your text blocks and be able to shift them around
Are you wanting to do a graph with labels?
Yup exactly what I'm going for
Got the graph part already up and running just fine
I think you'll probably find it easier to use FSlateDrawElement::MakeText() in the right positions on your graph
I find SConstraintCanvas a pain when you want to position things accurately
This was my combined widget:
The colour wheel and marker were done as an SLeafWidget, using OnPaint() to paint the wheel and the marker on it
Everything else was then put together in a separate SCompoundWidget subclass
FSlateDrawElement::MakeText() for this function, where is the actual position of the text being set?
Well, I guess ToPaintGeometry() can take a layout transform
Sorry - on a client call - can I get back to you on this in an hour?
Yeah no worries, thanks for all the help 🙂
Let me dig through my code and remind myself
Oh, it’s the first two values of the Offset
Depending on your alignment, those 4 values have different names (PosX, PosY, SizeX, SizeY), but they are always the 4 values in the Offset
@hexed plank ^
cool
@gritty frigate that colour picker is super cool! Is there a reason you did it in slate rather than UMG/UUserWidger BPs?
The plugin I'm building is intended to be licensed out, and I'd like to protect as much as possible, so C++ is preferable over BP
Also, the back end of all of these UIs are C++, so I preferred having a direct connection over having C++ interfaces to BP UIs
The tool I'm building is modular, so all of this can be extended with either C++ or BP
I know it's generally considered a bad idea to not use UMG unless you have to use Slate, but I've quite enjoyed doing it this way
It means that simple modules for this tool are generally 5 files (a state.h, controller.h, controller.cpp, widget.h and widget.cpp)
Damn I wish I had more experience doing it that way. Although it does sound slower maybe?
Slower to implement I mean
Slate isn't that bad at all, all things considered, UMG is just much more suited to game menus and content interaction.
I've got pretty comfortable with Slate
@quaint zealot so making an entire city builder UI in it might not be a good idea?
yeah, game UI stuff is definitely good for UMG
A game UI should 100% consider and try UMG first and foremost
I get the idea I could get faster with it, set up reusable styles, spacing etc. But the idea of having to type eeeeverything out and wait for a complie to see it is kinda scary.
Although I guess there's hot reload
The problem with Slate isn't really the slower iteration time, it's that customizing Slate widgets with content is quite painful and requires a really large amount of work beforehand
Adding an animated material to a Slate button is a lot harder than it has to be
I've not tried that one yet!
When you say animated, do you mean a MaterialInstanceDynamic?
Yeah
I've not found that so difficult
Well you do need to keep the material instance somewhere UObject related to avoid GC
And the entire Slate style thing isn't too easy to set up
True
I've got a big FMySlateStyle class set up
Have you ever tried subclassing the slate widget from FGCObject?
The only reason I'm doing Slate stuff is that I have 6 years of Slate code with a lot of boilerplate
So I don't have to solve these issues anymore
Starting out in Slate for game UI stuff - not a plugin, an editor tool etc - is just not a great idea
Take a look at SObjectWidget for how to do Slate and UObject GC together
Yeah I have that running
@gritty frigate Do you create a new MaterialInstanceDynamic for each button that uses the animated material? Or you just have a centralized instance in the style?
ah
If I were doing multiple buttons that were animated the same, then I'd have 1 MID
I ended up doing centralized styling by subclassing most common UMG widgets and setting up their style using a UPROPERTY() TSubclassOf<T> that had the style info in it
right
I've got a lot of custom icons and other things, so they're all .png files that are referenced directly into SlateBrushs
Whenever I make a tsharedptr to a member of a struct in my widget, I get an exception when the widget is destroyed, or when the member is emptied (its a tarray). This happens even if I immediately call reset on the tsharedptr after I make it. Does anyone know what I am missing?
I have made a simple button class in slate. Now how do i expose it to UMG
to use it there
You'll need to create your own UMyButton class
Why are you making your own button in Slate, though?
There is very little reason to make a new button, as the current one is very customiseable
its UI based application. And the client feel that creating C++ button will optimise performance
I'm not sure if thats true
but thats what he wants
There's already a C++ button in SButton
I'm new to slate actually
There's already a C++ button in SButton
@gritty frigate Thats my parent class
okay, so you're adding new functionality to it?
Yes
If you want a UMG version of yours, you can't subclass UButton, as it has an internal pointer to TSharedPtr<SButton>
I had to do this on a different class, and had to take a complete copy of the UMG class
I hope i'm going the right way😆
It didn't feel nice to do it this way
Have you done the SButton subclass already?
and it has some BP calable function for scaling and changing the color
no not yet. I'm just figuring out a way for now
You know that standard buttons can scale and set the color already?
It really sounds to me like you'd be better off convincing your clients that doing it in UMG is fine
thats not a option
😦
Okay, so once you've got your SMyButton, I would grab UButton, and take a copy of it and rename to UMyButton, and adjust accordingly
I've not figured out the best way to subclass UButton to UMyButton for this kind of thing
Hi everyone, I'm trying to create an SObjectPropertyBox but I'm getting a construct error. I've implemented this class on other files and I've got 0 problems. Any idea why is this happening?
This is the error
Are you linking against PropertyEditor?
I've included the necessary file. Beside from that am I missing something to link it properly?
I meant, have you set it as a dependency in your Build.cs?
That's what determines what modules are linked against
Any time you get a linker error saying something like "can't find symbol", it's either you're not linking against the right module, the class you're using isn't exported, or you've forgotten to define one of your functions
Oh, taking another look at SObjectPropertyEntryBox, it looks like your issue is the second one
it's not got PROPERTYEDITOR_API in the class definition
So you're out of luck, I'm afraid
Without that, you can't use it outside the module it's declared in
Unless you're rebuilding the entire engine?
We are building a plugin. And the idea is to create this SObjectPropertyEntryBox to filter some of our own data.
unfortunately, then, you're out of luck
Do any of the functions in the PropertyCustomizationHelpers namespace help you out?
Let me find the example where they've used it.
okay, this is odd. It looks like Construct() is exported, even though the whole class isn't
Did you check your Build.cs?
I may have been wrong about the reason earlier
They use it here. And it's an "outside" class. So I'm sure its linked because this works fins on the project.
Its implementes using AddCustomRow but i guess that is a Slate at the end so..
So the implementation should not be the problem imo.
But I'm not sure at all.
Did you see my messages about being wrong about the exports?
Because Construct is exported individually, which is what your linker error was complaining about
check your Build.cs for dependencies
UE4Build.cs right?
Your plugin's Build.cs
You need to add PropertyEditor to either of the top 2 sections
Ok, it compiled lol. Thanks 😅 😂
But I don't understand why the other code works.
Tbh
Is the other code in another module?
Yeah. now I've found it. Now I understand how all this works. Thanks @gritty frigate 😁
awesome 🙂
Im trying to get some custom context menu actions for my custom pin like shown in this picture https://gyazo.com/d22308773c09a43db15771ea89214631
But by default the bubbling doesn't reach my custom widget's "OnMouseButtonUp" function, it gets caught by the default pin actions. I'm not sure what causes it, since SGraphPinString looks pretty standard
I suspect it might have something to do with focus, but no proper clue so far
Code that walks the SWidget tree upward, checking if the child is always in the parent's "Children" container.
Can anyone tell me if this code is crazy or making wrong assumptions about Slate? The goal is to suppress some widget behavior (responding to input events) when the widget is not visible because it's a descendent of an inactive child of a UWidgetSwitcher
I call the function from an input event handler in the widget that might be inactive because of where it lies in the widget tree
Can you all perhaps also suggest other properties I should check while traversing up the parent chain? I'm assuming I should look at the visibility / enabled properties as well, for my use-case
Has anyone tried 4K support with Slate/UMG?
For example if I have a 32x32px texture, and I create a Brush that's 16x16, it seems that even if it's rendered larger on-screen (e.g. 2x size), it's still only rendered using the 16x16 data...
I know it's common for web and smartphone dev to have 2 or even 3 sets of assets, for 1x, 2x, 4x DPI
Yeah it will show it at 16x16 but its gonna load the 32x32 texture so your prob gonna need to setup multiple sets and switching per quality type that should be setup per device
Hi there. How to create a binding in a button (just like in BP) but in C++?
@gritty frigate
please don't tag people directly - if someone is around (I am right now) they'll see and get back to you
What kind of binding do you want? Directly to a function, a lambda?
Sorry about that.
I want to update the color of the button from a variable from a game instance class . What could be the best solution to that
Ah - I see
bindings are generally quite high-cost, as they are continuously called
Better to store a variable of your button and set it directly
Ah alright.
How do i add a Visual to the button? Because i wish to add text as well and button supports just one child in BP? and i believe should be same in CPP
If you want to add multiple elements, you'll need to add a single widget that itself takes multiple children
SOverlay, for example
can i add a SOverlay in a class which is the child of UButton
You can add an SOverlay as a child widget
@summer jolt are you talking about UPROPERTY(meta=(BindWidget))?
That lets you access BP defined widgets from C++
@summer jolt if you're using Blueprints, you're using UMG so it would be better to ask in that channel
@mild oracle I think he wants to do the equivalent in C++ as binding a function to a value.
From our conversation the other day he isn’t allowed to do this button in UMG - it has to be Slate
Anyone want to take a stab at my question from yesterday evening? Just a short scroll upward
@gritty frigate Ohh OK different kind of binding 🙂
my question is still open as well:
Text widgets seem to properly receive events such a OnMouseButtonDown in a blueprint graph pin, but my custom widget does not. The buttons inside the custom widget however have actions assigned and do work. I think the custom widget just doesn't get considered to be pressed in the first place, and apparently I have to do more than just overwrite the OnMouseButton functions.
For reference I have looked at SEditableText, which works as well, but I cant anything in regards to making it properly eligible for receiving mouse events
OK bear with me ... as I paste pictures with descriptions:
The Inventory Widget is a SizeBox with a set size. I tried putting it into a canvas, but it doesn't make a difference
Like I wrapped the size box in a canvas, and set it to size to content.
Is there some weird thing that adding a widget as a child of a panel, that would remove the sizing constraints of the sizebox somehow?
ok
Are you doing it in Slate?
uh,
oh damn ya... ;s
🙂
clearing it out ;s
okay made some progress... seems like the "OnMouseButtonXXX" functions are being blocked by SCompoundWidgets by default somehow. Just implemented a basic widget inheriting from SWidget and the functions are called properly
Hey, I'm trying to create a class filtering widget that functions similarly to the gameplay abilities tag widget. I want to be able to place the widget on a UI in UMG as well as have it be used in the details view for instances of a FClassFilter for example, but I'm confused on how I would supply the variable to write/read the data from in the case of placing it in the UMG UI.
For the UMG UI, would I wrap the Slate widget in a UMG widget and have the property on the UMG widget? Then I would just get a handle to the property and use a specific factory function to construct the Slate widget without the Property name slot? Similarly, I assume for the details customisation I would have a different factory function that handles creating the property name slot.
How do i add child widget in UButton class ? This my first time creating UI in C++
You don't want to be doing that kind of thing in the UButton - the UMG classes should just be wrappers around the Slate classes
If you want to add child widgets, your SButton is where you'll want to do it
What i want is that i extend the button class(Which is visible and ready to drag and drop in BP) , Now my button should have 2 images and a text in it
Have you already done a SButton subclass?
No. I'm still playing around the code. I have made a button class inherited from UButton class
That's not going to work
The U* UMG widgets are all just UObject wrappers around Slate widgets
It's inadvisable to try to do anything other than wrap the Slate widgets in them
Hence my recommendation the other day that you subclass SButton and then take a copy of UButton to link to your SButton subclass
(well, after my recommendation to do all of this in UMG...)
If i create a SButton class. then will I be able to expose it BP?
I'm sorry . I'm still learning UE CPP. What do you mean take copy of Ubutton and link to SButton?
If you look at UButton, you'll notice that most of it just forwards things to a TSharedPtr<SButton> MyButton
First you subclass SButton to make SCustomButton
You set up everything you want to set up in there
And then you make new files CustomButton.cpp and CustomButton.h. You then copy the contents of Button.cpp and Button.h into those files, and change references from UButton to UCustomButton
Once you've done that, change TSharedPtr<SButton> MyButton to TSharedPtr<SCustomButton> MyButton
At that point, it should work, but with the UMG CustomButton only having the same functionality as the standard button (although it will look like your SCustomButton
And then you can go into UCustomButton and add extra functions and properties to reveal the extra functionality that you added
Ah. Got it.
Btw just a random question. If you work professionally. How much do you think something like this should cost?
of course it must be a easy job for you. But whats the normal rate
I have no idea. It depends on the extra functionality that you're adding.
Alright. Thanks for the help
👍
Interesting!
Intriguing
It'll be nice to have some more insghts [sic] into Slate
Hi everyone. I wish to make my widgets entirely using c++ using the UUserwidget class. I wish to design as well as develop all the logics in C++ . What is the best approach?
How to add child to SNew(SOverlay)
dynamically
you wouldn't really use UUserWidget for a purely C++ widget, probably use UWidget to expose it to the UMG editor
or if you're not using UMG at all, just use slate directly
How to design using uwidget? Any suggestions or tutorials?
Look up UMG
How to add child to
SNew(SOverlay)
dynamically
@zenith lotus You'll need to assign it to a variable:
// Locally or as a member variable
TSharedPtr<SOverlay> MyOverlay;
// Where you're currently doing SNew(SOverlay)
SAssignNew(MyOverlay, SOverlay)
// Where you want to add new children
MyOverlay->AddSlot()
[
// Slot contents here
];
How to design using uwidget? Any suggestions or tutorials?
@summer jolt I'm not sure how many ways I can say this... You don't want to do any kind of design inside a UWidget. You either want to do it all in UMG, or in an SWidget
haha. Got it now. I promise. Thanks
Hi guys, I'm using an SObjectPropertyEntryBox to show a data class I've created. Now it's showing all of them, but i would like to filter them is possible, only those ones that have a certain value for example. Is this possible? Thanks!
I've found inside the SObjectPropertyEntryBox a Slate argument that could be the solution but it's not working for me:
Hi everyone! I am building some UMG UI. I need to style a ListView scrollbar, but I think it exceeds UMG's possibilities.
Can I use Slate for it? And in that case, will the resulting widget will be very different from the UListWidget from UMG?
In general, the Slate widgets and UMG widgets can absolutely use the same styling
And, in general, do
it's just a warning telling you that some property is zero and is used to divide some other value with. You need to down the stack and try to determine which value it is.
Can anyone recommend a good collections of examples for Slate? I am working on integrating a small toolset into UE - and so far have been piecing it together from web/engine source.
@south cobalt I got into it by just looking at the Construct functions of existing slate widgets.
detect a widget in the editor you are interested in. Use the WidgetInspector tool to find the type of the widget and then see the Contructor of the widget to see how it was setup. That gives you a visual to code comparison
Yeah, i am doing that... creating a Details/SSplitter like list in a custom tab, just now learned its best done with SExpandableArea - would be good to have a guide on something like that.
When I started with it there was basically nothing out there as learning reasource. Still struggling with it, as I only use it every now and then. There was also a livestream for expanding the editor
Engine Programmer Michael Noland walks us through a project designed to show how to add custom functionality to the editor.
That is a great stream
.BorderImage(FEditorStyle::GetBrush("ToolBar.Background")) is causing linker error, i've exhaustively included everything its referring to as well as "Slate", "SlateCore" in both plugin and project build files... what else could be causing it?
and the answer is: you have to add "EditorStyle", to the build also
For SListView I am able to select and hilight the row I want using the below:
PlayerListWidget->SetItemSelection(PlayerRows[Idx], true, ESelectInfo::Type::OnMouseClick);
FSlateApplication::Get().SetUserFocus(0, PlayerListWidget, EFocusCause::SetDirectly);
But the scroll into view isn't working:
PlayerListWidget->RequestScrollIntoView(PlayerRows[Idx]);
Is my setup correct?
Should this be working?
Any help is appreciated.
I've got a Slate widget constructor:
ChildSlot[
SNew(SButton)
.OnHovered(Delegate1)
]
I want to bind another function to OnHovered, so I should probably go like:
FSimpleDelegate Delegate1 = FSimpleDelegate::Create...
But I can't get either CreateUObject, CreateLambda or CreateSP to work. Is it because it's done in a widget class? (public SCompoundWidget)
I searched this server for working examples, but none seem to compile for me. :(
You can create your own lambda inline using:
SNew( SButton )
.OnHovered_Lambda( [this]
{
// whatever
});
it throws compiler error C4573, "the usage of (...) requires capture of "this", which is not allowed by the compiler"
Yeah, OnHovered requires a SimpleDelegate
This compiled fine for me:
SAssignNew( ButtonWidget, SButton )
.OnHovered_Lambda( [this]
{
})
let me try
You don't have a member variable called this, do you?
no, no
ButtonWidget is supposed to be an existing pointer?
because the above just throws undeclared identifier
Oh, yeah - replace the SAssignNew with your SNew
shouldn't make a difference to you
This compiles fine:
ChildSlot
[SNew(SButton) .ButtonColorAndOpacity(FLinearColor(0,0,0,0)) .ContentPadding(FMargin(0,0, 0, 0)) .VAlign(VAlign_Center) .OnHovered_Lambda([this]
{
})
This doesn't:
ChildSlot
[SNew(SButton) .ButtonColorAndOpacity(FLinearColor(0,0,0,0)) .ContentPadding(FMargin(0,0, 0, 0)) .VAlign(VAlign_Center) .OnHovered_Lambda([this]
{
ShowTooltip();
})
oh ok, mismatched declarations
now, can I pass an argument to the function with this method?
or wait, maybe it won't be necessary
You can capture additional variables
The lambda arguments are defined by the delegate type
Alright, everything works now, thank you so much @gritty frigate :)
cool stuff 🙂
@gritty frigate is there a way to add OnHovered functionality to STextBlock?
Not sure off the top of my head, but you could put it inside an SBorder which would do it
What a clever trick, thank you again!
You are welcome
I create a custom Widget.
I cannot build with #include "SMyWidget.h"
But can build with class SMyWidget;
Anyone know why?
Can't say without more context and the actual build log
what is the best way to wrap the gameviewport into an other widget by me (like a grid widget)?
I try to use something like this:
auto GameViewport = FSlateApplication::Get().GetGameViewport();
auto GameViewportContainer = StaticCastSharedPtr<SHorizontalBox>(GameViewport->GetParentWidget());
GameViewportContainer->RemoveSlot(GameViewport.ToSharedRef());
CustomWidget = SNew(SGridPanel)+SGridPanel::Slot(0,0)[GameViewport];
GameViewportContainer->AddSlot()[CustomWidget];
But the game crashes with something like
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000178
SWidget::ConditionallyDetatchParentWidget() [engine\source\runtime\slatecore\private\widgets\swidget.cpp:576]
TSlotBase<SOverlay::FOverlaySlot>::operator[]() [engine\source\runtime\slatecore\public\slotbase.h:91]
SVerticalBox::FSlot::operator[]() [engine\source\runtime\slatecore\public\widgets\sboxpanel.h:181]
SWindow::SetContent() [engine\source\runtime\slatecore\private\widgets\swindow.cpp:1171]
UGameEngine::SwitchGameWindowToUseGameViewport() [engine\source\runtime\engine\private\gameengine.cpp:611]
I tried that, and never managed to get it working
I actually changed my approach slightly
I ended up having that widget just be transparent, and then had a PostProcessMaterial that shifted the viewport image to fit inside the area that the widget covered
I passed a FramingMaterial to my widget, and then had to use Tick():
if( FramingMaterial && PreviousGeometry != AllottedGeometry )
{
PreviousGeometry = AllottedGeometry;
const FGeometry& ApplicationGeometry = GetApplicationWindow()->GetCachedGeometry();
const FVector2D AbsoluteViewportTopLeft = AllottedGeometry.LocalToAbsolute( FVector2D::ZeroVector );
const FVector2D AbsoluteViewportBottomRight = AllottedGeometry.LocalToAbsolute( AllottedGeometry.GetLocalSize() );
const FVector2D ApplicationViewportTopLeft = ApplicationGeometry.AbsoluteToLocal( AbsoluteViewportTopLeft );
const FVector2D ApplicationViewportBottomRight = ApplicationGeometry.AbsoluteToLocal( AbsoluteViewportBottomRight );
FVector2D TopLeft = ApplicationViewportTopLeft / ApplicationGeometry.GetLocalSize();
FVector2D BottomRight = ApplicationViewportBottomRight / ApplicationGeometry.GetLocalSize();
const FVector2D size = BottomRight - TopLeft;
if( size.X > size.Y )
{
ViewportClipping.X = 1.f;
ViewportClipping.Y = size.Y / size.X;
const float halfDiff = ( size.X - size.Y ) * .5f;
TopLeft.Y -= halfDiff;
BottomRight.Y += halfDiff;
}
else if( size.Y > size.X )
{
ViewportClipping.X = size.X / size.Y;
ViewportClipping.Y = 1.f;
const float halfDiff = ( size.Y - size.X ) * .5f;
TopLeft.X -= halfDiff;
BottomRight.X += halfDiff;
}
FramingMaterial->SetVectorParameterValue( FramingPositionParameterName, FLinearColor( TopLeft.X, TopLeft.Y, BottomRight.X, BottomRight.Y ) );
}```
thx... i will check if archive it differently... will let you know if i come up with something ^^
Please do let me know if you do manage it! I tried what you're trying, and I'd love to change mine to that
I wanted to ensure that it worked in PIE as well as -game (I'm not worried about full packaged game for my use)
what I'm kinda confused though is that the structure in my case is like
SWindow->SOverlay->SHorizontalBox->SViewport
but the UGameEngine::SwitchGameWindowToUseGameViewport
checks for SWindow->SViewport and would then recreate the viewport if it is not content of SWindow 🤔
well thats just a first look though
UUserWidget:
CurrentTooltip->ForceLayoutPrepass();
FGeometry geometry = CurrentTooltip->GetCachedGeometry();
FVector2D localSize = geometry.GetLocalSize();
FVector2D screenPosition = geometry.LocalToAbsolute(FVector2D(0, 0)); //TopLeft
FVector2D screenSize = geometry.LocalToAbsolute(localSize) - screenPosition; // BotRight-TopLeft = real size
Is there a reason why all of them would always be equal to 0,0?
Is that immediately after the widget has been created?
Has the game had a chance to tick at all since it was created?
yes!
then that's odd that it's all 0
and it displays fine
the size (local) line goes from screenSize.X and screenSize.Y
Im looking into making a parallax panel in slate, but all of my widgets so far have been compoundwidgets where I'd just string together different existing widgets. So I don't know a lot about arranging children and custom painting functions.
When looking into sample widgets like SOverlay, OnPaint just calls Paint on each individual widget, it doesn't seem like I can tweak the way they are rendered much. Can someone give some starting points at which functions or classes to look at?
If you take a look at SSlider, that's good some good examples
that paints a handful of elements
hmm that's a good suggestion, but I can't seem to wrap my head around the painting system. It seems like the SSlider::OnPaint just draws a box and passes on the draw elements. It's not modifiying any child objects there. I wonder if slate even supports changing the way children are rendered in more ways than just changing basic attributes like transform, visibility etc.
from the slate docs
"We begin at the top level windows and recur down the hierarchy, appending the draw elements of every widget to the draw list. Widgets tend to do two things during paint: they output actual draw elements or figure out where a child widget should exist and ask the child widget to paint itself."
This does't read to me like slate is designed with use cases like mine in mind 🤔 outputting draw elements means adding elements to the stack of widgets to draw, asking the child to paint itself means no modification
You could probably do it without worrying about OnPaint by just modifying the render transforms of the elements
I guess so. I take it I'd do that in the ArrangeChildren function?
I’m not certain, I’m afraid
guess I will try out some things :) thank you regardless
there's also the FSlateDrawElement::MakePostProcessPass function but it seems like you can't do much with it, or I'm misunderstanding its use
How often are you wanting to change the render transforms?
You could always do it in Tick()
I'd probably need to do it in tick for it to react live to mouse movement. And true, you do get the geometry as a parameter on tick.. 🤔 I'm gonna try that out soon, right now I'm reading up on ue4 graphics programming. I discovered the "MakeCustom" function (compared to MakeBox etc.) which lets you call graphics API calls directly
Cool. I’ve only ever used OnPaint to draw slate brushes, so haven’t investigated the other options
@gritty frigate didn't follow through because using a shader would have invalidated the hitting tests, so I just did it with OnMouseMove. Although I'd still like to know more about that custom slate rendering 👀
Current result https://gyazo.com/f2cb112a55e64b31bd339b8bcdc0af6f
I'm just using the parallax panel for testing purposes here, I'm not planning on putting it into the articy importer
Cool. If it’s definitely always linked to the mouse, then OnMouseMove is a smart idea, as it won’t be called more often than OnPaint or Tick
downside is of course it wont move if the mouse is outside the widget, but I think it's fine
I could also give it a TAttribute<bool> to determine whether it should move or not and put that check on Tick, in most cases it wouldn't move then
@gritty frigate so... i got something to work...
basically... i add my stuff as a grid panel to the overlay of the window...
auto GameViewport = FSlateApplication::Get().GetGameViewport();
auto GameViewportContainer = StaticCastSharedPtr<SHorizontalBox>(GameViewport->GetParentWidget());
auto GameOverlay = StaticCastSharedPtr<SOverlay>(GameViewportContainer->GetParentWidget());
Grid = SNew(SGrid)
.FillColumn(1, 1)
.FillRow(1, 1)
+SGridPanel::Slot(1,1)[
SAssignNew(GameSpacer, SSpacer).Size(FVector2D(200, 200))
];
GameOverlay->AddSlot()[ Grid ];
The GameSpacer is now basically the place holder for the game viewport.
After that i have in some tick function (like in a custom widget is used to contain the grid)
which then always updates the padding of the gameviewportcontainer in the overlay to fit exactly into the space occupied by the gamespacer
GameViewportContainer = StaticCastSharedPtr<SHorizontalBox>(GameWidget->GetParentWidget());
GameSpacer->GetCachedGeometry().GetAbsolutePositionAtCoordinates(FVector2D(0, 0));
Pos = GameViewportContainer->GetCachedGeometry().AbsoluteToLocal(FVector2D(0,0));
Pos2 = GameViewportContainer->GetCachedGeometry().AbsoluteToLocal(GameSpacer->GetCachedGeometry().GetAbsolutePositionAtCoordinates(FVector2D(1, 1)));
if (Pos != Pos2) {
FVector2D Size = GameViewportContainer->GetCachedGeometry().GetLocalSize();
FMargin Padding;
Padding.Top = Pos.Y;
Padding.Left = Pos.X;
Padding.Bottom = Size.Y - Pos2.Y;
Padding.Right = Size.X - Pos2.X;
if (GameSlot) GameSlot->Padding(Padding);
}
GameSlot is a reference to the slot used by the gameviewportcontainer in the overlay, so i can actually change its padding...
to get access to it... i just removed the container and the readded it, then cached the reference... you could also do it by just iterating over the children list of the container ^^
so thats how i do it for now ^^
now i just need to find a way to allow switching keyboard focus between those two.. or generally that you can interact with one of them xD
ok nope... due to interaction problems this is not ideal
@gritty frigate OK forget it... i got a way better solution now... which also works in terms of interaction by making the viewport container (vertical box) directly part of the grid.... reduces the code quite a bit and i i think the best solution:
GameWidget = FSlateApplication::Get().GetGameViewport();
TSharedPtr<SHorizontalBox> GameViewportContainer = StaticCastSharedPtr<SHorizontalBox>(GameWidget->GetParentWidget());
TSharedPtr<SOverlay> GameOverlay = StaticCastSharedPtr<SOverlay>(GameViewportContainer->GetParentWidget());
GameOverlay->RemoveSlot(GameViewportContainer.ToSharedRef());
GameOverlay->AddSlot(SNew(SGridPanel)
.FillColumn(1, 1)
.FillRow(1, 1)
+SGridPanel::Slot(1,1)[
GameViewportContainer.ToSharedRef()
]
// Add your own widgets sorounding the viewport here
);
Apperently the game engine and the swidget only make sure that the viewport is part of the gameviewportcontainer (horizontal box)... my best guess is, that this is for split view...
either way... they store the slot and then just check that slot if it refers to the viewport...
but it doesnt check if the overly contains the horizontal box directly, which allows us to hook in... and insert the grid...
Interesting to hear of your experiments! I haven't had a chance to read through yet, but that last one looks exactly like what would be needed for this
My concern is that the parent widget is different in PIE and game
That's what I hit upon before
PIE?
Play In Editor
ah...
What you've done which I haven't tried before is taken the parent widget of the GameViewport widget
due to my environment is cant even run it in PIE xD
I tried moving the GameViewport widget itself, which didn't work
ah
When I'm back on my dev machine, I'll have to take a look
jeah... because the SWindow checks that the GameViewport is direct child of the horizonta box... but it doesnt do that with the Overlay and the Horizontal box
lets just thank that UE4 is source available... otherwise i think i would have never figured that out xD
totally
I remember writing plugins for a tool at the start of my career, and I just couldn't figure out how they'd done something with the UI, so just left it a bit of a mess
and then the tool was EOLd, and the source code was licensed to some customers (including us), so I finally got to see the internals
^^
The nice thing about UE is that we get to see the source code, and it's still being developed!
jep
so thankful that some random guy in a forum reccomended me to have a look into UE4 instead of further learning Unity xD
I've never touched Unity - is it much more painful to work with?
From everything I've heard, for things like 2D games, it's much more friendly
In my industry (not games), Unreal is the defacto real-time engine these days.
There's only one big company that's used Unity, as far as I'm aware
Well I for me it helped a lot that i can code natively, have a look at the UI and still have the simplicity of BP and other tools...
Unity is more a cluster of multiple different things which dont work well with eachother...
and i dont like the C# backend
Jeah... i also think that the 2D support is realy bad (to non existent) here in unreal, and unity is way better in that regard... but i still would not use it even for 2D... there are i think better engines out there (like Godot)
What I really like and appreciate about Unreal and Epic is that they have very deliberately gone after my industry (film VFX), including that their CTO comes from this industry rather than games
Can's speak so much about that... since I'm just a hobby dev... but jeah... I saw how big UE got in that... and I guess it goes even bigger due to the virtual sets etc.
Totally - that's what all of my current dev is around
sounds interessting ^^
do you might know how i can tell the game viewport to "release" the mouse so it is visible again and so i can move it to different widgets?
I basically want to create a switch with the "tab" key which allows me to easily switch between user game interaction and sorounding widget interaction? @gritty frigate
You've got SetInputMode_UIOnly and SetInputMode_GameOnly somewhere - let me have a look where
WidgetBlueprintLibrary
Ah - that first one is deprecated. Should have been SetInputMode_UIOnlyEx
All done with PlayerController->SetInputMode(InputMode);
mhmhm... ok thanks
How can I make StructureDetailView to show instanced class? like detail panel in BP
Structure:
`USTRUCT(BlueprintType)
struct FMyStruct : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FString SomeString;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Instanced)
class UWeaponType* WeaponType;
};`
Instanced class: WeaponType
`UCLASS(Blueprintable, BlueprintType, DefaultToInstanced, EditInlineNew)
class MYEDITORPLUGIN_API UWeaponType : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName Name;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FText Description;
};`
@vocal jacinth Should probably be a TSubclassOf<UWeaponType>
Otherwise there is not much to instance :D
But this is also not a slate related question tbh.
This would have given you more answers in #cpp
I changed StructreDetailView to DetailView, then it works!
So... does someone know why a numericentrybox doesnt want to show the number nor change the value when something is typed in and committed?
The Slider works just as it should...
Hey all, I posted this in #gameplay-ai but it might also be appropriate here since the error has to do with DetailsView being null which is a Slate thing I believe.
Has anyone every seen the engine in a state where EQS is completely broken? I'm not sure how but currently if I create an EQS query and just click on the "Root" node it causes the engine to crash:
Assertion failed: IsValid() [File:D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]
UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:100]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:450]
UE4Editor_EnvironmentQueryEditor!FEnvironmentQueryEditor::OnSelectedNodesChanged() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Editor\EnvironmentQueryEditor\Private\EnvironmentQueryEditor.cpp:313]
...
Running it in Debug mode and poking around, I was able to find that a DetailsView variable being null is what's causing the crash. The rest of the call stack has to do with Slate. I've tried clearing out the .vs, Intermediate, DerivedDataCache, Saved, and Binaries of both my project and all plugins being used. I've also tried disabling all my plugins. Not sure how to restore the project to working state.
seems like an engine bug, so submit a bug report and give them all necesssary information. Also, if you can find out what exactly is happening you might also find a way to circumvent the issue for the time being
but if not thats just what it is. Broken
is it possible to render a texture in the details panel with slate?
I don’t know what the details panel controls are specifically, but if you can do any kind of custom slate code, then yes, using an SImage
You can yeah
👍
anyone how to set widget fill remain width? I want to the width is 100 + 100 + remain width of window, I tried fillWidth but it didnt works.
`SNew(SHorizontalBox)
- SHorizontalBox::Slot()
.MaxWidth(100.0f) [...] - SHorizontalBox::Slot()
.MaxWidth(100.0f) [...] - SHorizontalBox::Slot()
[...]`
has anyone tried the FSlateApplication::Get().ToggleGlobalInvalidation(true) ?
I'm seeing a global invalidation cache and tick rate ms decrease with it but not much documentation on it
how do you add a simple menu bar to a slate UI?
Or is there a way to tell the game viewport to always let the input event bubble up to other widgets... because i basically have something like a small editor and i want to capture some input events so i can have some short cuts...
or lets say... how do i tell it to ignore most of the input events?
What are some good resources/examples on slate? Specifically about UI in the details panel.
The widget reflector is very useful to find how the engine does stuff
I'm trying to work out if there's a way of doing responsive Slate/UMG elements. I'm imagining something like "If there's > X space, show widget in this way, otherwise show widget in another way"
Is this even feasible? I'm looking at ComputeDesiredSize but I guess I'd have to create a new kind of container like ResponsiveHorizontalBox?
When I set up my UI using UMG, I usually do it all from a subclass of AHUD using AddToViewport.
Is there a different way to do this for Slate-based elements?
Is TAttribute considered deprecated because it's basically the same as using Bind from the editor in that the getter would get executed every frame?
This is what I use to add my main Slate widget:
UGameViewportClient *ViewportClient = World->GetGameViewport();
ViewportClient->AddViewportWidgetContent( ApplicationWindow.ToSharedRef(), 10 );
Where ApplicationWindow is a TSharedPtr<SWidget>
@gritty frigate you're a legend, thanks!
👍
That's in a subclass of UVisual
void UApplicationWindow::ReleaseSlateResources( bool bReleaseChildren )
{
ApplicationWindow.Reset();
Super::ReleaseSlateResources( bReleaseChildren );
}```
I also have that
UApplicationWindow is a subclass of UVisual
oh UApplicationWindow is your custom class?
yes
in fact, here's the full code:
SApplicationWindow *UApplicationWindow::CreateApplicationWindow( UWorld *World, AMyActor *Application, bool bErrorState )
{
ApplicationWindow = SNew( SApplicationWindow )
.Application( Application )
.ErrorState( bErrorState );
if( World && World->IsGameWorld() )
{
UGameViewportClient *ViewportClient = World->GetGameViewport();
ViewportClient->AddViewportWidgetContent( ApplicationWindow.ToSharedRef(), 10 );
}
return ApplicationWindow.Get();
}
void UApplicationWindow::ReleaseSlateResources( bool bReleaseChildren )
{
ApplicationWindow.Reset();
Super::ReleaseSlateResources( bReleaseChildren );
}```
And in an actor in my level:
```cpp
void AMyActor::CreateApplicationUI( bool bErrorState )
{
ApplicationWindowWrapper = NewObject<UApplicationWindow>();
ApplicationWindow = ApplicationWindowWrapper->CreateApplicationWindow( GetWorld(), this, bErrorState );
}
UApplicationWindow is a UObject wrapper around SApplicationWindow
Thanks so much for sharing this!
you're welcome
Is there a way to use SLATE_BEGIN_ARGS and include all the parent class's args?
If you find out how, please let me know!
Does anyone know if it's possible to use fonts that use distance field alpha in slate?
Out of the box, I mean.
IIRC there is built-in support for it in the font parameters somewhere
Haven't played with that in years though
Yes, I've created a font with Distance field alpha. The Font Cache needs to be in "Offline" mode and the "Use Distance Field Alpha" must be checked.
But what I'm asking is if I can use that font with slate?
To reiterate: does slate offer support for such fonts, or does it only support runtime cached fonts like UMG?
UMG is pretty much a blueprint wrapper for Slate, so most likely it does
Well I didn't find any mention of that so I'd be happy to know what you know about it
(the fonts I mean, not the relationship between UMG and slate)
I've only used standard fonts in Slate, but give me a mo and I'll have a dig
not quite
To be completely honest, UMG is still missing many features of slate.
Which are trivially added if you need them
UMG is just a bunch of UObjects that create Slate widgets internally
It's quite a small layer
Precisely. And it's very incomplete
the font in UMG is passed directly through to Slate, so whatever UMG supports there, Slate will too
yes, but I'm telling you that UMG doesn't support something and I'm wondering if slate does
that something being DFA fonts
Oh, I thought you said that UMG did support it, and you were wondering if Slate did too
To wit, anything that UMG can do, Slate can do
I know that
That's not quite true either really, Slate can't interact meaningfully with content assets - hence UMG
fair
it's trivial to wrap slate with UWidget
Exactly
sigh I'm just gonna repeat my question. Maybe someone else knows:
Does anyone know if it's possible to use fonts that use distance field alpha in slate?
Probably not
There's support for it at the font level, for things like canvas
But as you mentioned, Slate/UMG only uses runtime fonts
Can u tell me how to solve delay between server and client
Wrong channel
@warm vault ask in #multiplayer
I have a sobjectpropertyentrybox that allows me to select a static mesh asset, but I can't get the thumbnail to work. It seems I need a IDetailLayoutBuilder but I can't find any real documentation on it. Does anyone know how I can grab a reference to one or maybe has some documentation you can link?
I'm trying to get the WebBrowser widget to run at 60FPS. It seems to have a couple of Slate components which are hardcoded to 24fps.
I tried just duplicating the Slate components and running them at 60fps but entered a bit of dependency hell due to its Chromium libraries. Are my only real options here to move to a source engine build, or to re-implement the entire widget plugin?
it is not so hard to rewrite WebBrowser
using source build is a piece of pain
can share you my own already rewrited @gray thistle
Thanks @pastel phoenix I'd appreciate that so I can at least figure out what I was doing wrong.
btw, if you planning to recompile CEF, be careful, it have virus in Chromium repository, lol
It does not, of course
LOL that’s probably a test image to reproduce a browser exploit
Any idea how to access the "Actual Size" in code?
You can get it from the AllottedGeometry in OnPaint or Tick I believe
const FVector2D WidgetSize = BoundingRect.GetSize();```
@eager charm Thanks! I will give that a shot
You can use GetCachedGeometry() to get the previous frames' info from somewhere else too
@craggy holly I was using TitleBar->GetCachedGeometry().GetAbsoluteSize() but it was giving me weird results.. Either 0 or a massive int.
It would certainly give you 0 before it has had a chance to lay itself out
Does anybody know where to set Global Invalidation on and off at runtime? or should we just be running console command's for
Slate.EnableGlobalInvalidation [0/1]?
So far I can only seem to find FSlateApplication::Get().ToggleGlobalInvalidation([true/false]);
Hello guys, Any idea or hint on how I can have my custom hardware cursor on mac os displaying after packaging? It's working well on PC and on Standalone on Mac but not after the package
Hello,
I want to display a text which is in HTML format, correctly formatted in Unreal. The text comes from a web server and could look like this: <h2>test</h2>\n\n<p>This is a test</p>\n\n<p><strong>test</strong> Nice Test <em>Cool</em> lol</p>\n\n<ul>>li>Ball</li>\n<li>Cow</li>\n<li>Car</li>\n</ul>
The only way I have found is to build my own Rich Textblock Markup Language and parse the HTML text into this language. Does anyone know a simpler method ?
simpler method is WebBrowser, but it can only show your html page, you can't use it other way
Unfortunately this is not possible, because I would like to create an interactive training and get the text from a Wiki.
not sure how that makes it impossible
but i think you're right about the alternative, you would essentially have to convert the input HTML to rich text markup
Trying to use an FWidgetRenderer to render a uimage to a utexturerendertarget2D throws the following error:
[2020.10.18-10.22.35:811][332]LogWindows: Error: Fatal error: [File:D:/Build/++UE4+Licensee/Sync/Engine/Source/Runtime/RenderCore/Private/RenderingThread.cpp] [Line: 855]
[2020.10.18-10.22.35:812][332]LogWindows: Error: Rendering thread exception:
[2020.10.18-10.22.35:812][332]LogWindows: Error: Assertion failed: SharedThis.Get() == this [File:D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 1329]
code:
TSharedPtr<FWidgetRenderer> WidgetRenderer = MakeShareable(new FWidgetRenderer(false));
TSharedRef<SWidget> SlateWidget = Widget->TakeWidget();
UTextureRenderTarget2D* TextureRenderTarget2D = WidgetRenderer->DrawWidget(SlateWidget, DrawSize);
it's the last line
this is called in a static method
Its cause your not cleaning up the widget renderer, dont use a shared ptr for it, just use a regular one. This is what I use in it
FWidgetRenderer* Renderer = new FWidgetRenderer(true);
// Do stuff with it here
// Call this when your done with the renderer to clean it up
BeginCleanup(Renderer);
Slate coordinate system is driving me insane. May I please ask for a bit of guidance. I want to move the node where the mouse is. But no matter what I do, I can't align MouseEvent position with Node::GetPosition(). There is always some weird offset.
`
FReply SGraphNode_MyNode::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
{
FVector2D mousePosGraph = NodeCoordToGraphCoord(MouseEvent.GetScreenSpacePosition());
SGraphNode::FNodeSet NodeFilter;
SGraphNode::MoveTo(mousePosGraph, NodeFilter);
}
`
I also tried MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()); , but no luck
Should that return an absolute position of the cursor? @pastel phoenix
may be, i don't know exactly
why you trying to work with local position?
i know nothing about SGraphNode, i working with scale in different things
const float DPI = ParentWindow.IsValid() ? ParentWindow->GetNativeWindow()->GetDPIScaleFactor() : 1.0f;
const float DPIScale = AllottedGeometry.Scale / DPI;
FVector2D AbsoluteSize = AllottedGeometry.GetLocalSize() * DPIScale;
In code, absolute is depricated since it doesn't account for zoom, etc
like this
absolute = local * (scale / DPI)
btw - double ZoomLevel = (double((DPI * 100) - 100)) / 25.0;
you are right
don't listen to me 😸
FVector2D LocalPos = MyGeometry.AbsoluteToLocal(MouseEvent.GetScreenSpacePosition()) * DPIScale; is for you
@pastel phoenix Thanks, I have tried that but it still didn't yield the desired result... I guess because it is using MyGeometry (of the node), it flickers between 2 positions and the movement delta is not correct either... Damn
Can you hotswap a DPI curve? anyone know off the top of their head and tried it? 😉
tried it in build I mean using some kind of debug/setting
@rocky abyss interesting question! I don't know but can you share if you find out?
For a player-modifiable UI scale I've just been using UUserInterfaceSettings ApplicationScale and it does the trick
do you know if that's the same as the engineDefault.ini DPI curve in scaling?
it's a little annoying designing UMG at 1K resolution if you're using 4K textures and have to scale them down due to the DPI curve
so I was pondering making my DPI engine curve to 1 to be default 4K so no scaling down textures in UMG just to have unreal scale them back up
but want to hotswap test just to see what issues might come out of it
@rocky abyss afaik that's something that's multiplied against the DPI curve. So we have a DPI curve that we've tested at 1.0 ApplicationScale. Players can use 2.0, but it will make stuff overlap at v low resolutions
@rocky abyss Oh I hadn't even thought about the scale-down+scale-up issue, maybe our stuff looks awful at 4k and I haven't noticed :S
@mild oracle 😄 thanks for answering, I'm more looking at workflow issues, to have any 4K textures in our UMGs we need to remember to scale them all down to 1k and then have unreal scale them back up? Seems like a waste of calculations to literally have to pre-pass calculate extra layout calculations on every widget. So why not design UMG native at 4K and just have engine scale down, however, the way unreal scales down textures is an interesting beast, and I've run quite a few builds looking at them. Mostly going below .5 texture size scale is meh on harsh white UI icons but this is with no mipmaps. So I wanted to run some builds on some devices with 4k UMG layouts and see what does unreal look like when the texture is scaled down like 75% of it's original look. Thus the hot swapping DPI curve to see what adjusting that curve in build does to the textures/UI/Fonts. I think most engines generally think scale up textures, and now we're in a world of 4K.... I don't think a lot of ppl have considered design at the top and scale down instead.
In general unreal is pretty decent at scaling up, a little more weird on scaling down, but that could just be my mipmap settings, thus was hoping to build me a quick pipeline to test it all
Whoa you've done more than us on this. I've recently been changing as many of our UI elements as possible to be power-of-two so we can enable mipmaps. For example for 4k loading screen images so they look OK at 1280x720, and for icons
Anyone know how to set order in which properties appear in a category? (From CustomizeDetails(..)) ?
I guess you just have to re-add them, even if unmodified.
@mild oracle we couldn't get a DPI curve to swap on the fly but setting it in the defaultEngine.ini did the trick as a last resort for our build test.
@rocky abyss oh, that sucks but thanks for the update!
Is there a Slate or UMG class that you can extend to get functionality similar to HTML5 Canvas? As in, direct drawing?
Can use UCanvasRenderTarget2D in combination with a SImage
Cross posting my question here in case someone knows: https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1825549-slate-utexture2d-in-details-panel-customization-crashes-editor-on-compile
I have a UObject derived class called USomeTestObject, in a separated editor module i have a class that customizes the details panel of said object blueprint instances, with a texture.
The texture is drawn correctly as you can see from the image, but as soon as i hit compile ...
does anyone know what the slate widget handling bitmask enums is called?
Anyone familiar with FGCObject ? Does a Slate widget simply need it as-is to store UObjects safely, or does the widget also need to be referenced by another object ?
Assuming the widget, inheriting from FGCObject, is kept alive by a TSharedPtr
it just needs to exist
if you build chains of uobject with shared ptr to gc object -> uobject -> gc object -> uobject -> gc object ... it will require several gc cycles to destroy them
this is what the mystery ensure in umg is trying to warn you about
Haven't seen that one yet, but I'll only have UObject -> (TSharedPtr) SSomething -> (FGCObject) UObject
Does anyone know how to get a reference to the data table in Slate for the text style set in the Rich Text block?
I have a SNew(SRichTextBlock) and want to refer to the table in CPP as in UMG
