maxVisibleCharacters change the already drawed letter is in mesh

So i’m making a text mesh editor for effects like Katana Zero. Everything was going well until i realise that the effects was only activating after all letters from the text was wrote.

I tried to store the modified value from the letters that already was drawed and reapling but i got a flick effect. I imagine that is happening because i’m overriding the mesh, but when it realeases a new character with “maxVisibleCharacters” the mesh updates to the normal text again.

Can someone help me on this? I’m strugglin by weeks now.

It’s a IJobParalllelFor that edits the mesh:

public void Execute(int vertexIdx)
{
  var charIdx = vertexIdx / 4;
  if(!applyToChars.Contains(charIdx)) return;
            
  var trueCharCount = GetTrueCharCount(charIdx);
  if(Delay(trueCharCount)) return;
            
  CheckNewCharacter(vertexIdx);
            
  actualVertexModified[vertexIdx] = true;
            
  var vecAngle = GetNewRotationAngle(vertexIdx);
  vertices[vertexIdx] = vecAngle;
}

Then on update after Job, store modified info:

localVertexIndices = memorySpaceForVertexIdx.ToList();
memorySpaceForVertexIdx.Dispose();
                        
var outVertices = nativeVertices.ToList();
for (int i = 0; i < removedVertices; i++) outVertices.Add(Vector3.zero);
localVertices = outVertices;
                        
textMesh.SetVertices(localVertices);
storeLocalVertices = true;

Then before starting a new Update Loop it restores:

if (storeLocalVertices) actualVertices = RestoreModifiedData(actualVertices);
var correctedVertices = actualVertices.RemoveAllValueInstances(Vector3.zero, out int removedVertices);
var nativeVertices = correctedVertices.ToNativeArray(Allocator.Persistent);

The restore function:

private List<Vector3> RestoreModifiedData(List<Vector3> correctedVertices)
{
  var outList = correctedVertices.Copy();
  for (int i = 0; i < localVertexIndices.Count; i++)
  {
     if (localVertexIndices[i]) outList[i] = localVertices[i];
  }

  return outList;
}

I really need to finish this till end of the month, Advanced thanks for those who can help me.
A video showing whats happening: https://youtu.be/D7VjCIFTc8w

1 Like