Skip to content

Instantly share code, notes, and snippets.

View HilariousCow's full-sized avatar

Aubrey Hesselgren HilariousCow

  • Seattle
View GitHub Profile
@HilariousCow
HilariousCow / gist:9132977
Created February 21, 2014 11:47
Ribbon Shader (expands an infinitely thin ribbon using direction to camera, and direction to next/prev ribbon node)
Shader "BezzyLines/VertexTextureAlpha" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags
{
"Queue"="Transparent"

Keybase proof

I hereby claim:

  • I am hilariouscow on github.
  • I am hilariouscow (https://keybase.io/hilariouscow) on keybase.
  • I have a public key whose fingerprint is D7E0 4954 0961 1466 0D8D 0845 43DC 7BB1 6526 D32A

To claim this, I am signing this object:

@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);
@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 / 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 / BoundsHelperExtensions
Created February 24, 2015 10:19
A few helpful extensions to get the render bounds (world space) of a game object, including all its children. Handy for placement at the edges of groups of meshes/text, or finding dead center.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public static class BoundsHelperExtensions
{
public static Bounds WorldBounds<T>(this List<T> listOfThings) where T : MonoBehaviour
{
Bounds bounds = new Bounds(listOfThings[0].transform.position, Vector3.zero);
foreach (T thing in listOfThings)
@HilariousCow
HilariousCow / Vector3Extensions
Last active July 5, 2018 15:21
Just some handy vector3 extensions I use a lot. I like using "FlatY" a lot for games on 2D planes.
using UnityEngine;
using System.Collections;
public static class Vector3Extensions {
public static Vector3 Flattened(this Vector3 vec, Vector3 planeNormal)
{
return Vector3.ProjectOnPlane(vec, planeNormal);
}
public class OneOneOneTwoThree
{
bool[] Null(bool[] t)
{
return t;// lol
}
bool[] Swap(bool[] t)
{
bool[] s = new bool[4];
@HilariousCow
HilariousCow / gist:7f301b04c28fdf61e71f
Last active March 31, 2024 18:33
Load All Prefabs In Directory
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
public static class PrefabLoader
{
//So, there's no "load all assets in directory" function in unity.
//I guess this is to avoid people using Prefabs as "data blobs".
//They'd rather you use ScriptableObjects... which is fine in some cases,
@HilariousCow
HilariousCow / VertexAlphaPlusColor
Last active December 16, 2015 13:14
So, blender doesn't do vertex alpha, annoyingly, which would be great, as it's a good way to mask out edges of meshs when you have other groovey effects going on the surface (think skyrim's wind gusts). This shader will just take blender's RGB values (i.e. luminescance) and use THAT as the alpha mask. It's otherwise a bog standard Texture * colo…
Shader "Unlit/VertexAlphaPlusColour"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Opaque" }