Skip to content

Instantly share code, notes, and snippets.

View jonHuffman's full-sized avatar

Jon Huffman jonHuffman

View GitHub Profile
@jonHuffman
jonHuffman / ScriptKeywordProcessor.cs
Created June 16, 2020 19:56
A Keyword processor for Unity script templates. Allows one to replace pre-defined symbols in a script template with procedurally determined values.
// Original gist by JoaoBorks, but the gist is no longer available
using UnityEngine;
using UnityEditor;
internal sealed class ScriptKeywordProcessor : UnityEditor.AssetModificationProcessor
{
private const string ASSETS_FOLDER = "Assets";
private const string SCRIPTS_FOLDER = "Scripts/";
public static void OnWillCreateAsset(string path)
@jonHuffman
jonHuffman / SceneConstantsGenerator.cs
Last active September 3, 2018 20:53
A utility script for Unity that generates a constants file for the scenes listed in the build settings. Can be accessed under Tools/Code Generation/Create Scene Constants
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: 15.0.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace CodeGeneration.Constants
@jonHuffman
jonHuffman / ActionExtensions.cs
Created March 1, 2017 20:55
Adds a SafeInvoke method for C# Actions
using System;
public static class ActionExtensions
{
public static void SafeInvoke(this Action action)
{
if(action != null)
{
action();
}
@jonHuffman
jonHuffman / CoroutineRunner
Created February 6, 2017 21:55
I've been using this CoroutineRunner to run Coroutines on non-MonoBehaviour objects for a while. People tend to find it useful so I figured I would share!
using UnityEngine;
using System.Collections;
namespace CR
{
/// <summary>
/// Allows for a coroutine to be run from objects that do not extend Monobehaviour
/// </summary>
/// <remarks>
/// Only use a coroutine in a non-monobehaviour if aboslutely needed as it will place a Unity dependancy in your code