Skip to content

Instantly share code, notes, and snippets.

@andijakl
andijakl / DepthImageVisualizer.cs
Created November 27, 2020 10:21
Convert the XRCpuImage to a Texture2D for AR Foundation.
// Source: https://github.com/Unity-Technologies/arfoundation-samples/blob/6296272a416925b56ce85470e0c7bef5c913ec0c/Assets/Scripts/CpuImageSample.cs
private static void UpdateRawImage(RawImage rawImage, XRCpuImage cpuImage)
{
// Get the texture associated with the UI.RawImage that we wish to display on screen.
var texture = rawImage.texture as Texture2D;
// If the texture hasn't yet been created, or if its dimensions have changed, (re)create the texture.
// Note: Although texture dimensions do not normally change frame-to-frame, they can change in response to
// a change in the camera resolution (for camera images) or changes to the quality of the human depth
// and human stencil buffers.
@JanikHelbig
JanikHelbig / EventHandlerAsync.cs
Last active June 24, 2022 06:54
Simple async EventHandler in Unity using Cysharp/UniTask
using System;
using UniRx.Async;
public delegate UniTask EventHandlerAsync(object sender, EventArgs e);
public static class EventHandlerAsyncExtensions
{
public static UniTask InvokeAsync(this EventHandlerAsync handler, object sender, EventArgs e)
{
Delegate[] delegates = handler?.GetInvocationList();
@antonsem
antonsem / arproxy.shader
Last active April 3, 2024 20:54 — forked from StigOlavsen/arproxy.shader
Unity shader for LWRP and AR Foundation, renders as transparent with occlusion and shadows. Put this on AR planes to get shadows and occlusion for 3D objects.
Shader "AR Proxy"
{
Properties
{
}
SubShader
{
Tags
{
@kamyker
kamyker / VFXAbstractParticleOutput.cs
Last active May 23, 2025 09:13
Custom Render Queue in Unity VFX Graph (com.unity.visualeffectgraph@8.2.0\Editor\Models\Contexts\Implementations\)
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEditor.VFX;
using UnityEngine.VFX;
namespace UnityEditor.VFX
@TheJLifeX
TheJLifeX / 00-hand-gesture-recognition.gif
Last active October 21, 2025 11:32
Simple Hand Gesture Recognition Code - Hand tracking - Mediapipe
00-hand-gesture-recognition.gif
@narner
narner / ARKitMultiCamTestViewController.swift
Last active December 16, 2022 19:30
ARKit + MultiCam Test for iOS 13 - Not Successful
//
// ViewController.swift
// test
//
// Created by Nicholas Arner on 9/19/19.
// Copyright © 2019 NFA. All rights reserved.
//
import UIKit
import SceneKit
@StigOlavsen
StigOlavsen / arproxy.shader
Last active November 10, 2021 08:01
Unity shader for LWRP and AR Foundation, renders as transparent with occlusion and shadows. Put this on AR planes to get shadows and occlusion for 3D objects.
Shader "AR Proxy"
{
Properties
{
}
SubShader
{
Tags
{
@krzys-h
krzys-h / SaveRenderTextureToFile.cs
Last active October 16, 2025 17:59
[Unity] Save RenderTexture to image file
using UnityEngine;
using UnityEditor;
public class SaveRenderTextureToFile {
[MenuItem("Assets/Save RenderTexture to file")]
public static void SaveRTToFile()
{
RenderTexture rt = Selection.activeObject as RenderTexture;
RenderTexture.active = rt;
@tomasdev
tomasdev / script.md
Last active November 18, 2023 15:00
JavaScript dominant color for image

Inspired by manu.ninja approach there's a front-end (or nodejs if using node-canvas) equivalent without using GraphicsMagick:

const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const image = new Image();
image.onload = () => {
    canvas.width = image.width;
    canvas.height = image.height;
 context.drawImage(image, 0, 0, 1, 1);
@cuxaro
cuxaro / BZZProximitySensor.m
Created March 21, 2016 21:09
Use the Proximity Sensor in iOS Device
-(void)activeSensorProximity{
UIDevice *device = [UIDevice currentDevice];
if ([self hasProximitySensor]) {
[device setProximityMonitoringEnabled:YES];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self
selector:@selector(proximitySensorDidChange:)