c++ - How to use BP to delete vertex color of a static mesh asset in UE5 - Stack Overflow

I met a problem in build a blueprint tool.I m trying to use blueprint to batch processing 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.

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
  • It works by using api StaticMesh->RemoveVertexColors(); – Youan Commented Mar 25 at 7:07
Add a comment  | 

1 Answer 1

Reset to default 2

If 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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信