HomeGuidesLearn about the Immerse SDK installerLog In

Priority Comparer


This feature requires the Immerse SDK Enterprise Edition

This is different to the free Immerse SDK. Contact [email protected] if you require access.

Understand the difference between the Free and Enterprise SDK

This is an 'advanced' feature for when you need to order the camera target list using some custom logic.

The default implementation of the Priority Comparer will order Camera Targets by their Priority value. In the case where the Interaction Package is included in the project and Avatar Camera Targets are available, these will always be first in the list. If two or more Camera Targets have the same Priority value, they will be placed in alphabetical order.

To override the behaviour, create a new class that inherits the IComparer<CameraTarget> interface. More information on writing this class can be found here. Once you have created this class, the comparer must be set at runtime by calling ImmerseSDK.SpectatorCamera.CameraTargetList.SetComparer.


using System;
using System.Collections.Generic;
using ImmerseSDK.SpectatorCamera;
using UnityEngine;

public class PriorityOverride : MonoBehaviour
    private void Start()
        // Override comparer on Start
        CameraTargetList.SetComparer(new AlphabeticalComparer());

    /// <summary>
    /// Compares camera target names only
    /// </summary>
    private class AlphabeticalComparer : IComparer<CameraTarget>
        public int Compare(CameraTarget x, CameraTarget y)
            return string.Compare(x.Name, y.Name, StringComparison.InvariantCulture);