Skip to content

Instantly share code, notes, and snippets.

View liamcary's full-sized avatar

Liam liamcary

View GitHub Profile
@liamcary
liamcary / LODGroupCustomEditor.cs
Created February 8, 2024 07:16
Custom LODGroup Inspector with fields for entering distances instead of screen size percentages.
using UnityEngine;
namespace UnityEditor
{
/// NOTE: This needs to be in an editor folder with an Assembly Definition Reference referencing
/// the UnityEditor.UI assembly. This is because it uses internal extension methods which are inaccessible
/// outside of UnityEditor.UI.
[CustomEditor(typeof(LODGroup))]
internal class LODGroupCustomEditor : LODGroupEditor
{
@liamcary
liamcary / DynamicResolutionScaler.cs
Last active February 18, 2025 08:08
Dynamic Resolution for Oculus Quest with Unity 2021.3 LTS and URP 12
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.XR;
public class DynamicResolutionScaler : MonoBehaviour
{
[SerializeField, Range(0f, 1f)] float _minResolutionScale;
@liamcary
liamcary / BaseComponentRealtime.cs
Created June 14, 2023 02:15
A generic, abstract base class for Normcore RealtimeComponents that handles OnRealtimeModelReplaced and calls more self-explanatory methods for common usages.
using Normal.Realtime;
using System;
public abstract class BaseComponentRealtime<TModelRealtime> : RealtimeComponent<TModelRealtime>
where TModelRealtime : RealtimeModel, new()
{
public bool IsOwnershipSupported => model.hasMetaModel;
public bool PreventOwnershipTakeover
{
get => model.preventOwnershipTakeover;
@liamcary
liamcary / RealtimeTransformOptimizer.cs
Last active October 8, 2024 01:42
A script to improve performance of RealtimeTransforms in Rigidbody mode. See comments for fixes required for the latest Normcore versions.
using Normal.Realtime;
using System;
using System.Collections;
using System.Reflection;
using UnityEngine;
namespace Normcore.Realtime
{
/// <summary>
/// This script is intended to be attached to an object with a RealtimeTransform in Rigidbody mode. We have to use reflection