Skip to content

Instantly share code, notes, and snippets.

@camnewnham
camnewnham / WindowsMixedRealityUtilities.cs
Created January 13, 2020 21:55
Better coordinate system
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
using System;
using System.Runtime.InteropServices;
using UnityEngine.XR.WSA;
#if WINDOWS_UWP
using Windows.Perception.Spatial;
using UnityEngine;
@camnewnham
camnewnham / HoloLensCoordinateSystem
Created January 11, 2020 05:12
A coordinate system that updates when the scene changes
using System.Runtime.InteropServices;
using UnityEngine;
namespace MyApp
{
public static class HoloLensCoordinateSystem// : MonoBehaviour
{
public static HoloLensCoordinateSystem Instance;
public static Windows.Perception.Spatial.SpatialCoordinateSystem Current;
@camnewnham
camnewnham / RaycastOverride.cs
Created July 22, 2019 00:34
Temporarily override raycast layers for all detected pointers
/// <summary>
/// Temporarily overrides layers masks for all input sources and pointers
/// </summary>
public class RaycastOverride : MonoBehaviour
{
public LayerMask[] RegularMasks;
public LayerMask[] OverrideMasks;
public void ApplyOverride()
{
@camnewnham
camnewnham / RaycastOverride.cs
Created July 22, 2019 00:34
Temporarily override raycast layers for all detected pointers
/// <summary>
/// Temporarily overrides layers masks for all input sources and pointers
/// </summary>
public class RaycastOverride : MonoBehaviour
{
public LayerMask[] RegularMasks;
public LayerMask[] OverrideMasks;
public void ApplyOverride()
{
@camnewnham
camnewnham / PlatformUtility.cs
Created July 11, 2019 05:23
MRTK SupportedPlatforms
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
namespace Microsoft.MixedReality.Toolkit.Utilities
{
public static class PlatformUtility
{
public static bool IsPlatformSupported(this RuntimePlatform runtimePlatform, SupportedPlatforms platforms)
@camnewnham
camnewnham / Notes.txt
Last active July 10, 2019 04:43
Issues with UnityTouch in MRTK
UnityTouchDeviceManager.cs
===============================
UnityTouchDeviceManager.RemoveTouchController(Touch touch)
Issue: Does not update touch data, so when Controller.EndTouch is called the last phase is always moved/stationary rather than ended, so the funciton returns early.
Resolution: Update TouchData before calling EndTouch.
UnityTouchController.cs
/// <summary>
/// https://stackoverflow.com/questions/56643325/how-can-i-simulate-hand-rays-on-hololens-1
/// </summary>
public class HoloLens1ShellHandRayPointer : ShellHandRayPointer
{
/// <summary>
/// Offset upwards to help with raycasting, so the user doesn't have to hold their hand quite as high.
/// </summary>
protected Vector3 HandOffset => new Vector3(0.00f, 0.2f, 0.00f);
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D2EC781E-7F4B-4FD8-9981-9FF150D3849D}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>rhino_template</RootNamespace>
<AssemblyName>rhino_template</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
@camnewnham
camnewnham / HandlerFunc.cs
Last active June 17, 2019 05:25
ManipulationHandler that raises state changed
private void _OnCurrentStateChanged(MyManipulationHandler.State oldstate, MyManipulationHandler.State newstate)
{
if (!oldstate.HasFlag(MyManipulationHandler.State.Scaling) && newstate.HasFlag(MyManipulationHandler.State.Scaling))
{
_meshCollider = this.GetComponent<MeshCollider>();
if (_meshCollider != null && _meshCollider.enabled)
{
_meshCollider.enabled = false;
}
}
@camnewnham
camnewnham / Debug Output.txt
Last active June 10, 2019 01:24
Rhino Debug output: Exception thrown: 'System.ComponentModel.Win32Exception' in WindowsBase.dll
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Rhino 6\System\RhinoWindows.dll'.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Rhino 6\System\RhinoCommon.dll'.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Rhino 6\System\Rhino.UI.dll'.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Rhino 6\System\Eto.dll'. Symbols loaded.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll'.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Program Files\Rhino 6\System\Eto.Wpf.dll'. Symbols loaded.
'Rhino.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'.
'Rhino.exe' (CLR