Skip to content

Instantly share code, notes, and snippets.

@allanolivei
allanolivei / gist:9260107
Created February 27, 2014 21:38
Unity 3d : Get Selected Folder in Project Window
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public static class UnityUtil
{
public static string GetSelectedPathOrFallback()
{
string path = "Assets";
@ikriz
ikriz / PostBuildTrigger.cs
Created February 21, 2014 21:56
Example PostProcessBuild Script referenced at http://www.ikriz.nl/2012/06/18/unity-post-process-mayhem/
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
public static class PostBuildTrigger
{
private static DirectoryInfo targetdir;
private static string buildname;
private static string buildDataDir;
@drawcode
drawcode / Audio.cs
Created January 6, 2014 08:47
AudioSource
using UnityEngine;
using System.Collections;
public class CSBars : MonoBehaviour {
@ereidland
ereidland / StaticCoroutine.cs
Created December 11, 2013 20:08
Static Coroutine in Unity
using UnityEngine;
using System.Collections;
public class StaticCoroutine : MonoBehaviour
{
private static StaticCoroutine _instance;
public static void Do(IEnumerator enumerator)
{
if (_instance == null)
@anotheruiguy
anotheruiguy / node-grunt-sass.md
Last active March 11, 2020 17:07
Set up Node.js, Grunt and Node-Sass from scratch

Run the following steps inside a clean directory

Not sure if you are in the same boat as I, but I could not find any good resource out there that pulled this all together. So here is a step-by-step tutorial for creating a Node.js app from scratch, adding in Grunt and then Node-Sass. Yeah, try and find good docs on Node-Sass alone :(

Hope this is of help!

Create your Node.js project

  • npm init - create a clean node project
  • NOTE: be sure to add "private": true, to the package.json so that your project is not globally distributed as a npm app
@fversnel
fversnel / UnitySingleton.cs
Created October 15, 2013 14:13
Singleton implementation from the 'Unite 2013 - Internal Unity Tips and Tricks' talk (http://www.youtube.com/watch?v=Ozc_hXzp_KU)
using UnityEngine;
public class Example : MonoBehaviour
{
public static Example Singleton;
void OnEnable()
{
if (Singleton == null)
Singleton = this;
@sttz
sttz / StoppableCoroutine.cs
Last active February 9, 2022 10:12
Simple wrapper around Unity coroutines (generator methods) that allows to stop them from the outside. Unity natively only allows this when starting the coroutine by using its lexical name.
using System;
using System.Collections;
using UnityEngine;
/// <summary>
/// Wrapper around coroutines that allows to start them without using
/// their lexical name while still being able to stop them.
/// </summary>
public class StoppableCoroutine : IEnumerator
{
@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@JosephLaurino
JosephLaurino / OBJ.cs
Created December 5, 2011 19:47
obj file loader for Unity3D
// this code is from http://www.everyday3d.com/blog/index.php/2010/05/24/loading-3d-models-runtime-unity3d/
// which was released under the MIT license
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
public class OBJ : MonoBehaviour {
@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining