Skip to content

Instantly share code, notes, and snippets.

@FreyaHolmer
FreyaHolmer / int2.cs
Last active November 2, 2023 15:59
int2 type for Unity
/////////////////////////////////////////////////////////////////////////////
// int2 is similar to Vector2, but with integers instead of floats
// Useful for various grid related things.
//
// - Swizzle operators xx/xy/yx/yy
// - Extended arithmetic operators similar to shader data types
// A few examples:
// int2(8,4) / int2(2,4) -> int2(4,1)
// 16 / int2(2,4) -> int2(8,4)
// int2(2,3) * int2(4,5) -> int2(8,15)
@AngryAnt
AngryAnt / MoveComponentContext.cs
Last active July 5, 2017 05:44
Adds "Move to Top" and "Move to Bottom" items to the inspector context menu of components.
using UnityEngine;
using UnityEditor;
public class MoveComponentContext
{
enum Destination
{
Top,
Bottom
///
/// Simple pooling for Unity.
/// Author: Martin "quill18" Glaude (quill18@quill18.com)
/// Latest Version: https://gist.github.com/quill18/5a7cfffae68892621267
/// License: CC0 (http://creativecommons.org/publicdomain/zero/1.0/)
/// UPDATES:
/// 2015-04-16: Changed Pool to use a Stack generic.
///
/// Usage:
///
@FreyaHolmer
FreyaHolmer / ScriptableObjectSpawner.cs
Last active January 8, 2020 06:51
ScriptableObject asset spawner for Unity
// Adds a menu item for easy creation of your ScriptableObject types
// Usage: Right click in project view -> Create -> ScriptableObject... -> Select your type
// It will land in the root of your assets folder with the same name as your class
// Freya Holmér - webmaster@acegikmo.com
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System.Linq;
using System.IO;
@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
@benblo
benblo / EditorCoroutine.cs
Created April 15, 2014 13:26
EditorCoroutine: coroutines for Unity editor operations. Usage: EditorCoroutine.start(myIEnumerator)
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
namespace Swing.Editor
{
public class EditorCoroutine