Created
March 14, 2025 22:55
-
-
Save DanMillerDev/7cdbf84bef22eb0288862b30cccb9424 to your computer and use it in GitHub Desktop.
A script for updating a logo based on platforms by checking the AR Session descriptor ID, useful when building from generic build platforms like Android and supported multiple android-based headsets like Meta Quest and Android XR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using UnityEngine.XR.ARFoundation; | |
public class LogoManager : MonoBehaviour | |
{ | |
[SerializeField] | |
Sprite MetaLogo; | |
[SerializeField] | |
Sprite AndroidLogo; | |
[SerializeField] | |
Sprite AppleLogo; | |
[SerializeField] | |
Sprite UnknownLogo; | |
[SerializeField] | |
Image m_UIImage; | |
[SerializeField] private ARSession m_ARSession; | |
const string k_MetaSessionName = "Meta-Session"; | |
const string k_AndroidSessionName = "Android-Session"; | |
const string k_VisionOSSessionName = "VisionOS-Session"; | |
void Start() | |
{ | |
// We switch on Session Descriptor id because we can't guarantee with current preprocessor directives whether | |
// a provider package (and its types) will be present. For example, UNITY_ANDROID could signal that either | |
// ARCore or OpenXR loader is present. Because we don't know for sure, we are unable to switch on the loader | |
// type without introducing a build-time error in case that package was stripped. | |
switch (m_ARSession.descriptor.id) | |
{ | |
case k_MetaSessionName: | |
m_UIImage.sprite = MetaLogo; | |
break; | |
case k_AndroidSessionName: | |
m_UIImage.sprite = AndroidLogo; | |
break; | |
case k_VisionOSSessionName: | |
m_UIImage.sprite = AppleLogo; | |
break; | |
default: | |
m_UIImage.sprite = UnknownLogo; | |
break; | |
} | |
m_UIImage.sprite = UnknownLogo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment