Skip to content

Instantly share code, notes, and snippets.

View MatthewMaker's full-sized avatar

Matt "Trip" Maker MatthewMaker

View GitHub Profile
@ZeroStride
ZeroStride / FastLookup.cs
Created May 20, 2011 22:37
Fast access to information on a Unity GameObject without having to call GetComponent.
using UnityEngine;
public class FastLookup : MonoBehaviour
{
[SerializeField]
public static int LookupListSize = 1597;//547; //!< Size of static data arrays. Prime numbers are best, in theory.
public const uint FlagAllocated = 1 << 0; //!< This index has been reserved for use.
public uint Idx; //!< Per-instance index into the static data arrays.
@AngryAnt
AngryAnt / build.pl
Created June 7, 2011 19:29
Example perl script for building .net assemblies for use in Unity.
#!/bin/usr/perl
use strict;
use File::Basename;
chdir (File::Spec->rel2abs (dirname($0)."/..")); # Modify for location of perl script
my $monoPath = "External/Mono/builds/monodistribution";
my @sourceDirs = (
"Path/To/Source/*.cs",
"Path/To/More/Source/*.cs"
@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
}
@tmpvar
tmpvar / gist:1133575
Created August 9, 2011 08:01
UnityScript instantiate object from variable
<Ascendion> tmpvar -- a.gettype().GetConstructors(); will get you a list of constructor methods -- look for the one that takes no parameters and invoke it
[00:50] * dock ([email protected]) has joined #unity3d
[00:52] <Ascendion> you will need "using System.Reflection" to get the ConstructorInfo data type that GetConstructors returns
@dbuck
dbuck / GetHierarchy.cs
Created August 16, 2011 15:04
Return the full hierarchy string of a gameObject, ready for use in GameObject.Find method later
//Return the full hierarchy string of a gameObject, ready for use in GameObject.Find method later...
static public string GetHierarchy(GameObject g)
{
if (!g || g == null)
{
return "";
}
string hierarchy = null;
@larrymyers
larrymyers / gist:1219952
Created September 15, 2011 17:51
Create a version.txt file for builds via Jenkins / Hudson and Git
echo "JOB: $JOB_NAME" > version.txt
echo "BUILD NUMBER: $BUILD_NUMBER" >> version.txt
echo "GIT REVISION:" >> version.txt
git log -n 1 >> version.txt
@keijiro
keijiro / PostprocessBuildPlayer
Created September 26, 2011 11:24
PostprocessBuildPlayer for Unity iOS: modifies Info.plist to use Facebook URL-scheme
#!/usr/bin/env python
import sys, os.path
install_path = sys.argv[1]
target_platform = sys.argv[2]
if target_platform != "iPhone": sys.exit()
info_plist_path = os.path.join(install_path, 'Info.plist')
@reklis
reklis / build.sh
Created September 30, 2011 15:42
Archive post-action
#in older versions of Xcode4 you may need to set PRODUCT_NAME manually
DIST_LIST=<TestFlight Distribution List name here>
API_TOKEN=<TestFlight API token here>
TEAM_TOKEN=<TestFlight team token here>
SIGNING_IDENTITY="iPhone Distribution: Development Seed"
PROVISIONING_PROFILE="${HOME}/Library/MobileDevice/Provisioning Profiles/MapBox Ad Hoc.mobileprovision"
LOG="/tmp/testflight.log"
DATE=$( /bin/date +"%Y-%m-%d" )
@nomadalex
nomadalex / water.shader
Created October 26, 2011 06:10
Unity-水面效果的shader文件
Shader "FX/Water" {
Properties {
_WaveScale ("Wave scale", Range (0.02,0.15)) = 0.063
_ReflDistort ("Reflection distort", Range (0,1.5)) = 0.44
_RefrDistort ("Refraction distort", Range (0,1.5)) = 0.40
_RefrColor ("Refraction color", COLOR) = ( .34, .85, .92, 1)
_Fresnel ("Fresnel (A) ", 2D) = "gray" {}
_BumpMap ("Bumpmap (RGB) ", 2D) = "bump" {}
WaveSpeed ("Wave speed (map1 x,y; map2 x,y)", Vector) = (19,9,-16,-7)
_ReflectiveColor ("Reflective color (RGB) fresnel (A) ", 2D) = "" {}
@azeitler
azeitler / CodeUtil.Unity.cs
Created November 13, 2011 02:14
C# Method Generation for Deep-Copy of any Class
using UnityEngine;
using UnityEditor;
public static class CodeUtilUnity {
[MenuItem("Tools/Test: CreateCopyMethod (Transform)")]
public static void TestCreateCopyMethod () {
Debug.Log (CreateCopyMethod (typeof(Transform), true));
}
}