Best Method of Setting Mesh Data?

I’m currently learning about compute shaders and mesh deformation and I’m wondering if there’s are better ways out there of setting mesh data on the cpu from the gpu.

Here is what I have :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;

[RequireComponent(typeof(MeshFilter))]
public class GPU_MeshDeform_Test : MonoBehaviour
{
    public ComputeShader meshDeformUnit;

	private MeshFilter meshFilter;
	private Mesh meshBase;
	private Mesh mesh;

	private GraphicsBuffer vertexBuffer;
	private CommandBuffer commandBuffer;

	private void Deform()
	{
		// Configure the vertex buffer for GPU access
		mesh.vertexBufferTarget |= GraphicsBuffer.Target.Raw;
		vertexBuffer = mesh.GetVertexBuffer(0);

		int vertexCount = vertexBuffer.count; 
		int stride = vertexBuffer.stride; // Assumes vector3 array (Position, etc.)
		int offset = mesh.GetVertexAttributeOffset(VertexAttribute.Position);

		// Initialize compute shader
		int kernel = meshDeformUnit.FindKernel("ShiftVertices");
		commandBuffer.SetComputeIntParam(meshDeformUnit, "STRIDE", stride);
		commandBuffer.SetComputeIntParam(meshDeformUnit, "OFFSET", offset);
		commandBuffer.SetComputeBufferParam(meshDeformUnit, kernel, "VertexBuffer", vertexBuffer);
		commandBuffer.DispatchCompute(meshDeformUnit, kernel, Mathf.CeilToInt(vertexCount / 64.0f), 1, 1);

		// Execute CommandBuffer
		Graphics.ExecuteCommandBuffer(commandBuffer);
		commandBuffer.Clear();


	byte[] rawData = new byte[vertexCount * stride];
	vertexBuffer.GetData(rawData);

Vector3[] vertices = new Vector3[vertexCount];
for (int i = 0; i < vertexCount; i++)
{
	int address = i*stride + offset;
	float x = System.BitConverter.ToSingle(rawData, address);
	float y = System.BitConverter.ToSingle(rawData, address + 4);
	float z = System.BitConverter.ToSingle(rawData, address + 8);
	vertices[i] = new Vector3(x, y, z);
}
mesh.SetVertices(vertices);


		foreach (Vector3 v in mesh.vertices)
			Debug.Log(v);
	}

	private void OnDestroy()
	{
		vertexBuffer?.Release();
		commandBuffer?.Release();
		Destroy(mesh);
		meshFilter.sharedMesh = meshBase;
	}

	void Start()
    {
		meshFilter = GetComponent<MeshFilter>();
		meshBase = meshFilter.sharedMesh;

		// create copy of base mesh
		mesh = Instantiate(meshBase);
		mesh.name = "Happy Deform Mesh";
		meshFilter.mesh = mesh;

		commandBuffer = new CommandBuffer { name = "Shift Vertices CommandBuffer" };

		//enact deform
		Deform();
	}
}
#pragma kernel ShiftVertices

// Buffer and stride information
RWByteAddressBuffer VertexBuffer;
uint STRIDE;
uint OFFSET;

[numthreads(64, 1, 1)]
void ShiftVertices(uint id : SV_DispatchThreadID)
{
    // Calculate the vertex index
    uint address = id * STRIDE + OFFSET;

    float3 position = asfloat(VertexBuffer.Load3(address));

    // Shift position to the right (along X-axis)
    float3 newposition = position;
    newposition.x += 1.0;

    // Write back modified position
    VertexBuffer.Store3(address, asuint(newposition));
}

Everything works, it’s a simple script that offsets vertices. I’m particularly interested in how I set the vertex data on the cpu side after I’ve ran the gpu data through a compute shader which is this part of the code :

byte[] rawData = new byte[vertexCount * stride];
vertexBuffer.GetData(rawData);

Vector3[] vertices = new Vector3[vertexCount];
for (int i = 0; i < vertexCount; i++)
{
	int address = i*stride + offset;
	float x = System.BitConverter.ToSingle(rawData, address);
	float y = System.BitConverter.ToSingle(rawData, address + 4);
	float z = System.BitConverter.ToSingle(rawData, address + 8);
	vertices[i] = new Vector3(x, y, z);
}
mesh.SetVertices(vertices);

This is only for the position data as that’s all I’m currently using, but there are many types of attributes. Will I have to handle each attribute specially or is there a way to update it all automatically?