Skip to content

Instantly share code, notes, and snippets.

@DanMillerDev
DanMillerDev / LogoManagerPPD.cs
Created March 14, 2025 21:23
A script to show a unique logo per platform using the preprocessor directives
using UnityEngine;
using UnityEngine.UI;
public class LogoManagerPPD : MonoBehaviour
{
[SerializeField]
Sprite MetaLogo;
[SerializeField]
Sprite AndroidLogo;
@DanMillerDev
DanMillerDev / HandJointFollow.cs
Created March 14, 2025 21:28
A script to set an objects position and rotation to a specific XR Joint based on the ID, handles usage for game object and physics rigidbodies
using System;
using UnityEngine;
using UnityEngine.XR.Hands;
using UnityEngine.XR.Management;
public class HandJointFollow : MonoBehaviour
{
[SerializeField]
XRHandJointID m_JointToTrack;
@DanMillerDev
DanMillerDev / AnchorPlacementManager.cs
Last active March 18, 2025 20:54
A script that places and manages Anchors, checking if the platform supports saved anchors and writing the ID to a file.
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARFoundation.Samples;
public class AnchorPlacementManager : MonoBehaviour
{
[SerializeField]
ARAnchorManager m_AnchorManager;
@DanMillerDev
DanMillerDev / AnchorRecallManager.cs
Last active March 18, 2025 20:56
A script that listens to trackable changed events for the ARAnchor manager and can recall saved anchors when an application is relaunched.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class AnchorRecallManager : MonoBehaviour
{
[SerializeField]
@DanMillerDev
DanMillerDev / LogoManager.cs
Created March 14, 2025 22:55
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
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
public class LogoManager : MonoBehaviour
{
[SerializeField]
Sprite MetaLogo;
[SerializeField]
@DanMillerDev
DanMillerDev / ShaderTypeManager.cs
Last active March 16, 2025 19:59
A script for changing the shader type of materials at runtime. In this example we're changing to use a custom occlusion shader required on AndroidXR and Meta Quest platforms for depth based occlusion.
using UnityEngine;
using System.Collections.Generic;
public class ShaderTypeManager : MonoBehaviour
{
[SerializeField]
List<Material> m_MaterialsToChange;
void OnEnable()
{
Shader targetShader;
@DanMillerDev
DanMillerDev / Unity_GDC_2025_Crossplatform_MixedReality.md
Last active March 18, 2025 21:09
Collection of gist shared in Unity GDC 2025 Talk Building cross-platform mixed reality

Collection of gist shared in Unity GDC 2025 Talk Building cross-platform mixed reality

Shell script for building a Meta Quest, AndroidXR and visionOS build in Unity via CLI batchmode
build_multiplatform_xr.sh

A script to show a unique logo per platform using the preprocessor directives and AR Session Descriptor
LogoManagerPPD.cs
LogoManager.cs

A script for managing permissions across Apple Vision Pro, Meta Quest and Android XR. It references world space UI element to let the user know about missing or denied permissions.

@DanMillerDev
DanMillerDev / AnchorSaveFile.cs
Created March 18, 2025 00:27
Saves and loads SerializableGuids and DateTimes to a file on the devices local storage for persistent anchors
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
using UnityEngine.XR.ARSubsystems;
/// <summary>