# Can UStaticMesh.bAllowCPUAccess be set in C++ code on runtime?

**URL:** <https://forums.unrealengine.com/t/can-ustaticmesh-ballowcpuaccess-be-set-in-c-code-on-runtime/377983>\
**Category:** Platform & Builds\
**Tags:** unreal-engine, procedural-mesh, staticmesh, question\
**Created:** [December 1, 2016, 5:31am UTC](https://forums.unrealengine.com/t/can-ustaticmesh-ballowcpuaccess-be-set-in-c-code-on-runtime/377983 "2016-12-01T05:31:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![UlyssesWu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UlyssesWu](https://forums.unrealengine.com/u/UlyssesWu)\
**Post date:** [December 1, 2016, 5:31am UTC](https://forums.unrealengine.com/t/can-ustaticmesh-ballowcpuaccess-be-set-in-c-code-on-runtime/377983/1 "2016-12-01T05:31:17Z")

</div>

I’m using the new mesh slice feature. I got a lot of StaticMesh which `bAllowCPUAccess` is not set.  
After I cooked the release build, the game crashed at

```
MyGame!UKismetProceduralMeshLibrary::GetSectionFromStaticMesh()
MyGame!UKismetProceduralMeshLibrary::CopyProceduralMeshFromStaticMeshComponent()

```

I tried to set bAllowCPUAccess in code:

```
staticMesh->bAllowCPUAccess = true;

```

This line is correct in syntax, but the game still crashed at the same line.

So the question is:

Since I don’t want to set all of meshes’ `bAllowCPUAccess` manually (it’s boring, and I’m worry about it may slow down the game?),

is there a way to let me use `CopyProceduralMeshFromStaticMeshComponent` with static meshes’ `bAllowCPUAccess` not set before build (e.g. copy and create a new StaticMesh which `bAllowCPUAccess` is set when creating), or I can only set bAllowCPUAccess in Editor before build? If so, why `bAllowCPUAccess` is settable in code ( `staticMesh->bAllowCPUAccess = true;` ) ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Infamous.Red1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/infamous.red1/32/903221_2.png) [@Infamous.Red1](https://forums.unrealengine.com/u/Infamous.Red1)\
**Post date:** [April 24, 2024, 10:14am UTC](https://forums.unrealengine.com/t/can-ustaticmesh-ballowcpuaccess-be-set-in-c-code-on-runtime/377983/2 "2024-04-24T10:14:43Z")

</div>

Hey man, Even i am stuck at this issue.  
I learned one trick recently, since i have to enable cpu access for around 1800 assets :

1. In any blueprint call a small cpp method which just enables the cpu access for the provided mesh in runtime.
2. Drop all your target assets (on the one you want CPU access), and you could pass these assets in a loop(or anyhow) and call the above mentioned method. This does the job in the editor and does enable the bool on those meshes.
3. Remember to not include this method in your shipping builds/ core game logic.

If you have any better solutions please put it out here.  
I tired this on 5.1.1  
I even tried to add staticMesh-\>bAllowCPUAccess = true; in a shipping build, and it crashed!!
