Skip to content

Instantly share code, notes, and snippets.

<a href="fb21312321321321://">click me</a>
@prime31
prime31 / UnityScript makes me cry
Created March 10, 2012 01:37
an example of what will result in a compiler error when using UnityScript
function jsIsReallySaddening()
{
if( true )
{
var shouldBeLocallyScoped:boolean = true;
}
if( true )
{
// unbelievably, the compiler will error on this with "There is already a local variable with the name 'shouldBeLocallyScoped'"
@prime31
prime31 / Really?
Created March 10, 2012 01:46
you have got to be kidding me
function youHaveGotToBeKiddingMe()
{
var array = new Array();
array.Push( "stuff" );
if( array.Count > 0 )
var iCantBelieveThisWorks = array[0];
Debug.Log( iCantBelieveThisWorks );
}
- (NSURLRequest*)webView:(WebView*)sender resource:(id)identifier willSendRequest:(NSURLRequest*)request redirectResponse:(NSURLResponse*)redirectResponse fromDataSource:(WebDataSource*)dataSource
{
// are we redirecting to my site only?
if( [request.URL.absoluteString hasPrefix:_mySiteYo] )
return request;
return null;
}
@prime31
prime31 / gist:2961486
Created June 20, 2012 18:40
Quick and easy endless color cycle using GoKit
var chain = new TweenChain();
chain.setIterations( -1, LoopType.PingPong );
// colors is an array of Color objects that is settable in the inspector
// in this case, we set the cameras background color but this could be light colors, material colors, etc
for( var i = 0; i < colors.Length; i++ )
chain.append( new Tween( Camera.mainCamera, 6f, new TweenConfig().colorProp( "backgroundColor", colors[i] ) ) );
chain.play();
@prime31
prime31 / PHPReceiptValidation.php
Created July 25, 2012 18:27
PHP receipt validation
<?php
// get input
$receipt = $_POST['receipt'];
$isTest = $_POST['isTest'] == '1';
// prop the post data
$json = json_encode( array( 'receipt-data' => $receipt ) );
@prime31
prime31 / Unity2Dframeworks.txt
Created August 12, 2012 19:22
Unity 2D framework comparison
Key:
"-" negative point
"+" positive point
"+-" could go either way depending on your opinion or if it functions or not
Background Info: the last project we worked on needed basic 2D functionality (sprites and animations) and SpriteKit was born to fill this need (http://www.youtube.com/watch?v=cabAr2CdLmc). It has no fancy editors and was really made to fit a specific need and as of yet it has not been extended much further than the video shows. Something a bit more full featured is required for a new prototype and instead of spending a bunch of time extending SpriteKit we went on a search for alternatives. None of the below frameworks are perfect and they all have pluses and minuses. One thing SpriteKit had that none of the others do is automatic texture selection based on screen resolution. That is one thing I would like to see incorporated in every 2D framework and it kind of surprises me that it isn't one of the first features added when making a 2D framework.
uint codePoint = UInt32.Parse( new string( unicodeCharArray ), System.Globalization.NumberStyles.HexNumber );
s += Char.ConvertFromUtf32( (int)codePoint );
@prime31
prime31 / MiniJSON.cs
Created October 30, 2012 01:44 — forked from Borluse/MiniJSON.cs
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) 2012 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
// create a TweenConfig that we will use on all 4 cubes
var config = new TweenConfig()
.setEaseType( EaseType.QuadIn ) // set the ease type for the tweens
.materialColor( Color.magenta ) // tween the material color to magenta
.eulerAngles( new Vector3( 0, 360, 0 ) ) // do a 360 rotation
.position( new Vector3( 2, 8, 0 ), true ) // relative position tween so it will be start from the current location
.setIterations( 2, LoopType.PingPong ); // 2 iterations with a PingPong loop so we go out and back
// create the chain and set it to have unlimited iterations
var chain = new TweenChain().setIterations( -1 );