Skip to content

Instantly share code, notes, and snippets.

View mstevenson's full-sized avatar

Michael Stevenson mstevenson

View GitHub Profile
using UnityEngine;
using UnityEditor;
//Version 0.21 | twitter:@izm update for DK2
//Version 0.2 | s.b.Newsom Edition
//Source from http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
//Modified by seieibob for use at the Virtual Environment and Multimodal Interaction Lab at the University of Maine.
//Use however you'd like!
@mstevenson
mstevenson / ConfigurableJointExtensions.cs
Created October 24, 2014 07:14
Extension methods for working with Configurable Joints for Unity
using UnityEngine;
public static class ConfigurableJointExtensions
{
/// <summary>
/// Sets a joint's targetRotation to match a given local rotation.
/// The joint transform's local rotation must be cached on Start and passed into this method.
/// </summary>
public static void SetTargetRotationLocal (this ConfigurableJoint joint, Quaternion targetLocalRotation, Quaternion startLocalRotation)
{
@mstevenson
mstevenson / gist:0e3b03cefe82c7ff2e6e
Created September 27, 2014 22:47
All ffmpeg optional codecs through homebrew
brew install ffmpeg --with-vpx --with-libvpx --with-vorbis --with-libvorbis --with-theora --with-libtheora --with-libogg --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus --with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl --with-libopus --with-libschroedinger --with-libspeex --with-libvo-aacenc --with-libx264 --with-libxvid
@mstevenson
mstevenson / maya_sublime.mel
Last active August 29, 2015 14:06 — forked from fredrikaverpil/maya_sublime.py
Send selected code snippets to Maya via commandPort
// Close ports if they were already open under another configuration
if (catch(`commandPort -name ":7001" -close True`)) {
warning "Could not close port 7001 (maybe it is not opened yet...)";
}
if (catch(`commandPort -name ":7002" -close True`)) {
warning "Could not close port 7002 (maybe it is not opened yet...)";
}
// Open new ports
commandPort -name ":7001" -sourceType "mel";
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class CreateMergedMesh : ScriptableWizard
{
[MenuItem ("Prototype/Create Merged Mesh")]
static void CreateDataMesh ()
{
using UnityEngine;
using System.Collections;
public class ObliqueCameraProjection : MonoBehaviour
{
private Matrix4x4 originalProjection;
public Vector2 slideViewport;
public Vector2 slideFrustum;
public Vector2 slideFarClip; // compound slideViewport and slideFrustum
public Vector2 skew;
@mstevenson
mstevenson / gist:10706756
Created April 15, 2014 06:20
GetComponentsInChildrenRecursive
void GetComponentsInChildrenRecursive<T> (Transform parent, List<T> buffer)
where T : Component
{
foreach (Transform t in parent) {
var c = t.GetComponent<T> ();
if (c) {
buffer.Add (c);
}
GetComponentsInChildrenRecursive (t, buffer);
}
@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@mstevenson
mstevenson / Fps.cs
Last active April 19, 2024 03:04
An accurate FPS counter for Unity. Works in builds.
using UnityEngine;
using System.Collections;
public class Fps : MonoBehaviour
{
private float count;
private IEnumerator Start()
{
GUI.depth = 2;