Skip to content

Instantly share code, notes, and snippets.

View fadookie's full-sized avatar
🕹️
😹

Eliot Lash fadookie

🕹️
😹
View GitHub Profile
@Protonz
Protonz / TweenObservable.cs
Last active February 26, 2018 19:46
Using UniRx to create a TweenStream
using System;
using System.Collections;
using UniRx;
using UnityEngine;
using System.Threading;
namespace UniRx {
public static partial class CustomObservable {
@HaleTom
HaleTom / git-quote-string-multiline
Created October 1, 2016 03:21
Quote a single- or multi-line string for use in git's aliases
#!/bin/bash -eu
# Quote a single- or multi-line string for use in git's aliases
# Copyright (c) 2016 Tom Hale under https://en.wikipedia.org/wiki/MIT_License
quote() {
printf %s "$1" | sed -r 's/(["\\])/\\\1/g';
}
IFS=$(printf '\n')
@scmx
scmx / react-proptype-warnings-as-errors-with-sinon.markdown
Last active March 1, 2019 08:42
Make React PropType warnings throw errors with mocha.js, enzyme.js and sinon.js

Make React PropType warnings throw errors with enzyme.js + sinon.js + mocha.js

A simple stateless functional component that we want to test that it renders without propType warnings.

import React, { PropTypes } from 'react'

let VersionListItem = function ({ active, version }) {
  return (
@Ragzouken
Ragzouken / Gist.cs
Last active December 8, 2021 21:32
simple gist thing for unity/c#
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Text;
namespace MakeGist
{
public class Gist
using UnityEngine;
using System.Collections;
using System;
using UnityEngine.Events;
using UnityEngine.UI;
using System.Collections.Generic;
public class Pigeons : MonoBehaviour
{
public class PigeonEvent<T> : UnityEvent<T>{}
@HilariousCow
HilariousCow / IntRangeDrawer
Last active September 26, 2021 13:57
A random int range unity data type with property drawer. FloatRange version here: https://gist.github.com/HilariousCow/1d056da2e3324670a087. Adapted from http://www.grapefruitgames.com/blog/2013/11/a-min-max-range-for-unity/
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
[CustomPropertyDrawer(typeof(IntRangeAttribute))]
public class IntRangeDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
@HilariousCow
HilariousCow / ExampleUse
Last active August 29, 2015 14:13
A Random float Range type: Adapted a bunch from http://www.grapefruitgames.com/blog/2013/11/a-min-max-range-for-unity/ ,When used, returns a random value between two ranges. IntRange coming soon...
//...
public class MyScript : MonoBehaviour
{
[FloatRange(-1f,1f)] //using this will make the randomModulator appear with double handles.
public FloatRange randomModulator;
@HilariousCow
HilariousCow / TransformExtensions
Created January 13, 2015 12:51
some handy extensions i use in unity to clean up pretty boring instantiate code
using UnityEngine;
using System.Collections;
public static class TransformExtensions
{
public static void SetLayer(this Transform trans, int layer)
{
trans.gameObject.layer = layer;
foreach(Transform child in trans)
child.SetLayer( layer);
@fadookie
fadookie / CameraAnchor.cs
Last active April 29, 2024 12:19
Screen-relative anchoring component for Unity3D. Find more Unity code at http://www.eliotlash.com/2015/01/unity3d-components-and-code-snippets/
/***
* This script will anchor a GameObject to a relative screen position.
* This script is intended to be used with ViewportHandler.cs by Marcel Căşvan, available here: http://gamedev.stackexchange.com/a/89973/50623
* It is also copied in this gist below.
*
* Note: For performance reasons it's currently assumed that the game resolution will not change after the game starts.
* You could not make this assumption by periodically calling UpdateAnchor() in the Update() function or a coroutine, but is left as an exercise to the reader.
*/
/* The MIT License (MIT)
@Fonserbc
Fonserbc / Easing.cs
Last active February 23, 2024 01:13
Compact and simple easing functions for Unity
using UnityEngine;
/*
* Most functions taken from Tween.js - Licensed under the MIT license
* at https://github.com/sole/tween.js
* Quadratic.Bezier by @fonserbc - Licensed under WTFPL license
*/
public delegate float EasingFunction(float k);
public class Easing