I met a problem in build a blueprint tool. I m trying to use blueprint to batch processing static mesh vertex colors with blueprint tools. I wrote a C++ blueprint function which use a static object as input and delete its vertex color, but looks like the changes were not saved .
here is my function :
...
for (FStaticMeshLODResources& LODResource : RenderData->LODResources)
{
if (LODResource.bHasColorVertexData)
{
LODResource.VertexBuffers.ColorVertexBuffer.ReleaseResource();
LODResource.VertexBuffers.ColorVertexBuffer.CleanUp();
LODResource.bHasColorVertexData = false;
}
}
StaticMesh->PostEditChange();
StaticMesh->MarkPackageDirty();
...
log shows the function works but when I open the vertex color editor, the vertex color data still shows on my static mesh.
I met a problem in build a blueprint tool. I m trying to use blueprint to batch processing static mesh vertex colors with blueprint tools. I wrote a C++ blueprint function which use a static object as input and delete its vertex color, but looks like the changes were not saved .
here is my function :
...
for (FStaticMeshLODResources& LODResource : RenderData->LODResources)
{
if (LODResource.bHasColorVertexData)
{
LODResource.VertexBuffers.ColorVertexBuffer.ReleaseResource();
LODResource.VertexBuffers.ColorVertexBuffer.CleanUp();
LODResource.bHasColorVertexData = false;
}
}
StaticMesh->PostEditChange();
StaticMesh->MarkPackageDirty();
...
log shows the function works but when I open the vertex color editor, the vertex color data still shows on my static mesh.
Share Improve this question asked Mar 22 at 3:22 YouanYouan 111 silver badge3 bronze badges 1 |1 Answer
Reset to default 2If you want to save the asset after you've made changes to it, you need to explicitly save it.
Call UEditorAssetLibrary::SaveLoadedAsset
to save it:
/**
* Save the packages the assets live in. All objects that live in the package will be saved. Will try to checkout the file.
* @param AssetToSave Asset that we want to save.
* @param bOnlyIfIsDirty Only checkout asset that are dirty.
* @return True if the operation succeeds.
*/
UFUNCTION(BlueprintCallable, Category = "Editor Scripting | Asset")
static bool SaveLoadedAsset(UObject* AssetToSave, bool bOnlyIfIsDirty = true);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744325893a4568645.html
StaticMesh->RemoveVertexColors();
– Youan Commented Mar 25 at 7:07