Skip to content

Instantly share code, notes, and snippets.

View simonwittber's full-sized avatar

Simon Wittber simonwittber

  • Different Methods
  • Australia
View GitHub Profile
@simonwittber
simonwittber / CommandGizmos.cs
Created February 14, 2018 10:50
SceneView Gizmos labels that don't create clutter.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public static class CommandGizmos
{
static GUIStyle sceneNote;
static CommandGizmos()
@simonwittber
simonwittber / PaletteWizard.cs
Created February 13, 2018 13:57
A Unity wizard to generate a palette from a source image.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class PaletteWizard : ScriptableWizard
{
public Texture2D sourceImage;
[Range(1, 5)]
@simonwittber
simonwittber / SceneContext.cs
Created February 7, 2018 15:55
Add an "OnContextClick" message to any open Unity Editors.
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Reflection;
[InitializeOnLoad]
public static class SceneContext
{
static System.Diagnostics.Stopwatch clickClock;
@simonwittber
simonwittber / ComponentPool.cs
Last active May 17, 2021 12:06
The last game object pool you will ever need... maybe.
using System.Collections.Generic;
using UnityEngine;
public class ComponentPool<T> where T : Component
{
static ComponentPool<T> Instance = new ComponentPool<T>();
Dictionary<int, Stack<T>> pools = new Dictionary<int, Stack<T>>();
Dictionary<int, int> instances = new Dictionary<int, int>();
@simonwittber
simonwittber / Interpolation.cs
Last active December 28, 2017 09:50
Linear interpolation is boring...
using System.Runtime.CompilerServices;
using UnityEngine;
/// <summary>
/// Convert linear 0.0f - 1.0f values to some other non-linear value.
/// </summary>
public static class Interpolation
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Boing(float v) => (Mathf.Sin(v * Mathf.PI * (0.2f + 2.5f * v * v * v)) * Mathf.Pow(1f - v, 2.2f) + v) * (1f + (1.2f * (1f - v)));