Skip to content

Instantly share code, notes, and snippets.

View Madgvox's full-sized avatar
🤖
I am not a robot.

Nate Tessman Madgvox

🤖
I am not a robot.
View GitHub Profile
@Madgvox
Madgvox / GameStateUtility.cs
Last active March 6, 2022 06:31
Unity: Expose an isQuitting variable to use when spawning things in OnDestroy
public static class GameStateUtility {
public static bool isQuitting { get; private set; }
[RuntimeInitializeOnLoadMethod( RuntimeInitializeLoadType.SubsystemRegistration )]
static void Init () {
isQuitting = false;
Application.quitting += () => {
isQuitting = true;
};
@Madgvox
Madgvox / aseprite_layer_and_tag_data.lua
Last active October 7, 2020 20:26
Generates layer and tag data (a la the --data cli option) for an aseprite file, but includes proper layer hierarchy information as well as tag colors.
local spr = app.activeSprite
if not spr then return app.alert "No active sprite" end
local function color_byte_to_string( col )
local hex = ''
while(col > 0)do
local index = math.fmod(col, 16) + 1
col = math.floor(col / 16)
hex = string.sub('0123456789abcdef', index, index) .. hex
Shader "Custom/WorldSpaceClip" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_InteriorColor( "Interior Color", Color ) = ( 1,1,1,1 )
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_ClipOffset ( "Clip Height", Float) = 10.0
}
@Madgvox
Madgvox / RandomizerWindow.cs
Last active March 17, 2022 23:08
Creates a Randomizer window for Unity 3D that allows for the modification of position, rotation, and scaling of selected objects.
/*
* Simple Attribute Randomizer
* Access via Tools/Randomizer
* @madgvox
*/
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine;
using System.Collections.Generic;
using System;
[ExecuteInEditMode]
[RequireComponent( typeof( MeshFilter ), typeof( MeshRenderer ) )]
public class StrandRenderer : MonoBehaviour {
public StrandRenderer child;
[HideInInspector]
public MeshFilter filter;