SMeshWidget - Hardware Instanced Slate Meshes Thread

Is there any way to find out which instance is being hovered by the mouse?

No, these widgets don’t support any kind of interaction like that so you’d have to build a system in yourself.

Yeah thought so :confused: Thanks anyways!

Hi! I confirmed that Nick’s sample works on UE 4.18 by adding the following changes.

MeshWidgetExample.Build.cs (Update to new format from UE 4.16)



public class MeshWidgetExample : ModuleRules
{
    public MeshWidgetExample(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

        PublicDependencyModuleNames.AddRange(new string] { "Core", "CoreUObject", "Engine", "InputCore", "SlateCore", "Slate", "UMG" });
    }
}


MeshWidgetExample.Target.cs (Update to new format from UE 4.16)



public class MeshWidgetExampleTarget : TargetRules
{
    public MeshWidgetExampleTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Game;

        ExtraModuleNames.AddRange( new string] { "MeshWidgetExample" } );
    }
}


MeshWidgetExampleEditor.Target.cs (Update to new format from UE 4.16)



public class MeshWidgetExampleEditorTarget : TargetRules
{
    public MeshWidgetExampleEditorTarget(TargetInfo Target) : base(Target)
    {
        Type = TargetType.Editor;

        ExtraModuleNames.AddRange( new string] { "MeshWidgetExample" } );
    }
}


MeshWidgetExampleCharacter.cpp (Fixed order of include)



#include "MeshWidgetExampleCharacter.h"
#include "MeshWidgetExample.h"
​​​​​​​

MeshWidgetExampleGameMode.cpp (Fixed order of include)



#include "MeshWidgetExampleGameMode.h"
#include "MeshWidgetExample.h"
#include "MeshWidgetExamplePlayerController.h"
#include "MeshWidgetExampleCharacter.h"
​​​​​​​

MeshWidgetExamplePlayerController.cpp (Fixed order of include)



#include "MeshWidgetExamplePlayerController.h"
#include "MeshWidgetExample.h"
#include "AI/Navigation/NavigationSystem.h"
​​​​​​​

ParticleWidget.cpp (Fixed order of include)



#include "ParticleWidget.h"
#include "MeshWidgetExample.h"
#include "Slate/SMeshWidget.h"
#include "Slate/SlateVectorArtInstanceData.h"
​​​​​​​

ParticleWidget (Fixed lack of include)



#include "Slate/SlateVectorArtData.h"
#include "Widget.h"
#include "ParticleWidget.generated.h"
​​​​​​​

Thanks Nick!

Can you post your code? I’m curious to see how you get your healthbar working… I want to do something similar and would be great if you can share your code…

Hi man,
I got your logic, but I have one confusion.
When your player hits the enemy, their health drops so how are you telling the material to update the health bar.



**FSlateVectorArtInstanceData ParticleData;

ParticleData.SetPosition(Some Position);

ParticleData.SetScale(Some Scale);**

**FSlateInstanceBufferUpdate::CommitUpdate(PerInstaceUpdate);**


Are you using above line of code to send update to the material.
And are you sending packed the byte data in the above statement only and then in material your are unpacking.

I got it, actually onPaint is getting called every frame, I just need to put the logic in that function only and it will wok.
Thanks for the wonderful resource.

fingers crossed, I updated the project to 4.25 GitHub - dantreble/MeshWidgetExample: Nick Darnell's example project from https://forums.unrealeng

1 Like

Hey,I used your code in ue426 and sucessfully send the renderdata to SMeshWidget::OnPaint() but still nothing have been drawn.Do you have any idea where should i check for?

Hey,Darnell**.**I just figure out how to make this work.And It looks like you send position and scale info into vertex attribute which seems to be a bit costly.So is there a reason why use uniform buffer instead?

----edit----
Don’t notice that is a per instance attribute.

I would like to elaborate.
I modified the material a little bit to include the texture:


But as a result I get this:

Not sure why it does blend the colors of the texture, though…

Hey guys! That’s actually so useful. I managed to implement the logic.
But what I am failing to do is to apply a custom texture to a mesh in NickDarnell’s example.
I just don’t see it in the rendered mesh particle. What could I be missing?

Ok, I figured out what the problem is. In MeshWidgetExample, the plane mesh does not have a proper UV mapping. Once you add it, everything works fine. That’s the only problem.