Skip to content

Instantly share code, notes, and snippets.

View Valeour's full-sized avatar

Chance Millar Valeour

View GitHub Profile
@Valeour
Valeour / DebugToggle.cs
Last active August 18, 2021 15:43
Toggle Unity Inspector between Debug and Normal.
/// Debug Toggle by Chance Millar 18/11/18
using System;
using System.Reflection;
using UnityEditor;
// Used to provide a shortcut for toggling Unity's Debug/Normal mode on the inspector.
// Place inside a folder named "Editor" for Unity to compile correctly.
// Will only work on a single inspector window, not all of them.
// Use Ctrl/Cmd+G to activate. Refer to the Shortcut manager to change the shortcut.
@Valeour
Valeour / BoolPool.cs
Created November 18, 2018 19:24
BoolPool: Using ints as bools instead of wasting 7 bits. Creates an internal int array to accomodate as many bools needed.
/// BoolPool by Chance Millar 18/11/18
using UnityEngine;
/// Class is used to create a pool of bits to be used as bools.
/// Bools typically take up 1 byte (8bits), which is a collosal waste of space.
/// This class is overall slower than just an array of bools, however the memory footprint is significantly smaller. (655464 bools array is around 512kb, however using ints will reduce it to around 17kb)
/// This class converts integer types into a collection of boots. An int is 4 bytes / 32 bits, so that's 32 bools to be used.
/// If you need a smaller footprint, converting the ints into bytes as appropriate works too, but you'll need to do some casting depending on the C# version you're on.
[System.Serializable]
@Valeour
Valeour / PreferencesWindow.cs
Last active September 8, 2018 15:23
Open Unity Preferences Window with Section
/**
* PreferenceWindow helper created by Chance Millar at Two Tails Games on 2018/07/24
* Use freely. That's a license, right?
*
* Be sure to place in an Editor folder inside Assets.
*/
using System;
using System.Collections;
using System.Reflection;
@Valeour
Valeour / GradientHDRAttribute.cs
Last active March 29, 2024 08:14
Unity C# Attribute to enable HDR Gradient fields in the Inspector.
/**
* GradientHDRAttribute created by Chance Millar at Two Tails Games on 2018/05/08
* Use freely. That's a license, right?
*
* Attach attribute like so:
*
* [GradientHDR]
* public Gradient _HDRGradient;
*
* Make sure this is placed in a non-Editor folder inside Assets.