Skip to content

Instantly share code, notes, and snippets.


Dan Puzey DanPuzey

View GitHub Profile
DanPuzey / SelectionHistory.cs
Created May 31, 2018
Unity3d editor window to show recent selections
View SelectionHistory.cs
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
public class SelectionHistory : EditorWindow
private const int NumberOfItemsToKeep = 6;
private const string MultiSelectPrefix = "+";
private const int ItemsPerRow = 2;
DanPuzey / GitRepl.ps1
Last active Apr 3, 2017
Super-hacky git REPL for PowerShell/Posh-Git
View GitRepl.ps1
function GitPrompt()
$Host.UI.RawUI.ForegroundColor = "White"
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
Write-Host "`ngit> " -NoNewLine -ForegroundColor "DarkGray"
DanPuzey / EventAggregator.cs
Created Jan 30, 2017
Unity3d/C# EventAggregator (Unity v5.5+)
View EventAggregator.cs
using System;
using System.Linq;
using Diagnostics;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Events
public static class EventAggregator
DanPuzey / Promise.cs
Last active Jul 1, 2018
Unity3d: promises for Coroutines
View Promise.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Promises
/// <summary>
/// Contains extension methods that provide promise-like behaviour for coroutines.
/// </summary>
DanPuzey / AddToRegistry.cs
Created Oct 26, 2015
Prototype Unity3d service locator (nicer than singletons!)
View AddToRegistry.cs
using UnityEngine;
namespace FunkyGeek.Core
/// <summary>
/// Adds a list of components (typically from this or child GameObjects) to the global registry.
/// </summary>
public class AddToRegistry : MonoBehaviour
public Object[] ObjectsToAdd;
DanPuzey / .gitattributes
Created Oct 23, 2015
.gitAttributes for Unity LFS
View .gitattributes
*.tif filter=lfs diff=lfs merge=lfs -text
*.cubemap filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.raw filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.mov filter=lfs diff=lfs merge=lfs -text
*.fbx filter=lfs diff=lfs merge=lfs -text
DanPuzey / .gitignore
Created Oct 21, 2015
My Unity3d .gitignore
View .gitignore
# unneeded Unity folders
# VS user files
# unneeded VS project files
DanPuzey / gist:c03e369eb7090808ca9c
Last active Aug 29, 2015
Random snippet of .cs that is broken in my Unity project (but works in a clean project)
View gist:c03e369eb7090808ca9c
string s = "RHUBARB" + "æ" + "CUSTARD";
var c = s[7];
var i = (int)c;
Debug.Log(c); // expect æ in console
Debug.Log(i); // expect 230 in console
View gist:0fbf9e3d93970b2fa6bc
IEnumerable<string> ErrorsFor3(string[] hayStack, string[] needles, Func<string, string, string> errorMessageGenerator)
return hayStack.Select(hay => needle.FirstOrDefault(hay.Contains))
.Where(n => n != null)
.Select(matchingNeedle => errormessageGenerator(hay, matchingNeedle));
DanPuzey / Log.cs
Last active Oct 24, 2018
Unity logging wrapper, for better performance and usage.
View Log.cs
using UnityEngine;
namespace Assets.Phunk.Core
public static class Log
#region Error
public static void ErrorFormat(UnityEngine.Object context, string template, params object[] args)
var message = string.Format(template, args);