Skip to content

Instantly share code, notes, and snippets.

View mminer's full-sized avatar

Matthew Miner mminer

View GitHub Profile
@mminer
mminer / Macros.cs
Created May 16, 2011 20:46
Unity editor script to invoke undocumented MacroEvaluator class.
using UnityEditor;
using UnityEditor.Macros;
using UnityEngine;
/// <summary>
/// Allows use of the undocumented MacroEvaluator class. Use at your own risk.
/// </summary>
public class Macros : EditorWindow
{
string macro = "";
@mminer
mminer / CreatePrefabFromSelected.cs
Last active May 30, 2020 01:19
Unity editor script to create prefab from selected game object.
using UnityEditor;
using UnityEngine;
/// <summary>
/// Creates a prefab from a selected game object.
/// </summary>
class CreatePrefabFromSelected
{
const string menuName = "GameObject/Create Prefab From Selected";
@mminer
mminer / Console.cs
Last active March 28, 2024 22:23
Unity script to display in-game debug console. Actively maintained version: https://github.com/mminer/consolation
// NOTE: For an actively-maintained version of this script, see https://github.com/mminer/consolation.
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// A console to display Unity's debug logs in-game.
/// </summary>
public class Console : MonoBehaviour
{
@mminer
mminer / showinvisibles.sh
Created May 16, 2011 21:27
Shell script to toggle invisible files in Finder.
#!/bin/bash
STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ "$STATUS" = TRUE ]; then
defaults write com.apple.finder AppleShowAllFiles FALSE
else
defaults write com.apple.finder AppleShowAllFiles TRUE
fi
@mminer
mminer / Wander.cs
Last active July 15, 2023 19:43
Unity script to simulate a wandering behaviour for NPCs.
using UnityEngine;
using System.Collections;
/// <summary>
/// Creates wandering behaviour for a CharacterController.
/// </summary>
[RequireComponent(typeof(CharacterController))]
public class Wander : MonoBehaviour
{
public float speed = 5;
@mminer
mminer / Marquee.cs
Last active January 27, 2024 10:32
Simple Unity script to create a scrolling marquee.
using UnityEngine;
public class Marquee : MonoBehaviour
{
public string message = "Where we're going, we don't need roads.";
public float scrollSpeed = 50;
Rect messageRect;
void OnGUI ()
@mminer
mminer / Wander2.cs
Last active September 21, 2020 15:28
Another Unity script to simulate a wandering behaviour for NPCs, this one taking into account collisions with boundaries.
using UnityEngine;
using System.Collections;
/// <summary>
/// Creates wandering behaviour for a CharacterController.
/// </summary>
[RequireComponent(typeof(CharacterController))]
public class Wander2 : MonoBehaviour
{
public float speed = 5;
@mminer
mminer / pocket.py
Created July 27, 2012 06:45
A script to save URLs to Pocket (read it later service).
#!/usr/bin/env python
"""
Saves URL(s) to a user's Pocket queue.
It accepts either command line arguments or a URL from the OS X clipboard.
For information about Pocket see http://getpocket.com/
"""
import optparse
import subprocess
@mminer
mminer / MoveToOrigin.cs
Last active July 5, 2018 09:59
Unity editor script that provides a shortcut to move the selected game object to the origin (0, 0, 0).
using UnityEditor;
using UnityEngine;
class MoveToOrigin
{
/// <summary>
/// Moves selected game object(s) to (0, 0, 0).
/// <summary>
/// <remarks>Keyboard shortcut: shift-cmd-0 (Mac), shift-ctrl-0 (Windows).</remarks>
[MenuItem ("GameObject/Move To Origin #%0")]
@mminer
mminer / jsonhandler.py
Created April 26, 2013 02:36
A JSON request handler for Tornado.
import json
import tornado.web
class JsonHandler(BaseHandler):
"""Request handler where requests and responses speak JSON."""
def prepare(self):
# Incorporate request JSON into arguments dictionary.
if self.request.body:
try: