# Pixel Sensor API Example

**URL:** <https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031>\
**Category:** Unity Development\
**Tags:** pixel-sensor\
**Created:** [January 17, 2025, 7:35pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031 "2025-01-17T19:35:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![inz.ece](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@inz.ece](https://forum.magicleap.cloud/u/inz.ece)\
**Post date:** [January 17, 2025, 7:35pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/1 "2025-01-17T19:35:28Z")

</div>

> **[World Camera Example | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/pixel-sensor/world-camera-example/#custom-configuration-example)**
>
> This section includes examples on how to configure the World Camera Pixel Sensor and display it's data.

Is there a unity scene that I can download to test the world camera example? I couldn't get it to render on my Quad, Mesh renderer to stream correctly.

---

<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:** [January 20, 2025, 2:59pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/2 "2025-01-20T14:59:42Z")

</div>

Have you taken a look at the latest version of the Unity Example Project? They have a Pixel Sensor Example.

Looking at the logs on the device is also helpful to determine bugs. You can use the ML Hub or Unity's Logcat package. You can also test that example script inside the Example Project and see if it works in the pre-configured project.

---

<div class="post-metadata">

**Author:** ![inz.ece](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@inz.ece](https://forum.magicleap.cloud/u/inz.ece)\
**Post date:** [January 20, 2025, 6:05pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/3 "2025-01-20T18:05:28Z")

</div>

Yeah, it managed to load the default configurations, but let's say I want to visualize with different exposure level - I'm struggling to load the config

---

<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:** [January 20, 2025, 6:24pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/4 "2025-01-20T18:24:10Z")

</div>

Understood, so what errors are you getting when running the following example script:

> **[World Camera Example | MagicLeap Developer Documentation](https://developer-docs.magicleap.cloud/docs/guides/unity-openxr/pixel-sensor/world-camera-example/#custom-configuration-example)**
>
> This section includes examples on how to configure the World Camera Pixel Sensor and display it's data.

---

<div class="post-metadata">

**Author:** ![inz.ece](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@inz.ece](https://forum.magicleap.cloud/u/inz.ece)\
**Post date:** [January 20, 2025, 11:12pm UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/5 "2025-01-20T23:12:33Z")

</div>

Trying to fetch sensor...

---

<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:** [January 21, 2025, 3:01am UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/6 "2025-01-21T03:01:24Z")

</div>

Oh no, it looks like there was a typo when the page was being updated. Please add

`TryInitializeSensor();` at the bottom of the `InitializePixelSensorFeature` function.

```csharp
    private void InitializePixelSensorFeature()
    {
        pixelSensorFeature = OpenXRSettings.Instance.GetFeature<MagicLeapPixelSensorFeature>();
        if (pixelSensorFeature == null || !pixelSensorFeature.enabled)
        {
            enabled = false;
            Debug.LogError("Pixel Sensor Feature Not Found!");
            return;
        }

        //Find pixel with the specified name.
        cachedSensorId = FindSensor(pixelSensorName);

        // Subscribe to sensor availability changes
        pixelSensorFeature.OnSensorAvailabilityChanged += OnSensorAvailabilityChanged;

// Call this function at the end.
        TryInitializeSensor();
    }

```

---

<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:** [February 4, 2025, 3:01am UTC](https://forum.magicleap.cloud/t/pixel-sensor-api-example/5031/7 "2025-02-04T03:01:52Z")

</div>

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