Skip to content

Instantly share code, notes, and snippets.

@boj
boj / ColorPicker.cs
Created August 30, 2011 17:39
Unity3d Color Picker
using UnityEngine;
using System.Collections;
// relies on: http://forum.unity3d.com/threads/12031-create-random-colors?p=84625&viewfull=1#post84625
public class ColorPicker : MonoBehaviour {
public bool useDefinedPosition = false;
public int positionLeft = 0;
public int positionTop = 0;
@AngryAnt
AngryAnt / GravityWell.cs
Created August 18, 2011 09:01
An example of how to easily do an inexpensive alternative gravity setup (untested).
// GravityObject.cs
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (Rigidbody))]
public class GravityObject : MonoBehaviour
{
public float gravityModifier = 1.0f;
@doskoi
doskoi / gist:1069240
Created July 7, 2011 10:12
Unity3D GUI Resolution
function OnGUI() {
var screenScale: float = Screen.width / 480.0;
var scaledMatrix: Matrix4x4 = Matrix4x4.identity.Scale(Vector3(screenScale,screenScale,screenScale));
GUI.matrix = scaledMatrix;
// then do the rest of your GUI as per normal, using the 480x320 screen size you had for your standard res iPhone app
}
@pamelafox
pamelafox / usermodel.py
Created July 6, 2011 21:08
SimpleGeo Timezone Calculation on Python App Engine
class User(db.Model):
location = db.StringProperty()
timezone = db.StringProperty(default='America/Los_Angeles')
# Do this once per user
def calculate_timezone(self):
from simplegeo import Client
client = Client('oauth key', 'oauth secret SHH')
response = client.context.get_context_by_address(self.location)
for feature in response['features']:
@lukeredpath
lukeredpath / ExampleClass.m
Created June 30, 2011 22:18
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@pamelafox
pamelafox / jsonexport.js
Created June 27, 2011 23:58
JSON Export Apps Script
// Exports current sheet as JSON and displays in message box.
function exportJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var rowsData = getRowsData(sheet);
ss.msgBox(Utilities.jsonStringify(rowsData));
}
// getRowsData iterates row by row in the input range and returns an array of objects.
// Each object contains all the data for a given row, indexed by its normalized column name.
@rozgo
rozgo / gist:1027953
Created June 15, 2011 19:58
Gestures
// alex@rozgo.com
using UnityEngine;
using System.Collections;
public class Gestures : MonoBehaviour {
float lastf0f1Dist;
void Update () {
@kylefinley
kylefinley / gist:1025736
Created June 14, 2011 19:59
AppEngine ndb Threaded Messaging.
import cgi
from google.appengine.api import mail
from google.appengine.ext import deferred
from ndb import model
from tipfy.routing import url_for
from tipfyext.ndb.mixins import DateMixin
@AngryAnt
AngryAnt / MyStateMachine.cs
Created May 31, 2011 08:45
A simple state machine using a dictionary of delegates indexed by an enum.
using UnityEngine;
using System.Collections.Generic;
public class MyStateMachine : MonoBehaviour
{
public delegate void StateHandlerDelegate ();
public enum MyStateType
@macintoxic
macintoxic / GameManager.cs
Created May 26, 2011 20:22 — forked from AngryAnt/GameManager.cs
GameManager.cs
using UnityEngine;
using System.Collections;
public enum GameStatus
{
Setup,
Initializing,
ReInitializing,
AwaitingMasterServer,