Skip to content

Instantly share code, notes, and snippets.

View MattRix's full-sized avatar

Matt Rix MattRix

View GitHub Profile
@MattRix
MattRix / RXDivider.cs
Last active May 1, 2024 18:15
Adds dividers into the inspector. Based on a brilliant idea by Matthew Wegner, see: https://twitter.com/mwegner/status/355147544818495488
//Based on a brilliant idea by Matthew Wegner - https://twitter.com/mwegner/status/355147544818495488
//Code for drawing the base PropertyDrawers is from here: http://forum.unity3d.com/threads/173401-Getting-Default-SerializedProperty-Drawing-within-a-PropertyDrawer?p=1186347&viewfull=1#post1186347
//My implementation is super lazy with magic numbers everywhere! :D
#if UNITY_EDITOR
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
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 / 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();
@MattRix
MattRix / RockMusic.as
Created December 10, 2013 02:15
This was create for Keith Peters' now defunct 25lines AS3 competition. This entry fit within all the rules of the competition (ex no cheap chaining) To try it yourself, simply paste this code on the first frame of an empty FLA. To view it live, check it out here: http://struct.ca/share/rock
[SWF (backgroundColor=0, width=800,height=600, frameRate=60)]
//////////////////////////////////////////
//ROCK MUSIC featuring THE ROLLING STONE//
//////////////////////////////////////////
//By Matt Rix //
//////////////////////////////////////////
//Hold down your mouse on the left and //
//right sides of the screen to move //
using UnityEngine;
using System;
using System.Collections.Generic;
public class DenomMaker
{
public static List<int> GetDenoms(int[] denoms, int totalValue, int numCoins)
{
List<int> resultCoins = new List<int>(numCoins+10);
@MattRix
MattRix / TrainyardTutorials.xml
Last active August 29, 2015 13:57
Trainyard Tutorials XML
<?xml version="1.0" encoding="UTF-8"?>
<tutorials>
<tutorial slug="welcome" name="Welcome!">
<!--welcome and explain goal of the game-->
<step>
<create_box xy="160,260">Welcome to TRAINYARD!</create_box>
<delay time="2" />
<reset_allActions />
<create_box xy="160,300">This tutorial will explain[br]how to solve puzzles</create_box>
@MattRix
MattRix / RXScroller.cs
Last active May 16, 2016 15:21
RXScroller generic scrolling logic.
using System;
using System.Collections.Generic;
using UnityEngine;
public class RXScroller
{
//note: these are not static in case you want to set them on a per-scroller basis
public float MAX_DRAG_SPEED = 20.0f; //maximum drag speed in pixels-per-update
public float EDGE_SQUISH = 60.0f; //how far to go past the end in pixels
@MattRix
MattRix / DZMenu.cs
Created April 28, 2014 17:55
Unity menu item to do iOS builds easily (make sure you put it in a folder named "Editor")
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
public class DZMenu
{
[MenuItem ("DiscoZoo/Build for iOS")]
static void BuildForIOS()
{