Skip to content

Instantly share code, notes, and snippets.

View MattRix's full-sized avatar

Matt Rix MattRix

View GitHub Profile
@MattRix
MattRix / FNodeLink
Last active December 10, 2015 12:48
This class allows you to link the position of a Unity GameObject to a Futile FNode. You should set METERS_TO_POINTS to a value that makes sense for your current game.
@MattRix
MattRix / ScopeDifferences.cs
Created January 8, 2013 06:37
Scope differences: C vs C# vs AS3 (using C/C# code, but it applies equally to AS3)
///// Example 1 - C:Valid, C#:Error, AS3:Warning /////
bool isHappy = true;
if(true)
{
bool isHappy = true;
}
///// Example 2 - C:Valid, C#:Error, AS3:Warning /////
@MattRix
MattRix / RXDebug.cs
Created May 19, 2013 04:07
RXDebug tracks instance counts
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Timers;
@MattRix
MattRix / RXExtensions.cs
Last active December 17, 2015 17:29
Extension methods for logging arrays and lists in C#, just call someArray.Log() or someList.Log(), or if you want a name logged with it, then just someArray.Log("The list of things")
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
//USAGE:
//someArray.Log();
//someArray.Log("a name");
//someList.Log();
//someList.Log("a name");
using System;
using System.Collections.Generic;
public class AudioClipType
{
static public List<AudioClipType> allAudioClipTypes = new List<AudioClipType>();
static public AudioClipType SnakeEat = new AudioClipType("snake_eat","wav",1.0f);
static public AudioClipType UIPress = new AudioClipType("ui_press","wav",1.0f);
static public AudioClipType Explosion = new AudioClipType("explosion","wav",1.0f);
using System;
using System.Collections.Generic;
using UnityEngine;
public class Scroller
{
public float maxDragSpeed = 20.0f; //maximum drag speed
public float edgeSquish = 60.0f; //how far to go past the end
public float edgeBounce = 0.19f; //how much force to use to bounce back
public float strongFriction = 0.75f; //used to bring it to a stop quicker
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Text;
using System.Reflection;
@MattRix
MattRix / ObjectInspector.cs
Last active December 22, 2015 21:48
Easy inspectors on regular monobehaviours etc
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEditor;
using System.Reflection;
[CustomEditor (typeof(UnityEngine.Object),true)]
[CanEditMultipleObjects]
@MattRix
MattRix / HealthBar.cs
Created September 26, 2013 15:52
HealthBar from Snow Siege
using System;
using UnityEngine;
public class HealthBar : FContainer
{
private const float INSET = 1.0f;
private const float DOUBLE_INSET = INSET*2.0f;
private static Color BAD_COLOR = Color.red;
private static Color OKAY_COLOR = Color.yellow;
@MattRix
MattRix / DeclarationExample.cs
Last active December 29, 2015 17:58
C# declaration example
//These have *identical* performance
Car myCar = new Car();
//STYLE A: with declaration outside loop
Car tempCarA;
for(int c = 0; c<1000; c++)
{
tempCarA = myCar;
tempCarA.Honk();