SNew no operator "<<=" matches these operands

I have compile error trying to assign SLATE_ARGUMENT… I don’t know what to do, I am following the documentation but I cant find why I get this error. Here is my code;

class SParticleMeshWidget : public SMeshWidget
{
public:
	SLATE_BEGIN_ARGS(SParticleMeshWidget)
		: _MeshData()
	{ }
	SLATE_ARGUMENT(USlateVectorArtData*, MeshData)
	SLATE_END_ARGS()

public:
	void Construct(const FArguments& Args, UHealthBarMeshWidget& InThis)
	{
		This = &InThis;
        SNew(SParticleMeshWidget).MeshData(This->MeshVectorArtData); <----Error Here!
    }

Sorry to say that but i think you have no idea what you doing, i don’t know why you got error and what document you follow but i can see other serious issues i see that makes that error meaningless.

What you doing is actually creating a infinite loop, use SNew to create SParticleMeshWidget inside it self which would construct inside it self which would again construct it self and again and again until memory runs out… but since SMeshWidget is not compound widget (SCompoundWidget) you can’t even construct this widget out of other widget so it would not even work. Also note that SNew does not create widget it self it just constructs information about widget which will be used for construction, so you can’t just put it in middle of nowhere and expect that something will apper on the screen, it usually need to be send to Slate system one way or another which will place widget in widget tree. Normally SCompoundWidget contains ChildSlot variable that you set in Constructor with widgets you want to contain, but widget you trying to override was not made for that.

SMeshWidget is leaf widget (SLeafWidget) which is which is lowest level of Slate widget and don’t contain slots for other stale widgets it only renders widget with OnPaint function, and since you overriding existing leaf widget there really no reason to change constructor or else you really need to do some extra initial setting.

So you should start by investigating SMeshWidget code first and see what it does:

https://github.com/EpicGames/UnrealEngine/blob/08ee319f80ef47dbf0988e14b546b65214838ec4/Engine/Source/Runtime/UMG/Private/Slate/SMeshWidget.cpp
https://github.com/EpicGames/UnrealEngine/blob/08ee319f80ef47dbf0988e14b546b65214838ec4/Engine/Source/Runtime/UMG/Public/Slate/SMeshWidget.h

And as you look at it think what you need to modify, most crytical point is OnPaint which has main code of rendering MeshWidget and any modification of SMeshWidget behavior will land primerly there

Other huge issue i can see is your attempt to use UMG inside Slate code and even change “this” that may mess up function calling, this is something i never seen done (which makes me interested what document you working with here). Only reason why UMG exist is to make Slate work with Blueprints because Slate classes don’t exist in UObject hierarchy so it hard to hook them in to blueprints, insted wrapper system was made called UMG which contains UObject classes that controls the slate widgets and it makes them display on viewport out of the box. So Slate classes should be independent from UMG, insted you should make UMG class that controls your UMG widget (or composition of slate widgets which imo is superior way of using UMG then just overriding UUserWidget).

I don’t know what is your intention, if you don’t want to alter rendering of SMeshWidget and just use SMeshWidget in UMG then either:

1.Make SCompoundWidget and make UMG widget out of it

2.Just make UMG widget that constructs SMeshWidget

Option 2 is better as UMG widget class itself practically have similar function to SCompoundWidget, option 1 is only good if you plan to reuse the widget directly in Slate, which i don’t think is think you planing to do.

Also study Slate more since you clearly lacking knowledge on it i think you got yourself to too deep waters of it, study both Slate widget code in engine (Everything you see in editor is Slate so there countless examples in editor code, use Widget Reflector to check name of widget in editor) and check how UMG widgets are constructed and how they manage Slate widgets, those are contained in Componets folder in UMG module:

https://github.com/EpicGames/UnrealEngine/tree/08ee319f80ef47dbf0988e14b546b65214838ec4/Engine/Source/Runtime/UMG/Private/Components

Blockquote Sorry to say that but i think you have no idea what you doing
I know that I have much more to learn before understanding c++ correctly, The part of SLATE_ARGUMENT is a bit miss understood, this is the documentation I was following;

SlateHello

This doc is a mess, The text structure is mixed with description and codes so hard to understand.

Blockquote Also note that SNew does not create widget it self it just constructs information about widget which will be used for construction, so you can’t just put it in middle of nowhere and expect that something will apper on the screen

This is what iv read about SNew and this is what I was trying to do. _MeshData was NULL so I taught to set the USlateVectorArtData MeshData using SNew because my issue seems to come from the initialization of the variable during construction of the widget itself. Now I understand that I was probably wrong.

The code I’m working with come from Nick Darnell Unreal Engine Developper so I don’t think that this code will teach me wrong informations. So If I understand correctly from your 2 options, this project is option 2… Its a UWidget that constructs SMeshWidget and this is what I want to get done…

The code seems to work as intended, but in certain circumstance like if you use it as 3D Widget and you compile the widget and you save the project the widget disappear leaving warnings in the engine log. This post is also miss leading according what you said; Manipulating Slate content during and after Construct()
Thanks for taking your time to answer. I will look deeper in the engine code to learn things.

Thanks a lot! that was exactly it! Hot Reload was causing me problems. I spend almost 4 days trying to figured out what is going on… you saved my time… much appreciated!

The question you point out does not have anything to do with issues i point out, note that in there examples they making SMyWidget which seams to based from widget that can contain something and them using SImage in it a diffrent widgets, what you doing is SParticleMeshWidget widget out of SMeshWidget which is not made to contain other widgets and then you trying to construct SParticleMeshWidget inside it which creates the loop… but it does not matter because you doing it wrong anyway.

Also note this was 2014 before UMG was implemented, now there other option of just making UWidget and construct and manipulate Slate widget in there insted of making another compound widget as they did in that question and then do UMG widget out of it, that is ofcorse if you don’t plan to alter code of SMeshWidget otherwise you need to indeed override SMeshWidget.

But on topic at hand “The code seems to work as intended, but in certain circumstance like if you use it as 3D Widget and you compile the widget and you save the project the widget disappear leaving warnings in the engine log”, do you compile with hot reload? hot reload have tendency to be buggy and mess ups the reflection system which may cause save issues as you described. Can you try to compile without editor open? Also what do you hook up to brush and how? as issue might be related to that.

raport bug then ;]