Skip to content

Instantly share code, notes, and snippets.

@PatHightree
PatHightree / HeadAttach.cs
Created November 23, 2023 22:36
Script to attach an object to the HMD and update the pos/rot just before rendering
using UnityEngine;
using UnityEngine.InputSystem;
public class HeadAttach : MonoBehaviour
{
public Transform Target;
public InputAction HmdPosition;
public InputAction HmdRotation;
private void Awake()
@PatHightree
PatHightree / Convert all TS to mp4.cmd
Created May 16, 2022 21:04
Windows batch script for FFmpeg, transcodes all *.TS files in the current directory to .mp4
@ECHO OFF
setlocal enabledelayedexpansion
for %%f in (*.TS) do (
set /p val=<%%f
ffmpeg -i %%f -map 0 -c copy %%~nf.mp4
)
@PatHightree
PatHightree / AimParticlesAtCameraForCubemapRendering.cs
Last active October 28, 2019 11:19
Workaround for artifact during rendering of cubemaps whereby particles are not oriented consistently over different view directions. Algorithm is explained in this video: https://youtu.be/1hbcWhifuxE
private struct ParticleData
{
public ParticleSystem System;
public ParticleSystem.Particle[] Particles;
public Transform Camera;
public ParticleSystemRenderSpace Alignment;
}
/// <summary>
/// Collect particle systems which are in view and use billboard rendermode.
@PatHightree
PatHightree / PostProcessor_GlobalScale1.cs
Created June 1, 2014 11:46
Unity postprocessor, sets the scale to 1 on fbx files exported from 3dsmax
using UnityEditor;
using UnityEngine;
/// <summary>
/// This asset preprocessor sets the importer's global scale to 1.0.
/// This way the scale in 3dsmax corresponds correctly to the scale in Unity.
/// </summary>
class PostProcessor_GlobalScale1 : AssetPostprocessor {
/// <summary>
/// This method is called just before importing an FBX.
@PatHightree
PatHightree / Unity build menu with push option for Android
Created August 28, 2012 14:29
Unity build menu with 2 options: 'Build Current Target' and 'push latest build to Android'.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEngine;
using System.Linq;
using Debug = UnityEngine.Debug;