#slate

1 messages · Page 2 of 1

gentle sedge
#

Hi everyone, I'm currently learning Slate in Unreal5 and I'm struggling with MakeInstance function.

In the tutorial I follow, it creates a MakeInstance function as follow: (for a class Named ActorDetailCustomization, derived from IDetailCustomization) :

TSharedRef<IDetailCustomization> FActorDetailCustomization::MakeInstance(){ return MakeShareable(new FActorDetailCustomization); }

But in my project MakeShareable only returns SharedPointerInternals::TRawPtrProxy<FActorDetailCustomization>
and I can't find a way to cast/replace it. What am I missing to be able to use MakeInstance with the correct return type ( TSharedRef<IDetailCustomization> ),
to be able to be used later in the module function StartupModule ?

heavy tendon
#

Anyone know what this error is?

#

It occus when I create the SCustomUISlateOptionButton:

#
SAssignNew(NewButton, SCustomUISlateOptionButton);
#

Heres the output log version:

#

error LNK2019: unresolved external symbol "private: static void __cdecl SCustomUISlateOptionButton::PrivateRegisterAttributes(struct FSlateAttributeDescriptor::FInitializer &)" (?PrivateRegisterAttributes@SCustomUISlateOptionButton@@CAXAEAUFInitializer@FSlateAttributeDescriptor@@@Z) referenced in function "public: virtual class FSlateWidgetClassData const & __cdecl SCustomUISlateOptionButton::GetWidgetClass(void)const " (?GetWidgetClass@SCustomUISlateOptionButton@@UEBAAEBVFSlateWidgetClassData@@XZ)

thick pasture
# heavy tendon

That normally happens when you don’t have the required modules added in the build cs file

heavy tendon
#

I can create other slate widgets, just not this particular one. It has nothing special in it though

#

This is the class, I can create a SCustomUISlateButton normally, without error

thick pasture
#

I’m not on my computer so I can’t check myself, but the external symbol errors are almost always due to a missing build cs module or header include

heavy tendon
heavy tendon
agile briar
#

Does anyone here have experience writing customizations?

white crater
#

Thanks for the help. I guess I'll just use SAssignNew and manually update the fields when they change. I guess I misread some of the Slate doc, as it sounded like it supported state listeners like SwiftUI.

grave hatch
#

You can write your own!

stone goblet
#

I am not sure if this is the best place to ask this, I was wondering whats the difference between UUserWidget::NativeConstruct and UUserWidget::NativeOnInitialized?

agile briar
#

You can read the source code of where they're called

stone goblet
#

I was wondering why then my bindings do not work when I bind them in the NativeConstruct function.

#

the only bindings that seem to work are the event base bindings, not the pure function based bindings.

hot notch
#

Just depends on what the binding is for. Initialized is ran when the widget is created. Construct is ran when the widget is added to a new parent.

stone goblet
#

For example, the Visibility binding, for a TextBlock does not work if I bind it inside NativeConstruct.

hot notch
#

I highly recommend you just use Tick in a UUserWidget. It's the same as a binding(unless it's for a TooltipWidget), doesn't break if you explicitly set the value later and it's really just simpler.

stone goblet
#

Okay.

#

I just find it kind of annoying to have 2 very similar functions, which have no documentation ono how to use them.

hot notch
#

Which two?

stone goblet
#

NativeOnInitialize and NativeConstruct.

hot notch
#

They're not similar. One is done at object creation time. You're supposed to set up defaults and handle possible extra creation and stuff here. Initialize happens once and only once over the lifetime of the widget.

Construct and PreConstruct are ran when you add the widget to a new parent. This happens every time you add the widget to a new parent and is intended for use of setting up internal widgets from the state it's been given before being added to said parent. In BP you do this with ExposeOnSpawn proeprties. Those are set after Initialize and before Construct.

stone goblet
#

Okay. Thank you. I am going to use NativeOnIntialize for my bindings and see if this will work.

hot notch
#

Funny enough. They are actually well documented for the BP calls. 😂 But yeah. The C++ are just... nothing.

stone goblet
heavy tendon
#

When inheriting in slate, is there a way to inherit the slate arguments?

#

For example if I have two slate classes:

SLATE_BEGIN_ARGS(SCustomUISlateButtonBase) {}
SLATE_EVENT(FOnClicked, OnClicked)
SLATE_EVENT(FSimpleDelegate, OnPressed)
SLATE_EVENT(FSimpleDelegate, OnReleased)
SLATE_EVENT(FSimpleDelegate, OnFocused)
SLATE_EVENT(FSimpleDelegate, OnUnfocused)
SLATE_END_ARGS()

SLATE_BEGIN_ARGS(SCustomUISlateButtonX) {}
SLATE_STYLE_ARGUMENT(FCustomUISlateButtonStyle, ButtonStyle)
SLATE_ARGUMENT(ETextJustify::Type, Justification)
SLATE_ATTRIBUTE(FText, ButtonLabel)
SLATE_ARGUMENT(bool, IsFocusable)
SLATE_END_ARGS()

And the bottom inherits the top, is there a way to set OnClicked (for example) without redefining it in the arguments of the second?

grave hatch
#

What you can do is pass the lslate arguments as an argument to the child class.

#

SLTAE_ARGUMENT(SCustomUISlateButtonBase::FArguments, BaseArgs)

#

Then do SCustomUISlateButtonBase::Construct(InArgs._BaseArgs);

hollow sorrel
#

Does anyone have any examples of SRichTextBlock in c++?

hot notch
#

It's more or less the same as the UWidget version. You assign the style table and then just set the text in it. Because it's slate, the style table probably needs to be somewhere global like a project setting, unless you're working in a UWidget or a UUserWidget where you can specify that.

hollow sorrel
#

I'm pretty sure I was getting a compiler error, since it didn't recognise SRichTextBlock with a UPROPERTY()

hot notch
heavy tendon
#

Are there any gotchas when IsResourceObjectValid throws an access violation? The call stack is all slate stuff, nothing from my modules.

#

This is the closest thing I can link it back to, but this is straight from SButton OnPaint

mild oracle
#

How come some classes in Slate use TSlateAttribute<T> and others use TAttribute<T>? What's the difference? Which one should I be using?
Also with the Bind button being 👻 evil 👻, would I ever want to implement these in new widgets?

grave hatch
#

Which one does SLATE_ATTRIBUTE create?

#

Does it even create them?

#

Shrug

true wasp
#

Since the documentation lacks a lot, did anybody here ever worked with the Slate Vector Art Data Object? It lets you input a static mesh and it says it "Turns static mesh data into Slate's simple vector art format."

grave hatch
#

That sounds... dangerous.

#

Anything could go wrong!

#

...in other words, no.

true wasp
#

xD Thanks

weary egret
#

anyone knows how to get the line break effect on the textblock here? I tried copying the slate code from SAssetTileItem but it doesn't break

craggy holly
#

Allows you to draw shapes other than rectangles

#

SMeshWidget itself is meant for instanced images, but is not straightforward to use because it relies on material magic too

#

But essentially, you can draw lots of the same thing very quickly, and have a tiny buffer to set some per-item info, like a float or two

warm vault
#

Hey guys! I'm having a hard time getting slate to behave 😦 I have a custom component that extends UWidgetComponent. Within that component I am trying to create a panel that floats above an actor. I'm constructing this on begin play within C++ and calling SetSlateWidget to assign it. I've attached an image showing the problem I have.
Here is the code I wrote to try and do this (where container is the thing I assign as the slate widget):

FSlateFontInfo FontInfo = FCoreStyle::GetDefaultFontStyle("Regular", 36);
Container = SNew(SConstraintCanvas)
            +SConstraintCanvas::Slot()
            .AutoSize(true)
            [
                SNew(SColorBlock)
                .Color(FLinearColor::Black)
            ]
            + SConstraintCanvas::Slot()
            .AutoSize(true)
            [
                
                SNew(SGridPanel)
                + SGridPanel::Slot(0, 0)
                .HAlign(HAlign_Left)
                .VAlign(VAlign_Top)
                [
                    SNew(STextBlock)
                    .Text_Lambda([]() { return FText::FromString("Name"); })
                    .Justification(ETextJustify::Center)
                    .Font(FontInfo)
                ]
                + SGridPanel::Slot(1, 0)
                .HAlign(HAlign_Left)
                .VAlign(VAlign_Top)
                [
                    SNew(STextBlock)
                    .Text_Lambda([]() { return FText::FromString("Value"); })
                    .Justification(ETextJustify::Center)
                    .Font(FontInfo)
                ]            
            ];
#

I should add that I'm using Text_Lambda because I'll be driving the data via lambdas later, just not yet

craggy holly
#

Out of interest... why Slate for this and not UMG?

#

Best guess is that the widget component is not adopting the desired size of your widget

warm vault
#

I wanted to make a component that doesn't need any dependency on content to be setup in a specific way. Later the contents of the grid will be completely driven by code, this is just my attempt to get it to start laying stuff out properly

#

Actually there's a bit more code for the setup of the widget component. This happens in the widget component ctor:

SetWidgetSpace(EWidgetSpace::World);
SetAbsolute(false, true, false);
SetCastShadow(false);
craggy holly
#

bDrawAtDesiredSize by default is false

#

So it'll draw at whatever arbitrary size you've set the component to be

#

There's also a bug in all UE5 versions currently where they can't draw any smaller than 100 units in either axis.

#

And annoyingly Epic didn't fix it for 5.1

warm vault
#

Ah thanks for that. I have set draw at desired size to true now, but it doesn't appear to help 😦 It gives the same result. I have also set the 'DrawSize' to be 200, 200 just to make sure it is big enough. It does change the overall size of the thing, but the container doesn't seem to inherit the size of its parent

craggy holly
#

In which case then it sounds like the slate widget isn't reporting a desired size to the widget component

#

Would be easy to test this by doing the same setup with UMG

#

bDrawAtDesiredSize would need to be true so that the widget component resizes the render target to accommodate the widget content

warm vault
#

Okie dokie, I'll recreate it

#

Thanks

grave hatch
#

Why use a constraint canvas insead of, say, a vertical box?

#

Or even a grid panel, considering your layout.

warm vault
#

YEah perhaps I shouldn't 😄 I've never used this before haha

#

I was going off what UMG creates

#

When I added a canvas for example under the hood it makes an SConstrainedCanvas which is why I used it. I will try an overlay with a grid panel though. Might be easier 😄

short meteor
#

Just realised that maybe someone here may know (by some chance) more about something I posted in CPP #cpp message

warm vault
# craggy holly bDrawAtDesiredSize would need to be true so that the widget component resizes th...

Ok! I have got it working. There were a couple of problems, one of which is my stupidity, and another was the way I had setup the widgets. Firstly I had somehow (no idea how) managed to disable ticking in the component. That meant it was not being updated correctly so I fixed that and things looked a little better but were still not right. Thanks very much for your help! The code I ended up with to get that layout I was after looks like this:

TSharedPtr<SGridPanel> GridPanel;

        Container = SNew(SOverlay)            
            +SOverlay::Slot()
            .Padding(0.0f)
            .HAlign(HAlign_Center)
            .VAlign(VAlign_Top)
            [
                SNew(SBorder)
                .Padding(4.0f, 2.0f)
                .HAlign(HAlign_Fill)
                .VAlign(VAlign_Fill)                
                .BorderImage(FCoreStyle::Get().GetBrush("BlackBrush"))
                [
                    SAssignNew(GridPanel, SGridPanel)
                ]
            ];

        for (uint32 i = 0; i < 10; ++i)
        {
            GridPanel->AddSlot(0, i)
            .HAlign(HAlign_Fill)
            .VAlign(VAlign_Fill)
            [
                SNew(STextBlock)
                .Text(FText::FromString("Name"))
            ];

            GridPanel->AddSlot(1, i)
            .HAlign(HAlign_Fill)
            .VAlign(VAlign_Fill)
            [
                SNew(STextBlock)                
                .Text(FText::FromString("Value"))
            ];
        }
true wasp
craggy holly
vast steeple
#

hey, does anyone know how I can see a list of engine slate bruhs? i.e FEditorStyle::GetBrush("GenericCurveEditor.ConstantKey");
just want to see other options like GenericCurveEditor.ConstantKey

weary trellis
#

or find cpp file in engine source

vast steeple
weary trellis
#

probably not

#

but if u know how it can be called ctrl and f

#

and stuff is changing betwine engine versions so some stuff can exist or just gone

#

and widget reflector is use full

dim bear
#

SEditableTextBox can't be clicked after I add FMargin to it padding.

#

Anyone have idea?

dim bear
hot notch
#

Quick question if anyone is around and might know. Does OnNavigation run Parent->Child or Child->Parent?

#

Having some serious navigation frustration with wrapboxes and grids in CommonUI's scrollbox. Wondering if I can subclass the two and handle the annoying navigation there instead of continuing to bash my face on the wall.

hot notch
#

Did some quick subclassing. Seems to go Child->Parent as expected.

agile briar
#

Heya,

Can you also add a ClassThumbnail brush to a styleset for a non-native (blueprint inherited) class? Maybe by adding the "_C" to the class name?

warm vault
#

anyone have any idea how i would go about displaying player model in the UI or other 3d models something like this?

grave hatch
#

There's a plugin called pocket world, I think, that might be helpful.

warm vault
queen ferry
#

Having no experience with slate, is there a built-in way (or an easy way in code), to reduce the amount of nesting arrays and structs/classes create?

thick pasture
#

Have you tried using that uproperty?

queen ferry
thick pasture
#

I’m on mobile so I can’t easily link it directly, but here

queen ferry
#

Damn, had no idea there was such a doc out there. Thanks a lot 😄

kind bronze
#

Is there a way to make an SImage that is a specific color without specifying the image?

#

Just make a square with that color?

grave hatch
#

SColorBlock

kind bronze
#

That should work.

broken beacon
#

Does Slate widget needs to be created in HUD class, or can I just create them in other class like a Subsystem?

craggy holly
#

You can create them wherever you want

hot notch
# broken beacon Does Slate widget needs to be created in HUD class, or can I just create them in...

APlayerController creates and maintains SVirtualJoystick. Adds it to the viewport and whatnot when it needs to.

I personally took a liking to creating C++ UUserWidgets and writing slate into their Rebuild function. You still get the blueprint editor benefits to most degrees, and you can still handle them in blueprint where you need via like CreateWidget calls and stuff, but you also get the major benefits of low level slate performance. I cut about 70% of the frametime off of our buff widgets that way. Same hierarchy, same BP use, just wrote it in slate instead of using UWidgets.

broken beacon
grave hatch
#

Smells like subsystem.

broken beacon
high charm
#

Hey everyone,

I'm trying to use slate to create a tool in UE4.23.

I'm following the documentation of UE4 named "Slate Widget Examples" but I'm having a headache trying to understand the chapter "Menu and Toolbars".

How do I pass a uiCommandList to my FMenuBarBuilder, how do I call my menuBar in slate?

Thanks to anyone who can help me

grave hatch
#

You can create an FMenuBarBuilder object and then call MakeWidget() on it, I think.

#

It iwll make you a menu bar.

high charm
#

Ok ok but I just create a new contextMenu tho ?
And I just call the makeWidget on the slate ?

#

I'm sorry but this this is breaking my brain !

shadow steppe
#

Hello!
I am trying to add a Slate overlay to the World Editor viewport to support a custom component visualizer. I tried to understand how the overlay in the static mesh works, but it looks like I have access to a Viewport overlay only at construction of a window or is there a way to modify it while running?

grave hatch
#

Unless you're working with a class that provides a premade system for doing so.

#

Like FBaseAssetToolkit or whatever it's called

high charm
grave hatch
#

You can create a window with FSlateApplication. It provides you with a widget to add things to (SWindow)

#

Just add a vertical box or whatever and make your toolbar the first entry.

#

If you want to use a tabbed window, try FGlobalTabManager and add a erm

#

thingy tab.

#

Nomad!

#

A nomad tab spawner which provides you an SDockTab you can add things to in a similar fashion.

#

There are much more involved ways of dealing with workflow like that and I am not going to go into them. 😛

#

Things like the FTabbedWorkflow or whatever it's called, the toolkit implementations, the base blueprint editor and so on.

#

You may also want to check otu the bp editor scripting stuff, I haven't used it, but ti may have a convenient way to create and manage tabs/windows.

high charm
#

Thanks a lot :)

broken beacon
#

In Slate's Construct(), which is wrapped in build optimization macro, is it okay to have a ternary if operator? Context is setting text format based on a bool value

grave hatch
#

Of course it is?!

#

You'd need to give a code example to show why that would be anything but fine?

cunning roost
#

So I'd like to learn a bit of UI creation.
I'm normally an Env artist, and I actually have some good C++ too.

What would be the best route for making something clean and functional for a small project? Slate? UMG? is there tutorial resources for actual best practices?
The scope is purely just a small project in UE5

thick pasture
#

Here’s a helpful resource to read up on both

cunning roost
# thick pasture In most cases I would recommend UMG.

Thank you for this! I appreciate the info. I've found it very difficult to find some explicit instructions for getting started with UI in unreal, lol. The systems feel like there are several fragments of deprecated workflows all over - so I wasn't sure what to start with for basic UI features and implementation

thick pasture
#

Epic provides an example project called Lyra to show off how an “AAA” project would design their UI and UI systems

#

It’s a bit more advanced so I’m on the fence recommending it if you’re still learning the ins and outs, but it could be worth checking out

cunning roost
#

I have a great deal of unreal experience and I've coded my own plug ins too. So if its a real use case I'd prefer that over something that's not practical.

narrow terrace
#

A good intro/example I point people to is the Example Project that Epic provides in the learning tab. It has a UMG map that shows different features of it in a simple way and you can open the blueprint code for it at any time

celest locust
#

probably really dumb question but is slate editor-only? does it make sense to have a slate dependency in a runtime/game module?

grave hatch
#

It's not.

#

UMG is built on Slate, if Slate didn't work at runtime, nor would UMG.

celest locust
#

oh interesting

celest locust
#

Does slate have any built in stuff for 3d models? Like if I wanted to do a model viewer type deal

celest locust
grave hatch
#

There's SMeshWidget or so. Not entirely sure how it works.

desert thicket
#

Hello everyone, can anyone explain me what PropertyHandle variable in FClassViewerInitializationOptions used for in SClassViewer? Can i automaticaly generate instance for object with Instanced objectflag if i use it as PropertyHandle for ClassViewer or i have to use UClass* and create object manually?

grave hatch
#

A PropertyHandle is the something generated by the property editor module and heavily relates to the details panel.

#

In this case, it's a link to the property the class viewer would be set to once you choose a class.

#

You can probably leave it blank if you aren't setting a property.

lilac yacht
#

Someone here by chance know where the customization/creation of a tarray editor display is done? I got a PropertyTypeCustomization for one of my structs, which has a TArray<StructContainingAFSoftObjectPath> and I need to add a listener to the FSoftObjectPath's SObjectPropertyEntryBox on the TArray<>'s entries. My plan is basically just recreate the display of the TArray in my PropertyTypeCustomization. Having a PropertyTypeCustomization for the struct being stored in the TArray is not an option.

grave hatch
#

Can you not listen to PostEditChainProperty in the object holding the struct?

#

Or it migth even trigger PostEditChangeProperty

#

Plus if you want to know where something slate related is define, check the widget debugger. It tells you exactly where it's instantiated. 🙂

lilac yacht
#

No, I need to filter out the results that are shown in the dropdown list generated by the SObjectPropertyEntryBox/FSoftObjectPath based off the value of another property in the struct

#

Errr do you mean listen to that to figure out where this stuff happens

#

Hopefully this explains it better?
I have FMainStruct and MainStructPropertyTypeCustomization. It (FMainStruct) has members FSoftObjectPath memberPath and TArray<StructContainingAFSoftObjectPath> arrayPaths. For memberPath, I create the slate for it (idk what to call it i guess) like so:

// In CustomizeHeader()
// Basically copy-paste from FSoftObjectPathCustomization
ChildBuilder.AddCustomRow(FText::FromString(GET_MEMBER_NAME_STRING_CHECKED(FMainStruct, memberPath)))
.NameContent()
[
    BaseStatHandle->CreatePropertyNameWidget()
]
[
    // Creation of SObjectPropertyEntryBox here
        .OnShouldFilterAsset // delegate I need
];

I just now need to do this for all the entries in the TArray. I was hoping to find wherever the engine creates the TArray display, and use that for reference

grave hatch
#

You could just remove the widget/row for the array property and add your own?

#

(In the struct customiser)

#

...unless you literally want to copy+paste the array one and add some filtering...

lilac yacht
grave hatch
#

Is it a delegate?

lilac yacht
#

.OnShouldFilterAsset, yeah. On the SObjectPropertyEntryBox that's used for creating the display for FSoftObjectPaths

#

or uh no I guess? SLATE_EVENT(FOnShouldFilterAsset, OnShouldFilterAsset);

grave hatch
#

I think that stuff is buried deep within the private section of the property editor module.

lilac yacht
#

I mean I can do this for regular FSoftObjectPath member variables just fine . I just don't know how to do this for FSoftObjectPaths that are inside of a TArray .-.

main mesa
#

Has anyone implemented anything akin to 3D line rendering in slate? Am looking to see if a library already exists for it but I don't see anything

desert thicket
lyric crescent
#

I know that this question has been asked but there is no answer for it.
How to properly display FGameplayTag widget in structure customization?
I'm trying to display default FGameplayTag widget as follows but it does not work:

Tag->CreatePropertyValueWidget()

I mean it works for other types (like Enums, SoundBase, etc) except for GameplayTag 😕

grave hatch
#

Maybe it uses it for meta data.

lyric crescent
#

@grave hatch It displays null widget instead of GameplayTag

grave hatch
#

Look at the regular one in the details panel and use the widget inspector to see where its instantiated. You may find the customisation there.

desert thicket
desert thicket
lyric crescent
desert thicket
grave hatch
#

With a UPROPERTY specifier

lyric crescent
grave hatch
#

Maybe!

desert thicket
#

and there u can use combobox for gameplaytag if it's not working properly by default

grave hatch
#

He wants to use the default implementation, though.

#

And is wondering why it doesn't work.

desert thicket
grave hatch
#

Have you tried a property row generator?

#

I really have no idea what they're for, but they're useful for generating property handles!

#

I know create single property doesn't do it either.

polar olive
#

Is it possible to have an animation play in slate?

grave hatch
#

Slate doesn't have a built in animation manager like UMG does afaik.

#

But you absolutely can animate things.

polar olive
#

I really jus twant to be able to play a video or something for a loading screen

grave hatch
#

Yes.

#

I'm not sure how, though.

#

Maybe just an simage widget with a media texture?

polar olive
#

Ohhh yesss I will try that

grave hatch
#

I've used that before with a widget component to play videos in the world. It definitely works.

#

No sound obviously, though.

polar olive
#

awesome just what I was looking for

#

Wait how do you assign an image in slate

grave hatch
#

SNew(SImage).Image(blah)

#

or SAssignNew(SomeVar, SImage).Image(blah)

polar olive
grave hatch
#

Blueprint can't interact with Slate, you'd need to use UMG or write a bridge via a BP library.

#

(or some other random uobject you have available)

polar olive
#

Wait so I have a Media texture in my content browser that I wanna use

grave hatch
#

You can import the media texture via its asset reference.

polar olive
#

How do I do that lol

grave hatch
#

Or better a class like UDeveloperSettings (create a subclass), add a uproperty on to it which you set in the editor and access in c++.

#

Mark it edit defaults only and then access the CDO in c++.

polar olive
#

I'm new to this stuff can you explain it like i'm 5 lol

#

idk what a CDO is

grave hatch
#

Class default object

#

If you don't know what that is, you need to do some tutorials!

polar olive
#

You are so right!!

#

SNew(SImage)
.Image(What do I put here lol)

grave hatch
#

UE c++ tutorials.

polar olive
#

I haven't been able to find a tutorial that implements an SImage other than the ones that just use ColorandOpacity

grave hatch
#

Look at engine code then.

polar olive
#

okay thanks

tepid mulch
#

is there a way to make the canvas panel the same aspect ratio as the camera? right now I have a 16:9 canvas panel with a 4:3 camera

grave hatch
#

The root ui element will cover the entire screen. Or should do.

#

Is your camera 4:3 when you have a 16:9 window?

jolly berry
#

Hi all,

I'm following the Slate QuickStart documentation (https://docs.unrealengine.com/5.1/en-US/slate-editor-window-quickstart-guide-for-unreal-engine/)

and I feel like I am missing a step. I finish step 4, rebuild the project in VS, relaunch the editor and my window is not showing the items I created.

I'm guessing it is because my SlateQuickstartWindow.cpp isn't calling my SQuickStartWindowMenu.cpp.

But I am unsure how to do this.

It's my first time diving into slate o.O

Build a simple editor window using Slate.

grave hatch
#

Show your code and a screenshot of what the actual outcome is.

jolly berry
#

I did also make sure that when I created the C++ Class that I set the Module drop-down to the SlateQuickstartWindow module.

#

It's this line in particular that I don't understand from the documentation.

Therefore, you should create a dedicated Slate widget to hold the menu's contents, then add that widget to the FSlateQuickstartWindowModule class.

grave hatch
#

Alright. So you've got your window there.

#

You set the content of that window using lines 72 and 73 of your first screenshot.

#

You havne't done that so it isn't displaying.

jolly berry
#

What would I call to display the widget?

I understand SNew(TextBlock) creates a text block,

What creates the widget?

grave hatch
#

Well, you could replace lines 67-74.

#

SNew(YourWidgetClass)

jolly berry
grave hatch
#

Where it says SNew(SBox) - that's creating a slate box widget and setting the properties and contents of that box.

#

So replace that with the details for you widget.

jolly berry
#

Ok, thank you. Do you know where I would find more documentation on that?

grave hatch
#

Slate... documentation.. ha.

jolly berry
#

Ah, it's as good as I have found, haha

grave hatch
#

Read the qt to slate guide in the pinned messages (if it's still there)

#

It's pretty good.

#

Also the umg and slate guide on github which should also be there.

#

Damn the qt one is gone.

#

Slaps mods

jolly berry
#

I just opened up the github one. Looks like a deep read haha.

grave hatch
#

Don't worry if you haven't used qt before.

#

It's still pretty good.

jolly berry
#

Ok, thank you for that. I've never used Qt lol

Another question. I saw that you can't necessarily connect slate to Blueprints. But I don't know how old that info is.

Really I'm trying to connect slate to a state tree which is built in BP

grave hatch
#

UMG is the wrapper for Slate that works with blueprints.

#

You can interact with slate in bp through a bp library, but no part of slate is usable in bp at all.

jolly berry
#

@grave hatch It would appear I have no idea what I am doing 😅

I tried adding the line like you mentioned, and rebuilt the project and it still doesn't show up.

I added the #include to the .cpp file as well.

grave hatch
#

Ah, well, one reason would be that you aren't actually adding your widgets to anything in your construct method

#

Normally you'd do something like Child[ your widget here ];

#

Or ChildSlot, whatever it is.

#

What's the header for your quick start class?

jolly berry
#

Ahh, there is one more puzzle piece to add. Haha

Here is my header for the quickstart

#

And this is the window

jolly berry
#

Adding that in fixed it. Thank you for the help, now onto the next learning aspect lol

grave hatch
#

Np. Good luck.

wide dragon
#

Is there a way to get the path of an image from the Widget Reflector?

grave hatch
#

Not that I know of. You can get the local the simage was instantiated and add a break point, though.

warm vault
#

Can I downcast a SWidget? Cast<T> is not implemented for Slate widgets, and dynamic_cast is giving me an error.
Casts.h(548): [C4541] 'dynamic_cast' used on polymorphic type 'SWidget' with /GR-; unpredictable behavior may result
Is there any way to know, given a pointer to base SWidget, what type the pointed widget actually is?
static_cast is not an option because I do not know the runtime derived type, so I could be getting undefined behavior sometimes for casting to the wrong type.

grave hatch
#

You can cast widgets with static_cast.

#

Not all widgets implement the Cast-style thing which sets their type name.

#

However, there is a debug thing which you can use to get the type name, but I don't know if that's available outside of the editor.

#

That method is GetTypeAsString()

grave hatch
#

However, if you want have an SVerticalBox, say, and that inherits from SBox, it will returns SVerticalBox as its type name, so checking if it's typename is SBox will fail, even though it's a valid cast.

#

If you want to use the Cast-like method, the widget itself must have SLATE_DECLARE_WIDGET or SLATE_IMPLEMENT_WIDGET in its header.

#

If it doesn't, the Cast-like system for widgets won't recognise that subclass (it will return the type of its parent).

#

You can check widget types with this system using StaticWidgetClass() or GetWidgetClass().

#

It's a bit of a mess, to be fair.

warm vault
#

SLATE_DECLARE_WIDGET seems to be exactly what I need. Thanks

spare cypress
#

what widget class should I subclass if I want to draw things on screen with functions like UWidgetBlueprintLibrary::DrawBox()? UUserWidget or SCompoundWidget?

spare cypress
#

(UUserWidget worked)

hot notch
#

Does anyone have any experience with the Virtual Keyboard stuff for non PC platforms? Apparently when using an editable text field on Playstation4, finishing the entry only closes the keyboard. It doesn't actually call any OnTextCommitted.

grave hatch
#

I've definitely heard woes about the virtual keyboard.

#

But not that one specifically.

hot notch
#

I do a lot of handling with the Entered part of that enum. 😦

grave hatch
#

Have you tried OnTextChanged instead of Committed?

hot notch
#

Don't want it there. This is for saving stuff to disk basically. On PC we just do it from enter press. OnTextChanged is only used for limiting the field length.

grave hatch
#

That's besides the point! If it works, it's an issue with the interaction with the virtual keyboard and text fields.

#

Like there are tons of inconsistencies in how Slate delegates work.

#

Being called in different orders depending on context and so on.

hot notch
#

Somehow that just isn't surprising. 😂

grave hatch
#

You can easily trace down the code execution if OnTextChanged does trigger to see where in the virtual joystick code the call is coming from and finding out why Committed isn't called.

#

Maybe there's a missing option or a callback you need to set, etc.

hot notch
#

Apparently there is an option for it. 😄 At least I'm assuming from glancing at the code. VirtualKeyboardDismissAction probably needs to be TextCommitOnAccept instead of it's default.

Thanks for the nudge @grave hatch

grave hatch
#

Np. 🙂

warm vault
#

It it possible to check whether shift or control are down in the OnClicked callback of SButton? I can see that the functions that call OnClicked inside SButton's cpp have access to a FInputEvent which has a ModifierKeys member, but that event structure is not forwarded along to the user defined callback. I would like some buttons to behave differently if certain modifier keys are down when clicking on them, and I can't figure out how to do that with SButton.

warm vault
#

For anyone wondering you can use if (FSlateApplication::Get().GetModifierKeys().IsShiftDown())

grave hatch
#

BoxReference->AddSlot().YourPropertyHere(blah).YourNextProperty(blah) [ slot contents ];

#

etc

celest locust
#

whats the difference between U and S classes? afaik S is slate, but why is it different from U? like theres UWidget and SWidget

#

is UUserWidget the only widget type thats allowed to tick?

#

it seems to be the only one with NativeTick and a Tick function

fossil kayak
#

nope, just add tick to your UWidget

#

i think CommonUI does that as well

#

of FCoreTicker but... FTickableGameObject ftw

celest locust
#

hm ok, well i want to derive URichTextBlock but make it tick so i can do per-character readout. i found a version online that uses a timer instead but.. idk it feels jank af. maybe im just being stupid

fossil kayak
#

but the guy on yt said timers only

#

if I knew how coros work I would make some kind of coro pun but...

celest locust
#

OK I'll be sure to ping to directly if anything bad happens though

fossil kayak
#

don't worry I did that in the past and it worked great

#

just implement GetStatID and youre good to go

celest locust
#

Like specifically for widgets?

fossil kayak
#

yeah

#

there is this widget that replaces your widget based on index

#

I made my animated version

celest locust
#

Oh nice. I was sort of worried that maybe it would tick properly or something. Or maybe it would tick when it shouldn't.. Idk

fossil kayak
#

and then heard about CommonUI and switched to that

celest locust
#

Lol

#

I've heard mixed things about commonui

fossil kayak
#

its great

#

you can check it out because Im sure it ticks in some way

celest locust
#

I can't partially use common ui can I? Like I have to change all my widgets to use it

fossil kayak
#

you can partially use it

grave hatch
#

Damn, activity in #slate and I missed it!

high charm
#

Hi Everyone,
I'm facing a little problem :
I'm trying to follow this tutorial : https://dev-epicgames-com.translate.goog/community/learning/tutorials/vyKB/unreal-engine-creating-a-custom-asset-type-with-its-own-editor-in-c?_x_tr_sl=en&_x_tr_tl=fr&_x_tr_hl=fr&_x_tr_pto=sc
And I keep having an issue with Slate_Begin_Args =. How do I prevent my IDE to go Bananas with this ?
Thanks :)

Epic Developer Community

In this tutorial, you will learn how to create a code plugin that adds a custom asset type (complete with its own editor) to the engine. As an example, ...

grave hatch
#

Have you tried just compiling?

#

Your IDE is just getting confused.

celest locust
#

rider? more like ridumb and i right?

grave hatch
#

Also that looks like the Rider error list.

#

Click the button on the left that looks like a folder tree. Never unclick it.

high charm
high charm
grave hatch
#

Ignore squiggles and fake errors.

high charm
#

kk will try that

grave hatch
#

Only look at the raw compiler output.

high charm
#

It's like what, it's not exactly Cpp so the IDE is freaking out ?

grave hatch
high charm
#

Thnks, will try to compile

#

And btw do you know Why I can't have access to GEditor->CanTransact() ?

grave hatch
#

You havne't included the file for GEditor?

#

Or the UnrealEd module in your build.cs?

#

Or your IDE is just faking errors again.

high charm
#

thanks

celest locust
grave hatch
#

I have never used UMG in c++.

#

Never intend to!

celest locust
#

ye fair enough

grave hatch
#

What problem are you having?

celest locust
#

long story short, im trying to figure out if its possible to do a letter-by-letter readout while also supporting decorators. my solution so far is to derive URichTextBlock (or CommonUI one), store the original text and an index and just append it to the actual text after some readout time. my problem is that when i get to a decorator in the string, its going to start printing out hello <decorator> until </>

#

this problem is compounded with nested tags

grave hatch
#

Or just make a record of the currently open tags and close them all when you have enough letters.

#

(using a stack)

celest locust
#

what do you mean by preprocess the tags?

celest locust
#

looks like im going to have to write some kind of dumb parser which i was sort of hoping to avoid

#

ye im not going to worry about i18n. at this point i feel like if im writing a preprocessor, is it even worth using the rich text decorators? i have all the information that i would need in the preprocessed structure

#

the problem is that some of the tags are going to affect how the readout is done. the most complicated one we have is an ellipsis which does . .. ... then repeats like 3 times

#

eh thats fine i wont go that far

#

do you mean with the glyphs thing again?

#

🤔 isnt the playstation button icon thing done with the inline image decorator?

crystal lark
#

If you get random weird errors that don't make sense in Rider or don't reflect compiler output, try File -> Invalidate Caches -> Invalidate and Restart. This has happened to me some times where I get errors like "APlayerController is not defined" or similar wording, cannot remember.

grave hatch
#

The better method is to go File -> Exit, then Start -> Visual Studio 😂

high charm
#

Hi everyone, I'm looking to dynamically change the details panel target ```cpp
TSharedRef<IDetailsView> DetailsView = PropertyEditorModuleForSentence.CreateDetailView(DetailsViewArgs);
DetailsView->SetObjects(TArray<UObject*>{ detailTarget});

I tried something like this 
```cpp
detailTarget = Asset->SentencesInDialogues[Asset->sentenceIndex];
        Asset->Modify();
        DetailsViewForSentence->SetObjects(TArray<UObject*>{ detailTarget});
        DetailsViewForSentence->ForceRefresh();
        PropertyEditorModuleForSentence.NotifyCustomizationModuleChanged();

But I have to close and open my asset to see the change everytime and it's a little time consuming :/

#

I just want the detail panel to update when I change the SentenceIndexvalue

#

Im in a FAssetEditorToolkit btw

grave hatch
#

It should update automatically

#

As long as the object its viewing doesn't change, its properties should just update.

high charm
#

Yes but that's what i'm trying to do : change the object it's viewing

grave hatch
#

Then that should work.

high charm
#

hmmmmm

#

My detail panel view object A, I made a Button to change the target to Object B (same type of object) but when I call the function I have to close the asset and reopen it to see the change

high charm
#

My bad I'm stupid

grave hatch
#

What was the issue?

grim summit
#

Hey there, I'm totally stuck with a custom Slate Widget that compiles in 5.0.3 but not in 5.1 with an unreadable error..
The main questionable thing I guess is that it's templated with NumericType to allow the use of any numeric type I want. I have 3 widgets made with this template and only one of them doesn't compile at all in 5.1. I simplified the widget as much as possible and I still have the error until I remove the template.

Here the only error I get:
1>Module.AATools.3_of_4.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl STest<int>::Construct(struct STest<int>::FArguments const &)" (?Construct@?$STest@H@@QEAAXAEBUFArguments@1@@Z) referenced in function "public: virtual void __cdecl FAACineCameraDetails::CustomizeDetails(class IDetailLayoutBuilder &)" (?CustomizeDetails@FAACineCameraDetails@@UEAAXAEAVIDetailLayoutBuilder@@@Z) 1>D:\Plastic\AADev\Plugins\AATools\Binaries\Win64\UnrealEditor-AATools.dll : fatal error LNK1120: 1 unresolved externals

Seems like the error I often get when I forget some #include or some module dependencies. But I can't figure out why the 2 other widgets built the same way are working.

I'm surely missing something, perhaps because I'm building my plugin for 5.1 in a new blank project.
Any help would be appreciated 🙂

grave hatch
#

The problem is that you can't define templated functions in cpp files.

#

Unless they are type specific "overloads"

#

You need to inline the constructor in the header and it should work.

#

You can rename it to a .inl file (inline) and just include it at the end of your header as well. Or simply just copy+paste the definition to the bottom of the header.

grim summit
#

Oh thx I'll try. This explains why SNumericEntryBox is all in header.

grave hatch
#

Yup.

grim summit
#

I did all in the header and it worked, so many thanks @grave hatch !! 🙏

grave hatch
#

Np

onyx night
#

How does one go about making a slate only application? I've tried to do this from time to time and it always seems egregiously complicated and never got it to work right.

grave hatch
#

You weren't wrong.

simple delta
#

@onyx night You should take a look at this: It's a hello world slate only application. You can go from there

grave hatch
#

Just don't link to Engine, CoreUObject

celest locust
#

Why would you want slate-only anyway?

#

I'd assume it's a non-game application

onyx night
onyx night
# celest locust Why would you want slate-only anyway?

I have a pre-launch gui written in rust and egui that does things like set/change graphics options. If the application/game isn't running right, this is an opportunity to change settings if you can't from the game menu for whatever reason. Doing it in Slate means I'd be able to link directly to the game itself and invoke code which would cut out 90% of the work.

onyx night
grave hatch
#

Does anyone know if there's a slate class like list view that offers a proper table-like appearance with consistent column widths?

#

Auto-sizing columns and such

#

But also works with a backing array like listview does.

#

Oh.

#

I forgot about SHeaderRow!

hollow dagger
#

how'd I get a reference to the instance of a slate thing from inside a lambda / a callable

#

I tried SAssignNew with a variable in localscope but it is null whenever the lambda is called

grave hatch
#

If that didn't work, just store a TSharedPtr to it on the class itself.

#

If Buttons is a class member, you could drop the const and add a & in the for loop and assign it to a sharedptr on that data structure.

#

(Assuming FButtonData is your class)

#

As you're passing in Button already.

#

It should work to use SAssignNew with a weak or sharedptr in local scope, though. Just pass it by value.

#

Probably want to use a weakptr, so you don't keep it alive unnecessarily.

zenith fulcrum
#

Which setting in slate for combo box changes that black background, its foreground color right?

grave hatch
#

It's a mystery.

zenith fulcrum
#

Trying to debug the issue with UMG controlling SComboBox not settings the background of the drop down correctly

#

or its just not transparent

celest locust
#

is it possible to make SGraphNode resizable by the user? like if they mouse near the edges/corner they can click and drag to resize?

ionic thunder
#

Any ideas on how I can simulate an input to a slate or umg widget ? To be more precise a function that will simulate a key press on the widget directly without being given by a pawn or controller. My problem is that I want to replicate the web browser widget so that one user changes a slide, the slide change is replicated to others.

grave hatch
#

Replicating key presses is definitely the wrong way to go about it.

#

You should bind the slider to a value and then chagne that value.

high charm
#

Hi everyone, I try to make a Scombobox<TSharedPtr<int>> and I keep having this error :
SComboListType [SComboBox.h(197)] detected a critical error. See diagnostic dump above.

SNew(SComboBox<FComboItemInt>)
                    .OptionsSource(&optionsInt)
                    .InitiallySelectedItem(currentItemint)
                    .OnSelectionChanged_Lambda(comboBoxLambda)
                    .OnGenerateWidget(this, &FDialogueAssetEditorToolkit::MakeWidgetForOption)
                    [
                        SNew(STextBlock).Text(this,&FDialogueAssetEditorToolkit::GetComboBoxLabel)
                    ]```
Did i forgot something ?
grave hatch
#

Show us the "diagnostic dump"

high charm
#

i can't find it

#

the only thing above is that

#
'UE4Editor-Win64-DebugGame.exe' (Win32): Loaded 'C:\Windows\System32\rasadhlp.dll'. 
'UE4Editor-Win64-DebugGame.exe' (Win32): Loaded 'C:\Windows\System32\FWPUCLNT.DLL'. 
The thread 0x2828 has exited with code 0 (0x0).
The thread 0x5fd0 has exited with code 0 (0x0).
The thread 0x514 has exited with code 0 (0x0).
[2022.12.08-16.04.31:255][  5]LogSlate: FSceneViewport::OnFocusLost() reason 0
[2022.12.08-16.04.31:477][ 15]LogSlate: Took 0.000340 seconds to synchronously load lazily loaded font '../../../Engine/Content/Slate/Fonts/Roboto-Light.ttf' (167K)
[2022.12.08-16.04.31:504][ 15]LogAssetEditorManager: Opening Asset editor for DialogueAsset /Game/NewDialogueAsset.NewDialogueAsset
[2022.12.08-16.04.31:644][ 15]LogTemp: Warning: Banana
[2022.12.08-16.04.32:845][ 72]LogSlate: Warning: WidgetMapToItem length (1) does not match ItemsWithGeneratedWidgets length (2). This is often because the same item is in the list more than once in SComboListType [SComboBox.h(197)]. Diagnostics follow.
[2022.12.08-16.04.32:845][ 72]LogSlate: Warning: 
[2022.12.08-16.04.32:846][ 72]LogSlate: Warning: ItemToWidgetMap :
[2022.12.08-16.04.32:846][ 72]LogSlate: Warning: 0x138c15c0 -> 0x36033918 @ SComboRow<OptionType> [SComboBox.h(408)]
[2022.12.08-16.04.32:847][ 72]LogSlate: Warning: 
[2022.12.08-16.04.32:847][ 72]LogSlate: Warning: WidgetMapToItem:
[2022.12.08-16.04.32:847][ 72]LogSlate: Warning: 0x36033910 -> 0x138c15c0
[2022.12.08-16.04.32:847][ 72]LogSlate: Warning: 
[2022.12.08-16.04.32:848][ 72]LogSlate: Warning: ItemsWithGeneratedWidgets:
[2022.12.08-16.04.32:848][ 72]LogSlate: Warning: [0] 0x138c15c0
[2022.12.08-16.04.32:848][ 72]LogSlate: Warning: [1] 0x138c15c0
[2022.12.08-16.04.32:848][ 72]LogOutputDevice: Warning: 
#

My list is just 1,2,3,4,5,6

#

I don't have the same element twice

grave hatch
#

I'd use the widget reflector to check where that flag is created, follow the class to where it's used and see what's going on.

high charm
grave hatch
#

Tank

high charm
grave hatch
#

Pretty sure the diagnostic dump was it complaining about adding the same thing twice.

sudden parrot
#

I asked a variant of this problem in CPP and they recommended I ask here, I am building a custom editor and trying to get the Ftext variable to show up and be edited as Multiline text box rather than a normal text box. Any advice on how to do that? I can get it to be a Multiline Text Box but you can't commit changes it always reverts to default value

celest locust
sudden parrot
#

Naturally, but the binding using the Actions and Factories system does not seem to have a clear way to do that

#

So I have the Editor Toolkit:
InTabManager->RegisterTabSpawner("SingleCorrespondenceMulti", FOnSpawnTab::CreateLambda([=](const FSpawnTabArgs&) { return SNew(SDockTab) [ SNew(SSingleCorrespondenceWidget) .Receiver(this, &FSingleCorrespondenceEditorToolkit::GetReceiver) .OnTextCommitted(this, &FSingleCorrespondenceEditorToolkit::SetReceiver)

#

Then inside the widget specifically:

 [
     SNew(SMultiLineEditableTextBox)
     .Text(InArgs._Receiver)
     .OnTextCommitted(InArgs._OnTextCommitted)
 ];```
#

Which SetReceiver is doing this:

{
    SingleCorrespondence->Modify();
    SingleCorrespondence->Receiver = Receiver;
}```
#

This line however .OnTextCommitted(this, &FSingleCorrespondenceEditorToolkit::SetReceiver) complains that there is no viable function

celest locust
#

you can wrap code in ```cpp
```

sudden parrot
#

My turn to deploy the question mark.

celest locust
#

```cpp
your code here
```

sudden parrot
#

Ah thank you

#

That does make it a lot easier to read

celest locust
#

your solution is probably something like using a class/local variable which you initialize to InArgs._Receiver then change in your OnTextCommitted callback

sudden parrot
#

I have that.... Hmm I'll have to keep working at it

sudden parrot
#

So adding the meta=(MultiLine=true) got me halfway there, I'm shocked I didn't get there sooner. It still wont text wrap which confuses me greatly

grave hatch
#

Instead of updating the .Text(), I would just bind it. Saves a lot of time and won't affect your game.

#

(seems you are!)

#

There might be am option for the MLTB that adds auto-wrap?

celest locust
grave hatch
celest locust
#

Ye I think I'm a bit confused. Isn't .Text how you bind? And I wasn't saying to call it again when it changes, you just call it once when you create your widget and it should uodste if you change by itself, right?

grave hatch
#

It is, but you said about changing the value set in text. You shouldn't change the value there, but rely on the function to do it.

celest locust
#

ah ye fair. i meant with a binding, i guess i just forgot how to words

grave hatch
#

🙂

sudden parrot
#

Yeah, I think in the creation of the editor asset there is a binding method that I just don't understand and cannot seem to replicate to the more complex MultiLine requirements. The method of making the base data type MultiLine with the meta tag has provided the best results

#

The tut I followed had it working perfectly for floats, getting and setting at will from a click drag method but I just suspect I'm missing something

distant folio
#

Does anyone know how I can intercept a touch event Before it is consumed by a widget?
If I was able to print "hello" on any touch event and am still able to scroll on scrollboxes or tap buttons my problem would be solved.

grave hatch
#

InputProcessor

celest locust
#

does anyone know why when i call UEdGraphNode->ReconstructNode my slate disappears and i have to zoom out for it to come back

polar vigil
#

Hi eveyone, How can I add Undo/Redo to non UObject class like SMyListWidget. it has a list of rows which are FMyListRow and for example I want to undo rename and other editor actions.

polar vigil
#

ok I think I figured it out, SMyListWidget should inherit from FEditorUndoClient and register itself by "GEditor->RegisterForUndo(this)" after that I can rebuild my widget by PostUndo which FEditorUndoClient gives me. I had forgotten usually we are editing an UObject by our editor classes so we can simply put RF_Transactional flag for that UObject and rebuild editor classes by listening to changes. but what if I don't have any relation to any UObject in my SMyListWidget class?

#

sorry I think I asked this question in wrong place and should asked it in editor-scripting channel.

grave hatch
#

No it's cool. I didn't know that!

wind cloud
#

Is there anyway to get the total line number from SMultiLineEditableTextBox class?

celest locust
#

Probably count the number of line breaks and add 1?

#

It's shit so maybe there's a better way

wind cloud
#

how to get that 'line breaks'? Right now, I can only get FText

celest locust
wind cloud
narrow terrace
#

You can't use Slate with Blueprint because it's C++ only. You can use UMG with Blueprint though. Also if your using BP only and wanting to do screen positioning only then yeah you have to use a canvas, may be good to use a separate user widget for that positioning widget so when it dirties the widget tree then it shouldn't affect the other user widgets, but it's something you may have to profile and see if it's really a bottleneck. Batching as much info as possible and keeping it easy to access is how you can avoid it really impacting you and profiling as you go is the best suggestion I can give though

#

If you have more questions regarding how to do this stuff in UMG, I do suggest hopping into the #umg channel just so it's in the right topic

narrow terrace
#

Yeah I mean that basically happens on tick because computers gotta update every frame for what's drawn, nothing you can do about that. But batching as much info as possible so you do the least amount of finding new versions of data and such, so if you know which player this UI element is tied to, no reason to find it every frame and such. Thats what I mean by batching

vocal laurel
#

hey - Is there any way I can bind to a

        /** Called when document loading completed. */
        SLATE_EVENT(FSimpleDelegate, OnLoadCompleted)

event from code (an object inheriting from UWebBrowser) ?

#

the slate event is on the slate Web Browser (SWebBrowser) which is a protected shared pointer in UWebBrowser

grave hatch
#

Find other instances of slate events and how they're bound.

#

You would bind to it following the SNew/SAssignNew macro.

vocal laurel
#

I've seen an example of that but wouldn't that require rebuilding the widget itself?

grave hatch
#

If it's not exposed through UWebBrowser, the you'll have to subclass UWebBrowser and change how it instantiates the widget.

#

...if that's even possible.

vocal laurel
#
TSharedRef<SWidget> UWebBrowser::RebuildWidget()
{
    if ( IsDesignTime() )
    {
        return SNew(SBox)
            .HAlign(HAlign_Center)
            .VAlign(VAlign_Center)
            [
                SNew(STextBlock)
                .Text(LOCTEXT("Web Browser", "Web Browser"))
            ];
    }
    else
    {
        WebBrowserWidget = SNew(SWebBrowser)
            .InitialURL(InitialURL)
            .ShowControls(false)
            .SupportsTransparency(bSupportsTransparency)
            .OnUrlChanged(BIND_UOBJECT_DELEGATE(FOnTextChanged, HandleOnUrlChanged))
            .OnBeforePopup(BIND_UOBJECT_DELEGATE(FOnBeforePopupDelegate, HandleOnBeforePopup))
            .OnConsoleMessage(BIND_UOBJECT_DELEGATE(FOnConsoleMessageDelegate, HandleOnConsoleMessage));

        return WebBrowserWidget.ToSharedRef();
    }
}
#

they have this in the code, which seems to be the place where they rebuild it - so i'd have to overwrite this pretty much i guess

grave hatch
#

Correct.

vocal laurel
#

yeah i think i have to extend UWidget and basically re-do parts of UWebBrowser to get this working

#

similar to how XSolla does it

grave hatch
#

Extend UWebBrowser.

celest locust
#

how do i make a SLATE_ATTRIBUTE lambda actually update stuff inside my widget? it works when the widget is first constructed but if the lambda returns a different value after that im not sure how to notify my widget

celest locust
#

i made a getter function in my widget and stored the passed in attribute. seems to work fine

grave hatch
#

You could create a TAttribute getter

#

TAttribute<type>::Create(TAttribute<type>::FGetter(...)) or so

#

I'm sure there are examples in teh engine

narrow terrace
#

Woops yeah sorry, I used that incorrectly. Currently traveling so brain is a bit scattered ATM, but yeah apologies for the confusion

celest locust
#

The whole thing is less code than all those words combined.. Probably

#

Explaining code is the worst

grave hatch
#

TAttribute is probably executing your lambda like it's been "set"

#

TAttribute also supports a callback/delegate to get the value, which is what you're doing right now with your member function.

#

Though the lambda should work fine. 😦

#

(for what you wanted it to do)

#

Paste some code?!

#

Like you should be doing something like .Text_Lambda(... { ... })

#

And it should call that lambda each time the widget is ticked (unless it's in something which blocks invalidation)

honest lake
grave hatch
#

What's the error?

spring crescent
#

What even is that FButtonOptions class?

honest lake
# grave hatch What's the error?

I cannot compile a deprecated method
I am trying rebuilding a plugin from 5.0.3 to 5.1
Direct access to ToolTipText is deprecated. Please use the getter or setter.

spring crescent
# honest lake

Oh, right. Seems like you need to do
SetToolTipText(NewOptions.ToolTip);

misty summit
#

i'm working on a graph widget, and one problem i'm having is if i specify the umg size through the anchors, this is resulting in the FGeometry size to be 0, so i can't seem to figure out how to work out the actual size for my points to scale to.

misty summit
#

nvm, i had to reload the editor as the patch didn't seem to apply right it seems.

grave hatch
#

(pretty handy for slate devs)

grave hatch
celest locust
#

Obviously no girls allowed

weary egret
glad elm
#

Anyone knows how can I get an FVector's default value from an UEdGraphPin*?
SVectorPin sets the value as far as I can see from the debugger but when I try to access it, its empty

grave hatch
#

Are you sure it's the actual pin being used, not just the default representation of the pin at design time?

glad elm
#

I think so - how can I verify?

grave hatch
#

Not sure. I know nothing about graph pins, except that people often mistake that ^

glad elm
#

alright, thank you

grave hatch
#

Sorry 😦

celest locust
#

and #include "KismetPins/SGraphPinVector.h" and add GraphEditor to modules

#

oh it looks like that function is private.. what a pain

grave hatch
#

The word "Default" is giving me worries.

#

But I guess it can be resolved at compile time if it's just a text value.

celest locust
#

idk i just work here

#

in any case, it looks like ConvertDefaultValueStringToVector uses UEdGraphPin::GetDefaultAsString() so.. looks like there might be some other funny business going on

glad elm
#

there was no way to access it

#

so far

#

probably serialization error

#

value being zeroed at some point

#

randomly

#

i should take a look tomorrow with a refreshed mind

#

thanks for the inputs CB_love_u

gloomy hearth
#

I am having some bugs with SlateEditableTextLayout , using Multiline EditableBox, I am using this widget inside Android where i had issue with backspace and Enter, which fixed by sending correct code to SlateEditableTextLayout (always send what is hardcoded inside).

Now issue is whenever i click in between of the text, MoveCursor does not go to middle for some reason, not sure what is the reason but it gets stuck on this line

        (TextInputMethodContext->IsComposing() && InArgs.GetMoveMethod() != ECursorMoveMethod::ScreenPosition))
    {
        // Claim we handled this
        return true;
    }

always returns true.

can some one explainw hat is the IsComposing and how it is being used so i can try to figure out what is going on ?

#

It seems like on Android AllowMoveCursor is null for some reason

gloomy hearth
#

It was because of the virtual keyboard = true had to disable it now it is working correctly

heavy tendon
#

If I SetPadding on my SBorder to less than 7.0f then the engine crashes. The call stack points to OnPaint as the culprit. Anyone know why this could be?

grave hatch
#

Show your code?

heavy tendon
#
void Button::UpdatePadding()
{
    SetPadding(GetCombinedPadding());
}
#

UpdatePadding is called in the following way:

SLATE_IMPLEMENT_WIDGET(Button)
void Button::PrivateRegisterAttributes(FSlateAttributeInitializer& AttributeInitializer)
{
    SLATE_ADD_MEMBER_ATTRIBUTE_DEFINITION_WITH_NAME(
        AttributeInitializer,
        "ContentPadding",
        ContentPaddingAttribute,
        EInvalidateWidgetReason::Layout
    )
    .OnValueChanged(FSlateAttributeDescriptor::FAttributeValueChangedDelegate::CreateLambda([](SWidget& Widget)
    {
        static_cast<Button&>(Widget).UpdatePadding();
    }));

    AttributeInitializer.OverrideInvalidationReason(
        "EnabledState",
        FSlateAttributeDescriptor::FInvalidateWidgetReasonAttribute{EInvalidateWidgetReason::Layout | EInvalidateWidgetReason::Paint}
    );

    AttributeInitializer.OverrideOnValueChanged(
        "EnabledState",
        FSlateAttributeDescriptor::ECallbackOverrideType::ExecuteAfterPrevious,
        FSlateAttributeDescriptor::FAttributeValueChangedDelegate::CreateLambda([](SWidget& Widget)
    {
        static_cast<Button&>(Widget).UpdateBorderImage();
    }));

    AttributeInitializer.OverrideOnValueChanged(
        "Hovered",
        FSlateAttributeDescriptor::ECallbackOverrideType::ExecuteAfterPrevious,
        FSlateAttributeDescriptor::FAttributeValueChangedDelegate::CreateLambda([](SWidget& Widget)
    {
        static_cast<Button&>(Widget).UpdatePadding();
    }));
}
#

However, I have noticed this happens with any padding

#

This for example:

SAssignNew(Overlay_Main, SOverlay)
+ SOverlay::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.Padding(InArgs._ButtonStyle->NormalPadding)
#

The padding cant be less than 10.0f

grave hatch
#

What happened to 7?

heavy tendon
#

7 is for the whole border, 10 is for the Overlay. This is probably something ultra stupid, but every componenet seems to have a minimum padding requirement

grave hatch
#

What's the line that causes the crash?

grave hatch
#

What line?

hollow dagger
#

I'm running Button->SetButtonStyle but nothing changes

#

the button doesnt get updated

gloomy hearth
#

Does anyone have a simple solution to split EditableBox in two separate strings, at cursor position ?

#

I check InsertAtCursor, but not sure where they exactly spliting the text. can someone guide me on this.

grave hatch
hollow dagger
#

The normal color, pressed color etc.

grave hatch
#

Hmm. Not sure on that one, tbh. Those seem like they should be okay. The fallback would be to use the individual options and use getter methods.

hollow dagger
#

it's very weird

#

I can use SetButtonStyle once the button is click in the onclick lambda

#

and it works fine

#

but i'm trying to make a BlueprintCallable function that calls it

#

but it doesnt set it

#

even if I SimulateClick

#

it doesnt set it

grave hatch
#

Are you sure it's actually being set?

hollow dagger
#

yes i debugged it

#

the values change

grave hatch
#

Are you sure it's the correct object/button?

hollow dagger
#

yes

grave hatch
#

How have you checked that?

hollow dagger
#

i'm holding a shared ptr to the button

#

i checked it and they both point to the same address

grave hatch
#

Hmm. 😦

#

Have you tried changing other stuiff? Like the button contents? It might be the thing you're changing just isn't having any specific effect.

hollow dagger
#

I kind of just deleted everything since I asked and decided to do it later so I can't do that now

#

I didn't try other stuff tho no

#

can't lie UI in unreal has been its weakest point for me

grave hatch
#

How come you're using Slate directly, btw, instead of UMG/CommonUI?

hollow dagger
#

it's basically a set of buttons that can be toggled is what i'm trying to make

#

like this

#

only 1 selected at a time

#

now i'm trying to select one of these without clicking it

#

from some other blueprint / C++ code

grave hatch
#

Quickest way to do that, without using styles, would be to use a callback with the setbackgroundcolor instantiation parameter.

#

However, it may not actually be the right parameter. Figuring out what does what is a pain. It's not very intuitive.

lilac yacht
#

Is it a bad idea to for a SComboBox's OptionSource to point to a TArray<> that sits on a IPropertyTypeCustomization? I got one with a TMap<KeyType, TArray<>> member property, and I set my combobox's OptionSource to one of the TArray<>s but I'm getting a weird edge case where the OptionsSource will go invalid sometimes. Not sure if this could be part of the reason or not.

grave hatch
#

The map's data can be moved/rearranged.

#

I would not use a map's value as an optionsource.

lilac yacht
#

Ah, that would make sense. Didn't even think of that. Thanks Daekesh.

grave hatch
#

Np!

#

Same goes for a tarray of tarrays, if you were thinking of some sort of tarray/tmap index thing.

#

A TSharedPtr to a TArray might work? I've never tried that.

#

You could safely put a sharedptr into a tmap.

#

Or SharedRef in this case, I suppose.

lilac yacht
#

I was using the tmap to map TSharedPtr<IPropertyHandle>s to TArray<TSharedPtr<FMyStruct>>s (so it was TMap<TSharedPtr<IPropertyHandle>, TArray<TSharedPtr<FMyStruct>>>). I was planning to just make a wrapper struct, containing those previous two types as it's properties, and then packing that in a TArray<>. So something like

FPackedStruct {
  TSharedPtr<IPropertyHandle> KeyHandle;
  TArray<TSharedPtr<FMyStruct>> ValueArray;
}

TArray<FPackedStruct> MyPsuedoMapLikeArray;
lilac yacht
grave hatch
#

Yeah.

#

Exactly.

#

That in-between redirector saves the day!

lilac yacht
#

That is pretty clever. I hope this fixes my bug, Thank you!

grave hatch
#

Np. Used a SharedRef, though, not Ptr.

copper cliff
#

Hi, I am drawing lines via UUserWidget::NativePaint in my HUD, but I don't like the look

The green lines are drawn using FSlateDrawElement::MakeSpline and alike. The lines are pixelated, which doesn't fit with the otherwise realistic theme.

This is true regardless of the thickness.

Can I draw anti-aliased lines somehow?

#

Or maybe I need to apply some post-processing. Ideally, the green lines will look like real-life HUD projections on a dirty glass ... my glass material is dirty, but the lines are rendered on screen directly.

craggy holly
#

Usually you would draw something like that with materials etc.

#

You have extremely limited capability by drawing primitive shapes directly

copper cliff
craggy holly
#

You should just create an SImage and assign a material to it

#

For in-game UI, UMG is better

copper cliff
craggy holly
#

The only time you really go directly into slate, is if UMG can't do what you need

copper cliff
#

the thing is, I use UMG and for all kinds of widgets, it's perfect. But I liked the flexibility of drawing lines in code ... this is why I thought NativePaint is fine: I rather make changes to my code than editing some image. But maybe this is very limiting

grave hatch
#

Also, just for reference, UMG doens't do anything itself, it's only a wrapper for Slate.

#

So trying to do this with UMG will still, in the end, probably use NativePaint.

copper cliff
grave hatch
#

You might want to generate a high res texture instead of directly drawing splines. Is there a reason you specifically need them to be dynamic?

copper cliff
#

just convenience. I define my splines by some parameters that I can tweak. Re-doing the same graphics from within GIMP, whenever I want to adjust curving, thickness, length, ... just appears to be more tedious.

grave hatch
#

True that.

copper cliff
#

I once made a PowerPoint-style pitch deck and ended up doing all the graphics with Latex-Tikz, programmatically drawn vector graphics, Tikz being a high-level, declarative language for that. That was a bit on the extreme side, but such are my preferences.

grave hatch
#

Hehe. I would just settle on something and work on getting the rest of the game done.

#

You could spend months getting a circle displaying to your tastes.

cloud coral
#

can I force a slate button to be in the pressed state from cpp?
there is Press() but its inaccessable?

#

or is this a bad idea

#

I can also update the style I guess

cloud coral
#

maybe I should zoom out a little

#

I have this hotbar and I want to have one of the slots selected

#

my idea was to make the border of the selected slot green or white or something

#

good question

#

I dont really know what im doing

#

i just followed some tutorial and ended on slate

hot notch
cloud coral
#

interesting

#

I will check out both

narrow terrace
# cloud coral I dont really know what im doing

Use UMG then, its a UObject friendly wrapper for Slate. So either way your working with Slate but UMG has a designer and is what your gonna end up using 90% of the time. The other 10% is for very specific use case stuff (if your game needs it) but you could totally do 100% UMG for some projects and it would be fine

stable loom
#

Hello #slate ,
I got a question concerning the engine's own style definitions. If i look at how the default styles are defined in CoreStyle.cpp, i can see that the resources are being loaded on engine startup from the raw .png files

#

When looking at a packaged game though these files are nowhere to be found, i assume they are automatically included in the .pak file. I have my own UMG Widgets defined in C++ and they have a default style asset where they load their resources in the same fashion. However, when i package the project, those resources are not automatically included in the package, i have to explicitly mention them in the project settings as additional non-asset directories to include. This is supposed to be a plugin however and it would kind of suck if you had to add that to every project the plugin's supposed to be used in. Is there a better way to do this / a way to automatically include those resources in packages?

grave hatch
#

Those files are not assets, they are raw image files. I'm pretty sure that means they won't be put into pak files, though I have no basis for this.

hoary moon
#

Hey Could someone help with a problem I got, I am currently saving data with game instance and save game in c++ and after i went into project settings and changed my game instance none of my widgets appear anymore and that is the only change Ive made
All I know is that everything compiles correctly and im sure my saving works its just the widgets that dont appear

grave hatch
#

None of your... Slate widgets?

forest lichen
#

Is there good resources for someone just diving in deep into the very intimidating Slate codebase? Read a lot of code I guess?

grave hatch
#

There's this:

#

(please pin that again <@&213101288538374145> )

#

And the guide by lighthouse in the pinned messages.

#

If you have read both of those and have specific questions, I'm sure someone will give you some pointers.

grave hatch
#

Just ignore the bits not about slate!

grave hatch
#

❤️

narrow terrace
celest locust
narrow terrace
novel geyser
#
TArray<FName> FControlRigControllerReferenceCustomization::GetNames()
{
    TArray<const void*> RawData;
    NamesArrayPropertyHandle->AccessRawData(RawData);

    return *reinterpret_cast<const TArray<FName>*>(RawData[0]);
}

For a property of type TArray<FName> this is an acceptable way to get the value yes?

craggy holly
#

Definitely not. You're reinterpreting the first item of the array to an array

novel geyser
#

the first element of the rawData array IS the array propertyy

craggy holly
#

Oh, carry on then. AccessRawData must not be doing what I think it does

novel geyser
#

was trying to work out why they never seem to use "GetValue"

grave hatch
#

There's no GetValue for arrays, apparently

#

I suppose there's GetValueData you could cast.

#

I guess it might return 1 entry per object selected?

novel geyser
#

for both getting and setting

#

where the result gets pushed back as some sort of text write to the struct?

grave hatch
#

Probably copypasta.

#

And what?

deep garden
#

is this the correct way to get RobotoBold font?

grave hatch
#

That would probably do it.

#

There might be a style setting that already links to it, though.

#

That'll keep your code consistent with whatever the engine uses in the future.

kind bronze
#

Is there a way to get the scale of an SWindow? I can get the size of the title bar. But without the scale I can’t get the right size of the title bar at different zoom levels.

grave hatch
#

I think you can get the global UI scale, that might be it.

#

Can't remember where it is, though.

kind bronze
#

I do use the global UI scaling, I think, for the content of the swindow, but that does not affect the WindowTitleBar. I see that the windowTitleBar has a scale that corresponds to the windows zoom in the widget inspector under size. But I don’t see how to access this from c++.

grave hatch
#

Maybe in FSlateApplication somewhere?

kind bronze
#

I think the GetApplicationScale I see in FSlateApplication is a scale that can be set but is not set by the windows zoom.

grave hatch
#

By windows zoom, do you mean the dpi scale?

#

Or is there something else?

kind bronze
#

Like in display settings, where you can set screen resolution, you can also set scaling from 100% to 350%. That makes it so I can’t hard code an offset, and need to know the size of the title bar.

grave hatch
#

Yeah. That's the DPI scale.

#

Maybe search for "dpi" in the codebase. 😦

kind bronze
#

It is? Ok I think I may be able solve this in like 2 minutes then.

grave hatch
#

I believe that's fed into the applicationscale thing, but maybe not.

kind bronze
#

Yep that is it.

#

That solved it. Thanks again Daekesh, you are a life saver!

grave hatch
#

Np 🙂

supple hinge
#

hello, i have the main thread doing some calculations and i want to add a progress screen on slate as a separate thread to reflect that progress while the calculations aren't done. I have a TSharedPtr to the slate progress screen widget and in between each calculation on the main thread i call the widget's SetProgress, which has a variable that the progress bar fetches

#

if i update the widget's progress variable on the main thread will the slate thread be able to fetch it on the Progress function binding?

#

but it seems to be blocking because i only see the menu when the calculations are done

supple hinge
#

i'm using SNew to create a slate widget and then use it on GEngine->GameViewport->AddViewportWidgetContent to add to the viewport immediately before starting the calculations

#

i had the idea that slate was not processed on the game thread, but apparently its on the game thread and the GetMoviePlayer is an exception because he makes a thread for updating stuff

grave hatch
#

If you're blocking the main thread with calculations, slate will simply not update.

supple hinge
#

@grave hatch so i need to do the same logic as movie player no?

grave hatch
#

I suppose so, yes.

#

That or offload your calculations to a different thread.

#

Not sure what you meant exactly with the movie player thing, sounded like you were saying it updates slate from another thread?

supple hinge
#

yes

grave hatch
#

Didn't even know that was possible!

supple hinge
#

i'll link you a talk

#

@19:30

grave hatch
#

Thanks!

supple hinge
#

np!

grave hatch
#

Also, that guy needs to smile. What a terrible preview image. Looks like he really doesn't want to be there lol.

supple hinge
#

haha

#

i was actually there in person

#

and he seemed nice

#

maybe just nervous

grave hatch
#

Maybe 🙂

supple hinge
#

it's unfortunate that the movie player doesn't work in editor

hexed plank
#

Isn't there a setting you can set in slate to keep widgets from pixel-locking?

grave hatch
#

Yes

#

It's a global setting somewhere, I think! I've seen it before. I can't remember where it is!

celest locust
#

what is pixel locking?

grave hatch
#

Means window/widget positions are rounded to the nearest pixel

hexed plank
#

Hmm

#

I'm searching the internet but can't find anything on it

grave hatch
#

Yeah. It's one of those hidden features.

hexed plank
#

If you remember what it's called lmk 🙂

grave hatch
#

I cannot.

#

You're probably best off looking at the actual widget render code to see where it rounds the values 😛

hexed plank
#

Yup going through it now

#

Ok I remember now that it is called pixel snapping

grave hatch
#

There's apparently a pixel snapping method option in umg

#

Maybe it isn't a global setting shrug

hexed plank
#

Really?

grave hatch
#

ESlateDrawEffect::NoPixelSnapping

#

Oh, I think benui added it himself.

#

And made a PR

#

But that enum might be from the engine.

#

Though I've only ever seen that enum used on raw slate draw calls. Not sure where it's used/settable in regular slate widgets.

hexed plank
#

Yeah looks like it needs to be done at the slate level

#

I think it also applies to what is drawn in slate

#

Not if you set it in slate and then draw other things on top

grave hatch
#

It would seem that it's pretty hard coded to use pixel snapping

#

For instance, in SImage, it creates its own flags and they are simply "None" or "DisabledEffect". No thought is given to pixel snapping at all.

hexed plank
#

Snapping is on by default

grave hatch
#

Yeah.

hexed plank
#

Because the flag is for disabling

grave hatch
#

That's what I mean 😛

#

I think you'd have to modify the engine to add the flag to everything.

hexed plank
#

Looks like that PR got approved on Nov 16, 2022

#

Still not merged though

grave hatch
#

GG Epic

#

Bear in mind, also, that's apparently for ue4.

hexed plank
#

Although he initially submitted it on Oct 29, 2021

#

LOL

hexed plank
grave hatch
#

Highly doubt it.

#

I will check

#

It is not.

hexed plank
#

Sadness

livid nacelle
#

How can I make my progress bar blink slightly when the progress bar has gone to 0 percent? I set it back to 100% when complete, and want it to blink for a quick second for the player to register that the skill is ready again. Im not using bindings, but events driven by the player to drive skill timers etc. Basically got a branch that can drive this logic

grave hatch
#

Use a timer and adjust the transparency using a curve asset?

livid nacelle
# grave hatch Use a timer and adjust the transparency using a curve asset?

How can I adjust the transparency? Never used a curve asset before, will have to look into that. Thanks! Struggling to find the right way to set this up, just finished making a dynamic spell icon system, figured it would be somewhat in the same line, but just changing the tint instead of the images, but no luck yet 😅

grave hatch
#

Normally you'd adjust the color/opacity of an simage or something.

#

I haven't used a slate progress bar before, so I don't know the specifics of how they work.

odd copper
#

Hi guys! Does anyone know how to remove the rows in the red box?

#

My code

grave hatch
#

Is that your own struct/object?

odd copper
#

No, It is DataRegistry from Epic. But my object holds it.

grave hatch
# odd copper My code

If you disable custom details views, you can't remove the rows at all... any customisation you do will just not be used?!

#

Does the property visible delegate not let you hide them?

odd copper
#

Umm...I decided to create a window to display the details.Thank you very much!

odd copper
#

I found a bug in version 5.1. Can anyone submit it to Epic? The question mark was not clickable (image 1), I fixed it (image 2) by modifying this (image 3) to SWrapBox.

grave hatch
gaunt haven
# grave hatch You _can_ cast widgets with static_cast.

Hey Daekesh, I saw this old comment of yours. If I have:
TSharedPtr<SButton> MyButton;
and I know it is of child type SBetterButton, is this the best way to downcast it:
static_cast<SBetterButton*>(MyButton.Get())->DoSomething();

grave hatch
#

It honestly doesn't matter which way you do it. It's going to do the same operation in the end.

#

You could do StaticCastSharedPtr too.

gaunt haven
#

Alright thank you!! I appreciate the alternative!

grave hatch
#

I would check GetTypeAsString() == "SBetterButton" though

#

The "wiget class" system is super dodgy with Slate.

#

You can check StaticWidgetClass and GetWidgetClass, but if the widget doesn't use IMPLEMENT_WIDGET (or whatever it is) then it just returns the type of the nearest parent that does.

#

And the macro is entirely optional.

gaunt haven
grave hatch
#

Awesome!

feral arch
#

Hey All, I have been spending some time trying to get a custom version of the SSpinBox up and running but have hit some odd issues. The main one I am facing now is the fact that there is no SetFont() function, so I am doing my best to try to implement one. I have tried to recreate the way other things get passed down but to limited success. In the UNG class I have added:
/** Set font. */ UFUNCTION(BlueprintCallable, Category = "Behavior") void SetFont(FSlateFontInfo InFont);

void UDynSpinBox::SetFont(FSlateFontInfo InFont) { Font = InFont; if (MySpinBox.IsValid()) { MySpinBox->SetFont(Font); } }

And in the Slate class I added:

void Construct(const FArguments& InArgs) { ... Font = InArgs._Font; ... }

/** See the Font attribute */ FSlateFontInfo GetFont() const { return Font.Get(); } void SetFont(FSlateFontInfo InFont) { Font.Set(InFont); }

TAttribute<FSlateFontInfo> Font;

The annoying thing is this clearly causes the font field in the spinbox to properly update, but it does not visually update until something else is changes in the font section of the Spinbox. So it is getting the right information but just not acting on it

grave hatch
#

You need to trigger some sort of invalidation.

#

Look into what causes the Construct method in the UWidget to fire

feral arch
#

I had tried that a couple of ways, including a MySpinBox->Invalidate(EInvalidateWidgetReason::Paint); in the SetFont of either the UMG or slate class but looks like no dice

grave hatch
#

It'll be in the UMG class. The slate is irrelevant here.

feral arch
#

I had tried the same with EInvalidateWidgetReason::All in the case Paint was not broad enough, but still nothing

grave hatch
#

The UMG needs to reconstruct the widget.

feral arch
#

Hmmm so a invalidate that does not target the slate directly? I have tried running the RebuildWidget directly and still had no luck

grave hatch
#
{
    Font = InFont;
    if (MySpinBox.IsValid())
    {
        MySpinBox->SetFont(Font);
    }
}``` This in particular is where it should be triggered. Change the SetFont line in the if block to the invalidation call. It _may or may not_ be the Invalidate method. I don't know specifically.
#

Find out what triggers RebuildWidget in the class. I'm sure there must be something. Maybe even just resetting the MySpinBox sharedptr.

hollow dagger
#

I'm trying to change a SButton's color when I press a button but for some reason running SetButtonStyle / SetColorAndOpacity have no effect in game

#

do I need to run it from a specific thread for it to work?

grave hatch
#

It might be the wrong color. There are other color settings like background color. Depends what color you're trying to change.

feral arch
# grave hatch Find out what triggers RebuildWidget in the class. I'm sure there must be someth...

This font issue is wild. I have set the preconstruct to run SetFont first thing in a UserWidget of just the spinbox. I set the UserWidget font variable to font size 30, and compile. If I look at the spinbox it clearly says the right size, but visually is wrong. I then save this way and fully close UE, then reopen. The spinbox still says the updates font size but even after the restart is STILL the wrong visual size. There is some bazarre caching going on here that I am failing to update properly.

#

To add to the weirdness, the preview of the UserWidget DOES match the correct sizing, but not in actual use

grave hatch
#

Just to check, are you setting the font on the slate widget when it'd constructed in Native Construct?

#

It's *

#

It won't do anything to change it after it's created.

feral arch
#

My UMG widget is setting the SLATE_ATTRIBUTE(FSlateFontInfo, Font) via SNew(SDynSpinBox<float>).Font(Font) in the RebuildWidget()

grave hatch
#

Alright!

hollow dagger
grave hatch
#

😦

#

I have no luck with slate button styles.

hollow dagger
#

How would I use SButton

#

Oh mb

#

CommonUI button

#

It has a selected state

#

How'd I replace my sbutton with that

#

Kind of unclear in the docs

grave hatch
#

Use hte CommonUI button class instead?

hollow dagger
#

Yes

pulsar remnant
#

Can I call function on struct from PropertyTypeCustomization ?

whole briar
#

I think this is a slate question?
I want to draw a minimap for a generated level, mostly just lines to start with.
Is there a way to draw onto a canvas (or would it have to be a texture?) once at the start and then just rotated/clipped as needed from there?

grave hatch
#

Yes

#

You can use the Primitive Draw Interface of a Draw call in a viewport client or the OnPaint of a widget to add drawelements

hollow dagger
tulip jackal
#

Long shot here, but I am at the end of my rope:
You know the asset picker/ actor picker you get when you EditInline?
I need to manually insert my own list of assets/actors instead of the generated one.

I've tried the usual resources: Google, examples, documentation, and ChatGPT.
ALL of them are more or less out of date. Like it always seems to be ue 4.26ish content.

grave hatch
grave hatch
tulip jackal
#

Internally it is just FAssetData, so I can convert my reference into array of that.

#

It is able to grab reference to objects in the world, so I believe that is how it is doing that.

#

eh, I think I know what you mean.

#

I wonder if something like this is close (the .ObjectPaths())

grave hatch
#

I'm not saying it's not possible with the underlying widget, but with the details customisation for assets.

tulip jackal
#

I think i'm close

pulsar remnant
#

Is there any other SWidget except SButton that has Hover events?

pulsar remnant
#

Green one is SButton, and white one is SBox
Why SButton is bigger for no reason?

SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
[
    SNew(SButton)
    .HAlign(HAlign_Center)
    .VAlign(VAlign_Center)
    .ButtonColorAndOpacity_Lambda( [=] (){ return BackgroundColor; })
    .OnClicked_Lambda([=] ()
    {
        PropSpawnerSubsystemREF->ToggleMesh(StructPtr->Mesh);
        return FReply::Handled();
    })
    .IsFocusable(false)
    .ContentPadding(FMargin(0.0))
    .Content()
    [
        SNew(SBox)
        .HeightOverride(74.0)
        .WidthOverride(74.0)
        .VAlign(VAlign_Center)
        .HAlign(HAlign_Center)
        [
            SNew(SImage)
            .Image(this, &FPropCollectionStructCustomization::GetMeshBrush)
            .DesiredSizeOverride(FVector2D(64.0))
            .Visibility(EVisibility::SelfHitTestInvisible)
        ]
    ]
]
pulsar remnant
#

Looks like SButton keeps some size to itself regardless of what
Is there any idea why?

grave hatch
#

You mean padding around its contents?

#

That's just part of its style.

#

Use a different button style.

#

Or make your own based on one of the editor ones

pulsar remnant
grave hatch
#

I guess both?

#

They are different padding settings for different states.

pulsar remnant
#

Great, I was losing my mind
I was forcing buttons size by wrapping with SBox, but then button was starting to steal it's contents size

#

Thanks 🙂

hot notch
#

Could use some help with what I might be doing wrong here. PlantKey is a gameplay tag. But this code using PlantKeyHandle->CreatePropertyValueWidget() does not actually seem to create the gameplaytag value editing widget there?

#

Replacing that line with the commented STextBlock line shows the textblock though. So not sure why the gameplay tag ValueWidget isn't showing.

grave hatch
#

Is gameplay tag a struct?

#

The basic create value widget doesn't work for structs. You have to use the struct property builder or whatever its called.

hot notch
#

I think so.

hot notch
#

Aha! Took a minute to find it. 😄 Thanks @grave hatch

grave hatch
#

Awesome!

#

Now why GenerateValueWidget just can't do that I don't know.

pulsar remnant
woven iris
#

How am i supposed to use a referenced Component? I can't find much on expose

                    + SVerticalBox::Slot()
                    [
                        SNew(SHorizontalBox)
                        + SHorizontalBox::Slot()
                        .AutoWidth()
                        .Expose(OctaveEditorSlots)
                        [
                        SNullWidget::NullWidget
                        ]
                    ]```
grave hatch
#

You mean a reference to an actor component (and it's many, many subclasses) ?

woven iris
grave hatch
#

You need to assign the horizonbox to something with, say, SAssignNew(SomeVariable, SHorizontalBox)

#

Then you can do SomeVariable->ClearChildren() and SomeVariable->AddSlot()

#

That AddSlot works identically do + SHorizontalBox::Slot()

woven iris
#

Thank you that's exactly what i was looking for!

woven iris
#
static UTexture2D* CreateTexture2DFromArray(const TArray<FColor>& Contents)
{
    const size_t Size = std::sqrt(Contents.Num());
    ensure(Size * Size == Contents.Num());
    UTexture2D* Texture = UTexture2D::CreateTransient(Size, Size, PF_B8G8R8A8);
    void* TextureData = Texture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
    FMemory::Memcpy(TextureData, Contents.GetData(), 4 * Contents.Num());
    Texture->PlatformData->Mips[0].BulkData.Unlock();
    Texture->UpdateResource();
    check(Texture);
    return Texture;
}






    uint8 TextureWidth = 100;
    uint8 TextureHeight = 100;
    int ArraySize = 100 * 100;
    TArray<FColor> RawImageData;
    for (auto i = 0; i < ArraySize; i += 4)
    {
        RawImageData.Add(FColor(150, 250, 0, 255));//temporary
    }

    UTexture2D* NewTexture = CreateTexture2DFromArray(RawImageData);
    const FSlateDynamicImageBrush* GeneratedNoiseMap = new FSlateDynamicImageBrush(NewTexture, FVector2D(TextureWidth,TextureHeight),FName("NoiseMap"));;``` 
Is there a better way to manually paint for like noise map previews in slate ui? The last line gives me a "Exception 0x80000003 encountered at address 0x7ff9a9be6b4d" But if i continue it doesn't error and it works fine. But i also need a more efficient way of editing this in real time ontop of it just having issues
grave hatch
#

For one, you should do RawImageData.Reserve(ArraySize);

#

You could use a consistent texture2d instead of having to create one each time

#

Your NewTexture is probably getting GC'd as well.

pulsar remnant
#

I'm using it to get asset thumbnails

TArray<FName> Names;
Names.Add(FName(TEXT("StaticMesh ") + MeshString));

FThumbnailMap ThumbnailMap;
ThumbnailTools::ConditionallyLoadThumbnailsForObjects(Names, ThumbnailMap);

UTexture2D* MeshThumbnail = FImageUtils::ImportBufferAsTexture2D(ThumbnailMap[Names[0]].AccessCompressedImageData());
slate spoke
#

How can I fill UWrapBox slots during Rebuild using my widgets?
for example i have UStorageSlotWidget (based from UWidget), and i have UStorageSlotPanel (parent UWrapBox). In my StorageSlotPanel i want fill slots by slots count using StorageSlotWidget

TSharedRef<SWidget> UStoragePanelWidget::RebuildWidget()
{
    Slots.Empty();
    for (int32 i = 0; i < SlotsCount; i++)
    {
        //Fill my UStorageSlotWidget in Slots array
    }
    return Super::RebuildWidget();
}

#
TSharedRef<SWidget> UStorageSlotWidget::RebuildWidget()
{
    MySizeBox = SNew(SBox)
        .WidthOverride(SlotSize)
        .HeightOverride(SlotSize)
        [
            SNew(SOverlay)
    + SOverlay::Slot()
        [
             SAssignNew(MyBackgroundImage, SImage)
            .Image(&BackgroundBrush)
        .ColorAndOpacity(FSlateColor::UseForeground())
        ]
    + SOverlay::Slot()
        .Padding(10)
        [
            SAssignNew(MyIconImage, SImage)
            .Image(&IconBrush)
        .ColorAndOpacity(FSlateColor::UseStyle())
        ]
    + SOverlay::Slot()
        [
            SAssignNew(MyBorderImage, SImage)
            .Image(&BorderBrush)
        .ColorAndOpacity(FSlateColor::UseStyle())
        ]
    + SOverlay::Slot()
        .HAlign(EHorizontalAlignment::HAlign_Right)
        .VAlign(EVerticalAlignment::VAlign_Bottom)
        [
            SAssignNew(MyCountTextBlock, STextBlock)
            .Font(CountFont)
            //.Font(&CountFont)
            .Text(FText::FromString("99"))
        ]
        ];
    
    return MySizeBox.ToSharedRef();
}
grave hatch
#

That seems about right

feral arch
#

So I have a more broad question I wanted to ask about slate in general. I see that a bunch of the UE documentation talks about that Slate prefers polling to invalidation. I take that to mean that when the state changes in a Slate object (some argument changes) that it does not invalidate the object and ping upstream that this slate needs a update. Instead there is some polling period where all currently present widgets are checked for changes and updated. My confusion is what exactly is the polling period in which the slate stuff is refreshed? Is it on tick? Or when some things indicates a user or code interaction?

#

I am giving a presentation on how to use to slate at my work and feel like this is a key aspect of its behavior, but I feel i don't fully grok it

grave hatch
#

Polling would be on tick.

feral arch
#

Well that makes things easy, thank you!

slate spoke
#

can i bind to delegate in myScompoundwidget?

#

i have ItemObject attribute, so i want bind to this object and update text

SLATE_ATTRIBUTE(const class UItemObject*, ItemObject)
pulsar remnant
#

Of course, your function has to return UItemObject*
like that:

UItemObject* MyFunction();
#

Also you can bind lambdas too

.ItemObject_Lambda( [this] ()
{
    return SomeItemObject;
})
grave hatch
slate spoke
#
void OnItemCountChanged(class UStackItemObject* StackItemObject, int32 ItemCount);
  void OnItemHealthChanged(class UHealthItemObject* HealthItemObject, int32 ItemHealth);

this get error.


void SStorageSlot::SetItemObject(TAttribute<const class UItemObject*> InItemObject)
{
    if (IsValid(ItemObjectAttribute.Get()))
    {
        if (const UStackItemObject* StackItemObject = Cast<UStackItemObject>(ItemObjectAttribute.Get()))
        {
            StackItemObject->OnItemCountChanged.RemoveDynamic(this, &SStorageSlot::OnItemCountChanged);
        }
        if (const UHealthItemObject* HealthItemObject = static_cast<UHealthItemObject>(ItemObjectAttribute.Get()))
        {
            HealthItemObject->OnItemHealthChanged.RemoveDynamic(this, &SStorageSlot::OnItemHealthChanged);
        }
    }
    ItemObjectAttribute.Assign(*this, InItemObject);
}

void SStorageSlot::OnItemCountChanged(class UStackItemObject* StackItemObject, int32 ItemCount)
{

}

void SStorageSlot::OnItemHealthChanged(class UHealthItemObject* HealthItemObject, int32 ItemHealth)
{

}
#

@grave hatch @pulsar remnant i want bind to events from ItemObject

slate spoke
#
B:\UnrealEngine\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl(1182): error C2664: 'void TMulticastScriptDelegate<FWeakObjectPtr>::Remove(const UObject *,FName)': cannot convert argument 1 from 'UserClass *' to 'const UObject *'
1>        with
1>        [
1>            UserClass=SStorageSlot
1>        ]
1>B:\UnrealEngine\UE_5.1\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl(1182): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>B:\UnrealEngine\UE_5.1\Engine\Source\Runtime\Core\Public\UObject\ScriptDelegates.h(372): note: see declaration of 'TMulticastScriptDelegate<FWeakObjectPtr>::Remove'
1>B:\Projects\Survival\Source\Survival\Inventory\Widgets\SStorageSlot.cpp(148): note: see reference to function template instantiation 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UHealthItemObject *,int32>::__Internal_RemoveDynamic<SStorageSlot>(UserClass *,void (__cdecl SStorageSlot::* )(UHealthItemObject *,int32),FName)' being compiled
1>        with
1>        [
1>            UserClass=SStorageSlot
1>        ]
1>B:\Projects\Survival\Source\Survival\Inventory\Widgets\SStorageSlot.cpp(148): note: see reference to function template instantiation 'void TBaseDynamicMulticastDelegate<FWeakObjectPtr,void,UHealthItemObject *,int32>::__Internal_RemoveDynamic<SStorageSlot>(UserClass *,void (__cdecl SStorageSlot::* )(UHealthItemObject *,int32),FName)' being compiled
1>        with
1>        [
1>            UserClass=SStorageSlot
1>        ]
pulsar remnant
slate spoke
#

@pulsar remnant Can you show me how to properly bind to my object, I want to update the text in my SStorageSlot when the value in ItemObject changes

pulsar remnant
hot notch
#

@slate spokeOut of curiosity. Why a full slate class for this? This seems like a gameplay related widget. I personally find that it's much easier to connect a UserWidget with gameplay aspects and you can write slate directly into a UserWidget class's RebuiltWidget and get the best of Slate and easy UObject code for update bindings. And you can also create the widget in Blueprint if necessary.

slate spoke
#

@hot notch I try to use base classes if possible.

#

It would also be a good experience for me to learn the basics of the engine and learn how to work with it

hot notch
#

Well, that's fair. But I would take inspiration from already existing gameplay UI slate. Most all of it is UObject wrapped UWidgets. The UWidget does the general bindings and stuff and just updates it's underlying slate. It's also a much easier and faster design method to be able to just throw widgets around in blueprint than to have to go down the slate level just to create a new widget.

#

Is mostly the reason I write some widgets as pure slate in a UserWidget. You still get to write performant UI, and easily throw it around with create widget calls. And it's a UObject for easy delegate binding calls. Can even make a BP child class for specifying default for customizations.

slate spoke
#

Thanks, I'll try that if I don't succeed in binding the slate to my ItemObject delegate

grave hatch
pulsar remnant
slate spoke
#

SynchronizeProperties work runtime?

slate spoke
#

Can i add UWidget( UStorageSlotWidget ) to wrap box like this, using TakeWidget?

void UStoragePanelWidget::SynchronizeProperties()
{
    Super::SynchronizeProperties();
    if (MyWrapBox.IsValid())
    {
        MyWrapBox->SetInnerSlotPadding(InnerSlotPadding);
        MyWrapBox->SetUseAllottedSize(bUseAllottedSize);
        MyWrapBox->SetWrapSize(WrapSize);

        MyWrapBox->ClearChildren();
        for (int32 i = 0; i < SlotsCount; i++)
        {
            UStorageSlotWidget* StorageSlotWidget = NewObject<UStorageSlotWidget>(this);
            StorageSlotWidget->SetSlotSize(SlotSize);
            StorageSlotWidget->SetBackgroundBrush(BackgroundBrush);
            StorageSlotWidget->SetBorderBrush(BorderBrush);

            MyWrapBox->AddSlot()
                [
                    StorageSlotWidget->TakeWidget()
                ];
        }
    }
}
grave hatch
#

Your UWidget would be immediately GC'd.

#

Whether that also deletes the backing SWidget or not... that's a good question.

empty sable
#

How to fix it?

grave hatch
#

Start off by copy+pasting errors, not screenshotting them.

#

And put a ` on either end.

slate spoke
#

@grave hatch can you show, how to create and add UWidget correctly?

grave hatch
#

I'm not sure exactly. I don't use UMG at all.

#

But I imagine it's very similar to Slate, except using UWidgets and UUserWidgets.

slate spoke
#

garbage collector deletes widgets, so I wanted to find the right solution

#

okay

grave hatch
#

You would need to stay within UMG if you're using UMG widgets.

#

You add them to other UMG widgets, not slate widgets.

#

And your root UMG widget you add to the viewport, just like in BP.

#

If you want to use an underlying UMG Slate widget in Slate code, just look at the underlying widget and construct that instead of the UMG one.

#

In your example, check what the UStorageSlotWidget actually does behind the scenes and use that.

#

That or, and I highly don't recommend this, create a TStrongObjectPtr in your slate widget, construct the umg widget and store it there and then get its slate backing widget.

#

That's really, really bad.

slate spoke
#

thanks

slate spoke
#

I try to use TWeakObjectPtr, but ItemObject.IsValid() return false

//.h
SLATE_ARGUMENT(TWeakObjectPtr<class UItemObject>, ItemObject)
TWeakObjectPtr<class UItemObject> ItemObject;
//.cpp

SAssignNew(MyCountTextBlock, STextBlock)
.Font(InArgs._CountTextFont)
.Text_Lambda([&]() { return GetItemCountText(); })

FText SStorageSlot::GetItemCountText()
{
    if (ItemObject.IsValid())
    {
        GLog->Log("SStorageSlot::GetItemCountText()");
        if (UStackItemObject* StackItemObject = Cast<UStackItemObject>(ItemObject.Get()))
        {
            return FText::FromString(FString::FromInt(StackItemObject->GetItemCount()));
        }
    }
    return FText::FromString("");
}
grave hatch
#

A weak object pointer won't stop the UObject being GC'd.

#

And where do you assign ItemObject?

#

Also if you're trying to capture this in your lambda, why not just do [this] instead of [&] ?

pure cave
#

I learned about GetAllAssetViewContextMenuExtenders(), which is the menu when you right click on an asset but where is the menu of GetAllAssetContextMenuExtenders()

slate spoke
#

I forgot to specify in Construct ItemObject = InArgs._ItemObject

pure cave
grave hatch
#

Right.

pure cave
#

Oh boy. So it's just a simple right click in -empty space

slate spoke
#

how to use FDragDropOperation in Slate?

grave hatch
#

You trigger it with return FReply::Handled().SomethingSomethingDragDrop() in OnMouseDown

#

Then you override OnDrag - Or was it OnDragDetected?!

#

on teh thing you want to drag from

#

And OnDrop on the thing you want to drop on.

#

There's OnDragEnter and OnDragOut as well if you want to handle things like that.

#

You can cast them to something with some templated method as well.

#

VS isn't playing ball, so I can't look that up right there.

slate spoke
#

I make drag but my icon always black

struct FStorageSlotDragDropOperation : public FDragDropOperation
{
    DRAG_DROP_OPERATOR_TYPE(FStorageSlotDragDropOperation, FDragDropOperation);

    FStorageSlotDragDropOperation(const FSlateBrush* DragIconBrush);
    using FDragDropOperation::Construct;
    virtual TSharedPtr<SWidget> GetDefaultDecorator() const override;

private:

    const FSlateBrush* OverrideIcon;
    const FSlateBrush* GetOverrideIcon() const { return OverrideIcon; }
};
#
FStorageSlotDragDropOperation::FStorageSlotDragDropOperation(const FSlateBrush* DragIconBrush)
{
    OverrideIcon = DragIconBrush;
}

TSharedPtr<SWidget> FStorageSlotDragDropOperation::GetDefaultDecorator() const
{
    return SNew(SBox)
            .WidthOverride(64)
        .HeightOverride(64)
        [
            SNew(SImage)
            .Image(this, &FStorageSlotDragDropOperation::GetOverrideIcon)
            .ColorAndOpacity(FSlateColor(FLinearColor::White))
        ];
}
#

FReply SStorageSlot::OnMouseButtonDown(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
{
    UE_LOG(LogTemp, Warning, TEXT("SStorageSlot::OnMouseButtonDown"));
    return FReply::Handled().DetectDrag(SharedThis(this), MouseEvent.GetEffectingButton());
}

FReply SStorageSlot::OnDragDetected(const FGeometry& Geometry, const FPointerEvent& MouseEvent)
{
    UE_LOG(LogTemp, Warning, TEXT("SStorageSlot::OnDragDetected"));
    FSlateBrush IconBrush;
    if (ItemObject.IsValid())
    {
        if (UTexture2D* IconTexture2D = ItemObject.Get()->ItemTexture.LoadSynchronous())
        {
            UE_LOG(LogTemp, Warning, TEXT("SStorageSlot::OnDragDetected: texture valid: %s"), *IconTexture2D->GetFName().ToString());
            IconBrush.SetResourceObject(IconTexture2D);
            IconTexture2D->bForceMiplevelsToBeResident = true;
            IconTexture2D->bIgnoreStreamingMipBias = true;
        }
    }

    TSharedPtr<FStorageSlotDragDropOperation> StorageSlotDragDropOperation = MakeShareable(new FStorageSlotDragDropOperation(&IconBrush));
    StorageSlotDragDropOperation->Construct();
    return FReply::Handled().BeginDragDrop(StorageSlotDragDropOperation.ToSharedRef());
}
grave hatch
#

You have to call FDragDropOperation::Construct manually

#

And, of course, your icon has to be valid.

slate spoke
#

it was default cursour

pure cave
#

I am trying to get a SListView working. My plan was to use IContentBrowserSingleton::GetSelectedAssets but the function populates the TArray<FAssetData> argument you provide and the SListView needs a TArray<TSharedPtr<FAssetData>> . Not sure how to go about it.

grave hatch
#

The issue you're going to face is that you should not create SharedPtrs to members of a tarray because if hte tarray reallocates, all your sharedptrs become invalid memory... without them knowing about it.

#

(probably)

#

You should have your own TArray<TSharedPtr<FAssetData>> array and populate it by iterating over the list and doing MakeShared<FAssetData>(array element)

#

Assuming fassetdata has a copy construtor, of course.

pure cave
#

Thank you 🥳 . I tried MakeShareable because the docs say MakeShareable is less efficient, but works even if the object's constructor is private, enables you to take ownership of an object you didn't create, and supports customized behaviour when deleting the object. so I thought it's more robust but it throws an error. MakeShared worked

#

Btw, you can ping me ipingchu

grave hatch
#

Yeah, I probably should of.

#

Just don't make a sharedptr to something that lives in a tarray. That will end in tears.

gray jolt
#

Good Morning! I'm attempting to extend unreal's FComponentReference struct and expand upon it so it is capable of working within the context of a CDO (as in the blueprint class editor and not in an instance of the actor in a ULevel/UWorld)

The hardest issue to surmount is that the component picker widget uses a scene outliner widget to gather a list of actor components for a developer/designer to choose from, but the scene outliner only works within the context of a UWorld.

I was hoping someone here could point me at a widget that I can use in place of the Scene Outliner that works within the context of an actor's CDO. I can ascertain which environment the property is in (UWorld or CDO) and select the right widget, so no need for the widget to be compatible with both contexts.

If it comes down to it I may have to duplicate the SceneOutliner and gut out the basic structure and populate it with custom logic. Hoping for something easier 🤞

grave hatch
#

Don't select the component, select its class and then get the cdo.

#

@gray jolt

#

Unless you need to filter it to just the cdos available from classes in your scene or something.

sharp zinc
#

Hi, I was looking to find out if it is somehow possible to get a comcrete UWidget / UUserWidget object from an SWidget that I have. Example:

{
    TSharedPtr<SWidget> SWidget = FSlateApplication::Get().GetKeyboardFocusedWidget();
    //SWidget->GetUserWidgetInstance() ?
        //UMGApplication.Get()->PleaseFindMeTheActualUserWidgetInstanceFromTheSWidget()?    
}```
grave hatch
#

Afaik nothing like that exists in the engine.

#

There are a few people who've written the code to do it, but there are no shortcuts like that.

#

Afaik you literally just have to iterate over the uwidgets/uuserwidgets until you find the one with the right slate widget.

sharp zinc
#

That's sad.

grave hatch
#

I don't use them, though, so maybe that's changed.

sharp zinc
#

So which ppl exactly managed to make it work? Is there a plugin or some little library for that ?

grave hatch
#

Just use for (UWidget* Widget : TObjectIterator<UWidget>) and check the uwidget's slate widget

#

Quite honestly as long as you don't do it a thousand times a tick, it isn't all that bad. It's just not ideal.

#

However

#

If the focused widget is part of a compound widget (e.g. it's a sub-widget of the actual uwidget's slate widget) that's not gonna work at all.

sharp zinc
#

Hmm...

#

Doing the check manually on the other hand is an overkill.

gray jolt
grave hatch
#

Oh.

#

At design time (within the bp editor) ?

gray jolt
#

Yes

grave hatch
#

You could use the construction script as a fallback.

#

Getting bp components isn't a simple matter of even accessing the actor's cdo.

#

They're all hidden away in construction script related stuff.

gray jolt
#

Pretty designer unfriendly, and also I'd like to prevent that sorry if boiler plate

grave hatch
#

Honestly, I'm not sure how it would even work from within the bp editor. Does the editor let you use details panel customisations to set default values?!

gray jolt
#

Are you familiar with the FComponentReference? It's basically everything I want, just I need to make it work when it's editing the class defaults in the blueprint editor.

grave hatch
#

Yeah, I know what it is. It's your one saving grace.

#

It doesn't mean the UI is going to play ball with you, though. 🙂

#

If it doesn't just work then you're kinda screwed, I think.

gray jolt
grave hatch
#

Ah well use that then!

gray jolt
#

One sec 😅

grave hatch
#

The issue is then creating a ui and enumerating the components!

gray jolt
#

Editing a FComponentReference typed property on an actor in a level

grave hatch
#

That's not what you want, though.

gray jolt
#

Editing a FComponentReference typed property on an component within the blueprint editor