Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Miner mminer

View GitHub Profile
@mminer
mminer / Macros.cs
Created May 16, 2011
Unity editor script to invoke undocumented MacroEvaluator class.
View Macros.cs
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
Unity editor script to create prefab from selected game object.
View CreatePrefabFromSelected.cs
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 Aug 9, 2021
Unity script to display in-game debug console. Actively maintained version: https://github.com/mminer/consolation
View Console.cs
// 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
Shell script to toggle invisible files in Finder.
View showinvisibles.sh
#!/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 Dec 29, 2022
Unity script to simulate a wandering behaviour for NPCs.
View Wander.cs
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 Nov 22, 2022
Simple Unity script to create a scrolling marquee.
View Marquee.cs
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 Sep 21, 2020
Another Unity script to simulate a wandering behaviour for NPCs, this one taking into account collisions with boundaries.
View Wander2.cs
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 Jul 27, 2012
A script to save URLs to Pocket (read it later service).
View pocket.py
#!/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 Jul 5, 2018
Unity editor script that provides a shortcut to move the selected game object to the origin (0, 0, 0).
View MoveToOrigin.cs
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 Apr 26, 2013
A JSON request handler for Tornado.
View jsonhandler.py
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: