Hi, I made a simple Editor Utility Widget that copies sockets from one mesh asset to another. It seem to work fine but modified mesh fails to save. Does anybody know why? I am on version 5.6.1.
Thank you for your time ![]()
Hey @Lokstrel how are you?
It seems the problem is it doesnât automatically mark the asset as âdirtyâ (modified/unsaved), so the changes wonât be saved and wonât even show up in the list of files to save. The sockets are being added in memory correctly, but UE doesnât know it needs to save the changes.
To solve this, you can try by adding two nodes to your blueprint: âBegin Transactionâ and âEnd Transactionâ.
The first one should be added bewtween your âOn Clickedâ and the first âGetâ. And the second one needs to be connected to the âCompletedâ pin of your For Each Loop.
You donât need to add any value to the âBegin Transactionâ node, but you could add your mesh to its âPrimary Objectâ anyways.
Hope this helps you! Let me know if you need more help!
Hello, thank you for your answer. I hope you are having a nice day.
I added Begin Transaction and End Transaction nodes but the problem persists. Problem is not that Unreal does not try to save the asset, but it throws error when saving it (I probably should specified that in original post, sorry).
Here is the error message that I get:
When I add Sockets manually, asset saves without problems.
Hello again @Lokstrel !
Ohh ok ok, then itâs a completely different thing! haha
Could you share your log when you get that error? As that pop-up doesnât say anything really useful. Go to âWindowâ - âOutput Logâ and seach for the lines in red that appears when you click on âretryâ, and post them here!
Iâll be waiting for your answer!
I didnât find any red text in output log, but I found several warnings mentioning assets that I tried to save:
LogSavePackage: Warning: Referencers of StaticMeshSocket /Game/0_created_By_Me/General_Meshes/Pillar_01.Pillar_01:StaticMeshSocket_0:
LogSavePackage: Warning: StaticMesh /Game/0_created_By_Me/General_Meshes/Pillar_01.Pillar_01 (1 refs)
LogSavePackage: Warning: 0) ObjectProperty /Script/Engine.StaticMesh:Sockets.Sockets
LogSavePackage: Warning: StaticMesh /Game/0_created_By_Me/General_Meshes/Pillar_02.Pillar_02 (1 refs)
LogSavePackage: Warning: 0) ObjectProperty /Script/Engine.StaticMesh:Sockets.Sockets
Warning: Canât save â../../../../Unreal Projects/Arena_Game/Content/0_created_By_Me/General_Meshes/Pillar_02.uassetâ: Illegal reference to private object: âStaticMeshSocket /Game/0_created_By_Me/General_Meshes/Pillar_01.Pillar_01:StaticMeshSocket_0â referenced by âPillar_02â (at â/Game/0_created_By_Me/General_Meshes/Pillar_02â) in its âSocketsâ property.
Hope it helps.
Hello again!
Iâve been trying to solve this issue and I did it! The only caviat is that you will need to implement some C++ code to be able to do it, but lets start with the blueprints part first!
Your approach is mostly correct! The only problem with it is that you are assigning a reference to a socket that belongs to a different âpackageâ (your first static mesh) instead of creating a new socket. So we will change some parts of the bleuprint first.
- The first part, until the for each loop included, will be exactly the same!
- In the loop, instead of adding the socket to the new mesh, you will need to duplicate the socket:
- immediately after that, you will need to add the node âBegin Transactionâ with your target mesh as its âprimary objectâ:
This node will tell that asset that it has been modified (mark it as âdirtyâ), so the engine will let you know you need to save it. - The next step is the one that needs a C++ implementation to work, as you CANNOT cast to âStatic Mesh Socketâ natively in Unreal Engine. But first let me show the complete blueprint:
The green node is a custom function you will need to create using C++, and âEnd Transactionâ is to close the transaction you started in the previous step. As you can see, you are adding the new Socket to your Mesh, instead of adding a reference to your first meshâs socket.
And thatâs it for the BP. Lets do the C++ part!
- First of all, you need to go to âtoolsâ in your Engine window and click on âNew C++ ClassâŚâ:
- On the next window, click on âAll Classesâ and search for âBlueprintFunctionLibraryâ, then click on âNextâ:
- Name your function library something like âSocketCopyFunctionLibraryâ and you will see it will create a âsourceâ folder in your project if you donât have it already. Click on âcreate classâ:
After that, you will get some warnings. Click âokâ, then click ânoâ, and close the engine. - Now, in your project folder, you will see a new file with â.slnâ extension. You need to open it with Visual Studio or any IDE you like.
- Navigate your project until you can open both new files (In my case, both of them are called SocketCopyFunctionLibrary.h and SocketCopyFunctionLibrary.cpp). This is how it looks in my Visual Studio:
- In your â.hâ paste this:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SocketCopyFunctionLibrary.generated.h"
class UStaticMeshSocket;
/**
*
*/
UCLASS()
class ANIMATIONSHARING573_API USocketCopyFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, BlueprintPure)
static UStaticMeshSocket* CastToStaticMeshSocket(UObject* Object);
};
- Then paste this in your â.cppâ:
// Fill out your copyright notice in the Description page of Project Settings.
#include "SocketCopyFunctionLibrary.h"
#include "Engine/StaticMeshSocket.h"
UStaticMeshSocket* USocketCopyFunctionLibrary::CastToStaticMeshSocket(UObject* Object)
{
return Cast<UStaticMeshSocket>(Object);
}
- The final step is to compile the project! To do it with Visual Studio, make sure you have âDevelopmentâ selected and then click on play âLocal Windows Debuggerâ. This will compile and open the editor again:
After doing that, you will be able to use the green node âCast to Static Mesh Socketâ in your blueprint and your Editor Utility will create copies of all the required sockets, then it will add them to the new mesh!
Once you do this, you will be able to open the project from the launcher or .uproject file as you always do, as you donât need to compile more C++ code.
Hope this helps you! Let me know if you need more help!
It Works! Thank you so much!
That detailed guide really helped. I couldnât do it without it.











