# Changing color of meshing subsystem renderer only changes part of mesh

**URL:** <https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245>\
**Category:** Unity Development\
**Created:** [March 4, 2024, 6:15am UTC](https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245 "2024-03-04T06:15:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paklnet](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@paklnet](https://forum.magicleap.cloud/u/paklnet)\
**Post date:** [March 4, 2024, 6:15am UTC](https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245/1 "2024-03-04T06:15:01Z")

</div>

I am trying to have the meshing subsystem mesh toggle between being transparent and not transparent with the menu button . However I find that only _some_ of the mesh is getting changed. Most of the mesh remains in the original color/opacity. It's as if multiple instances of the Mesh Prefab are being created and used...? Any suggestions on how to change all of the mesh? Thank you.

Here's my code to toggle the mesh opacity:

```auto
    private void HandleOnMenu(InputAction.CallbackContext obj)
    {
        Renderer r = meshController.GetComponent<MeshingSubsystemComponent>().meshPrefab.GetComponent<Renderer>();
        if (r.material.color.a == 0.0f) {
            r.material.color = new Color(1,1,1, 2.0f/255.0f);
        } else {
            r.material.color = new Color(1,1,1, 0.0f);
        }
    }

```

**Unity Editor version** : 2022.3.12f1  
**ML2 OS version** : 1.4.1  
**Unity SDK version** : 1.12.1  
**Host OS** : MacOS

---

<div class="post-metadata">

**Author:** ![sfernandez](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/sfernandez/32/747_2.png) [@sfernandez](https://forum.magicleap.cloud/u/sfernandez)\
**Post date:** [March 4, 2024, 10:28pm UTC](https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245/2 "2024-03-04T22:28:34Z")

</div>

Hi @paklnet  
you could try using

> r.sharedMaterial.color

instead if you want to effect all objects using that material  
-Sidney

---

<div class="post-metadata">

**Author:** ![paklnet](https://avatars.discourse-cdn.com/v4/letter/p/b782af/32.png) [@paklnet](https://forum.magicleap.cloud/u/paklnet)\
**Post date:** [March 5, 2024, 7:42am UTC](https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245/3 "2024-03-05T07:42:04Z")

</div>

That worked perfectly. Thank you

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [March 20, 2024, 7:42am UTC](https://forum.magicleap.cloud/t/changing-color-of-meshing-subsystem-renderer-only-changes-part-of-mesh/3245/4 "2024-03-20T07:42:38Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
