# Meshing Example

**URL:** <https://forum.magicleap.cloud/t/meshing-example/2219>\
**Category:** Unity Development\
**Created:** [July 17, 2023, 6:27pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219 "2023-07-17T18:27:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ineedhelpty](https://avatars.discourse-cdn.com/v4/letter/i/50afbb/32.png) [@ineedhelpty](https://forum.magicleap.cloud/u/ineedhelpty)\
**Post date:** [July 17, 2023, 6:27pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/1 "2023-07-17T18:27:48Z")

</div>

Give us as much detail as possible regarding the issue you're experiencing.

**Unity Editor version** : 2022.2.0f1  
**ML2 OS version** : 1.3.0 dev2 (secure)  
**MLSDK version** : 1.3.0 dev2  
**Host OS** : Windows

**Error messages from logs** (syntax-highlighting is supported via Markdown): I have a question about this example. How can I remove all the other functions other than the occlusion? Can I just simply delete the "MeshingVisualizer" and "MeshingSubsystemComponent"? And also deleted other render mode and shooting prefab in the "MeshingExample" script?

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [July 17, 2023, 9:53pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/2 "2023-07-17T21:53:21Z")

</div>

Hi @ineedhelpty,

The mode switching functionality can be found in `MeshingVisualizer.cs`

```auto
public void SetRenderers(RenderMode mode)
        {
            if (renderMode != mode)
            {
                // Set the render mode.
                renderMode = mode;

                _meshingSubsystemComponent.requestedMeshType = (renderMode == RenderMode.PointCloud) ? 
                    MeshingSubsystemComponent.MeshType.PointCloud : 
                    MeshingSubsystemComponent.MeshType.Triangles;

                switch (renderMode)
                {
                    case RenderMode.None:
                        break;
                    case RenderMode.Wireframe:
                        _meshingSubsystemComponent.PrefabRenderer.sharedMaterial = _wireframeMaterial;
                        break;
                    case RenderMode.Colored:
                        _meshingSubsystemComponent.PrefabRenderer.sharedMaterial = _coloredMaterial;
                        break;
                    case RenderMode.PointCloud:
                        _meshingSubsystemComponent.PrefabRenderer.sharedMaterial = _pointCloudMaterial;
                        break;
                    case RenderMode.Occlusion:
                        _meshingSubsystemComponent.PrefabRenderer.sharedMaterial = _occlusionMaterial;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException($"unknown renderMode value: {renderMode}");
                }

                _meshingSubsystemComponent.DestroyAllMeshes();
                _meshingSubsystemComponent.RefreshAllMeshes();
            }
        }

```

If you delete the `MeshingSubsytemComponent`, the example will not work.

Best,

El

---

<div class="post-metadata">

**Author:** ![ineedhelpty](https://avatars.discourse-cdn.com/v4/letter/i/50afbb/32.png) [@ineedhelpty](https://forum.magicleap.cloud/u/ineedhelpty)\
**Post date:** [July 18, 2023, 2:13pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/3 "2023-07-18T14:13:38Z")

</div>

Hi, thanks for the response. Can I delete "MeshTexturedWireframeAdapter" if I'm not using the wireframe render mode?

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [July 18, 2023, 3:40pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/4 "2023-07-18T15:40:21Z")

</div>

For this, I recommend creating a git repository and making changes that can be reverted to a previous state so you can edit the project with peace of mind.

> **[How to Create a Git Repository | Atlassian Git Tutorial](https://www.atlassian.com/git/tutorials/setting-up-a-repository)**
>
> Set up a git repository: git init creates a new repo, git clone copies an existing repo, git config configures your Git installation from the command line

[https://git-scm.com/book/en/v2/Getting-Started-Installing-Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

---

<div class="post-metadata">

**Author:** ![etucker](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/etucker/32/842_2.png) [@etucker](https://forum.magicleap.cloud/u/etucker)\
**Post date:** [July 18, 2023, 3:56pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/5 "2023-07-18T15:56:54Z")

</div>

> [@ineedhelpty](#):
>
> Hi, thanks for the response. Can I delete "MeshTexturedWireframeAdapter"

To answer your question, yes you can delete this component and it will still work as long as you don't use the wireframe material.

---

<div class="post-metadata">

**Author:** ![ineedhelpty](https://avatars.discourse-cdn.com/v4/letter/i/50afbb/32.png) [@ineedhelpty](https://forum.magicleap.cloud/u/ineedhelpty)\
**Post date:** [July 18, 2023, 9:05pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/6 "2023-07-18T21:05:30Z")

</div>

Hi @etucker The occlusion stopped working after I disabled "MeshTexturedWireframeAdapter" in the inspector. Do you know if there is any reason causing this problem? Thanks

---

<div class="post-metadata">

**Author:** ![ineedhelpty](https://avatars.discourse-cdn.com/v4/letter/i/50afbb/32.png) [@ineedhelpty](https://forum.magicleap.cloud/u/ineedhelpty)\
**Post date:** [July 18, 2023, 9:29pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/7 "2023-07-18T21:29:36Z")

</div>

@etucker This is a separate question from the previous one. In 'MeshingVisualizer', I saw the default mode is Wireframe.  
With nothing else changed, I tried to set the default mode as occlusion but occlusion stopped working.  
My only change is:  
"

```auto
public RenderMode renderMode
        {
            get; private set;
        } = RenderMode.Occlusion;

```

Blockquote

---

<div class="post-metadata">

**Author:** ![kbabilinski](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.magicleap.cloud/kbabilinski/32/19_2.png) [@kbabilinski](https://forum.magicleap.cloud/u/kbabilinski)\
**Post date:** [July 19, 2023, 12:07am UTC](https://forum.magicleap.cloud/t/meshing-example/2219/8 "2023-07-19T00:07:44Z")

</div>

Hi @ineedhelpty

You do not need the Wireframe adapter to have the meshing display the occlusion material. Additionally, Please see the Meshing example in the Magic Leap Unity Example's project to learn how to set the render mode and materials.

See MeshingVisualizer.cs to learn how the material is applied and the MeshingExample.cs script to see how to set the render mode.

---

<div class="post-metadata">

**Author:** ![ineedhelpty](https://avatars.discourse-cdn.com/v4/letter/i/50afbb/32.png) [@ineedhelpty](https://forum.magicleap.cloud/u/ineedhelpty)\
**Post date:** [July 19, 2023, 6:58pm UTC](https://forum.magicleap.cloud/t/meshing-example/2219/9 "2023-07-19T18:58:43Z")

</div>

Thank you. I realized I need to change the mesh prefab in `MeshingSubsytemComponent`
