Skip to content

Instantly share code, notes, and snippets.

@sabresaurus
sabresaurus / PaletteWindow.cs
Last active September 27, 2023 19:50
Palette window with drag-drop boxes that you can drag common objects onto such as scenes, materials, prefabs to easily access them later (From SabreCSG originally)
// MIT License
//
// Copyright (c) 2021 Sabresaurus
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@yasirkula
yasirkula / UnitypackageExtractor.cs
Last active April 11, 2026 14:59
Extract a .unitypackage to any directory (even outside the project folder) from within Unity
#define STOP_EXTRACTION_WHEN_WINDOW_CLOSED
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Text;
using System.Threading;
using UnityEditor;
@mrkybe
mrkybe / BenchmarkSqrt.cs
Last active October 31, 2022 05:30
Benchmark Sqrt vs SqrMagnitude in Unity
/*
Results on a Ryzen 3800X, ymmv on mobile, but for desktop,
please just write legible code that conveys your intention.
Modern CPUs are fast.
All results are in milliseconds for 10,000,000 iterations.
In Editor:
Vector3.Distance: 437
(v1-v2).Magnitude: 567
@Manamongods
Manamongods / GizmosContextMenu.cs
Last active January 21, 2022 13:59
(For 2022.1) In new Unity versions, collapsing a component doesn't hide its gizmos anymore, which makes it slower to temporarily hide a component's gizmos. This helps that out by adding options to the right click, the context menu, of a component
// Creative Commons 0
#define SINGLE_BUTTON // Comment this if you want individual buttons
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;