Skip to content

Instantly share code, notes, and snippets.

@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active September 26, 2023 09:46
A Material Property Drawer for the [Gradient] attribute which lets you edit gradients and adds them to the shader as textures. More information here: https://twitter.com/totallyRonja/status/1368704187580682240
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public class MaterialGradientDrawer : MaterialPropertyDrawer {
private int resolution;
using UnityEngine;
using UnityEditor;
public class HeightmapFromTexture{
[MenuItem ("Terrain/Heightmap From Texture")]
public static void ApplyHeightmap () {
var heightmap = Selection.activeObject as Texture2D;
if (heightmap == null) {
EditorUtility.DisplayDialog("No texture selected", "Please select a texture.", "Cancel");
@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
@Bradshaw
Bradshaw / Gifify.cs
Last active February 27, 2017 18:43
Drop this into a UnityProject, attach it to a GameObject, customise the values if necessary, and then hold down the key you selected to capture images that you can gifify later.
using UnityEngine;
using System.Collections;
using System.IO;
/*
Gifify.cs
Author: Kevin "Gaeel" Bradshaw
Drop this into a UnityProject, attach it to a GameObject, customise the values if necessary, and then hold down the key you selected to capture images that you can gifify later.
@wonkwh
wonkwh / unpack_plist.py
Created July 19, 2013 10:22
extract image from plist,png file created by texturepacker
#/usr/local/bin/python
import os,sys
from xml.etree import ElementTree
from PIL import Image
def tree_to_dict(tree):
d = {}
for index, item in enumerate(tree):
if item.tag == 'key':
if tree[index+1].tag == 'string':