Error: Unity Not Allowed to Access Vertices on Mesh

What's Causing This Error

The error "Unity not allowed to access vertices on a mesh" is typically caused by one of two reasons:

  1. Immutable Meshes: By default, in Unity, you cannot change mesh data (like vertices) that come from 'imported' models, such as FBX files or models dragged into the Scene from the Assets folder. The meshes of these models are considered immutable for performance reasons.

  2. Read/Write Enabled Property: Another common cause is that the Read/Write Enabled property might be disabled in the import settings of your model. Unity requires this setting to be enabled to allow scripts to read or write the mesh data.

Solution - Here's How To Resolve It

To resolve this issue, you can follow these steps:

  1. Create a Copy of the Mesh: If you need to modify an imported mesh, you should first create a copy of it in memory using Instantiate(). After creating the copy, you can manipulate the mesh data without restrictions.

    Mesh meshCopy = Instantiate(originalMesh); // Now you can change meshCopy’s vertex data
  2. Enable Read/Write: If the problem is related to the Read/Write Enabled property, ensure it's enabled for your mesh. In the Inspector tab, select your model and navigate to Model > Import Settings > Advanced > Read/Write Enabled. Check this box to enable the property. Keep in mind that enabling this option may increase memory usage.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.