Skip to content

Instantly share code, notes, and snippets.

@FreyaHolmer
FreyaHolmer / GpuPrinter.cginc
Last active March 16, 2025 05:51
A unity shader .cginc to draw numbers in the fragment shader - see the first comment below for example usage!
///////////////////////////////////////////////////////////////////////////////
// ABOUT: A unity Shader .cginc to draw numbers in the fragment shader
// AUTHOR: Freya Holmér
// LICENSE: Use for whatever, commercial or otherwise!
// Don't hold me liable for issues though
// But pls credit me if it works super well <3
// LIMITATIONS: There's some precision loss beyond 3 decimal places
// CONTRIBUTORS: yes please! if you know a more precise way to get
// decimal digits then pls lemme know!
// GetDecimalSymbolAt() could use some more love/precision
@unitycoder
unitycoder / DelaunayTriangulation.cs
Created July 29, 2023 18:58
2D Delaunay Triangulation in single C# script (Bowyer–Watson algorithm)
// https://forum.unity.com/threads/programming-tools-constrained-delaunay-triangulation.1066148/#post-9180485
// https://en.wikipedia.org/wiki/Bowyer%E2%80%93Watson_algorithm
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DelaunayTriangulation : MonoBehaviour
{
    public int VertexCount = 128;
    Material _Material;
    List<Triangle> _Triangles = new List<Triangle>();
@unitycoder
unitycoder / MeshCut.cs
Created April 3, 2023 16:27 — forked from alexcmd/MeshCut.cs
Mesh cut algorithm for Unity
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MeshCut
{
private static Plane blade;
private static Transform victim_transform;
private static Mesh victim_mesh;
@davidjmallar
davidjmallar / gist:f41942abe57577c1c86576ff03d332df
Created June 7, 2022 09:20
Unity AddNextSprite button with OdinInspector
using Sirenix.OdinInspector;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using System;
public class MyUnityObject : MonoBehaviour {
[InlineButton("AddNextAnimationSprite", "Add Next")]
[PreviewField(ObjectFieldAlignment.Left, Height = 50)]
@totallyRonja
totallyRonja / MaterialGradientDrawer.cs
Last active March 31, 2025 13:38
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;
@IronWarrior
IronWarrior / UnityProjectJunctionTool.cs
Last active February 18, 2025 07:15
Unity editor tool to create dummy Unity projects to allow a single project to be open in multiple editor instances.
// gist by Roystan (IronWarrior): https://gist.github.com/IronWarrior/005f649e443bf51b656729231d0b8af4
// Video demo: https://twitter.com/DavigoGame/status/1300842800964018178
//
// CONTRIBUTIONS:
// Mac and Linux support added by Creature Coding: https://creaturecoding.com/
//
// PURPOSE:
// Unity does not permit a project to be open in two different editor instances.
// This can be frustrating when building projects with multiplayer networking,
// as it would require you to create a build every time you wish you test your netcode.
@JimmyCushnie
JimmyCushnie / UnityGraphicsBullshit.cs
Last active February 19, 2025 10:59
Exposes some Unity URP graphics settings that are (for some stupid fucking bullshit reason) private.
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;
/// <summary>
/// Enables getting/setting URP graphics settings properties that don't have built-in getters and setters.
even_letters = "bcdfghlmnprstwx"
odd_letters = "aeiou"
def format_uid_digit (n, level):
if n != 0:
letters = odd_letters if (level & 1) else even_letters
base = len(letters)
s = format_uid_digit(n / base, level + 1)
return s + letters[(n % base)]
return ""
@JohannesMP
JohannesMP / UIBlur.shader
Last active February 24, 2025 11:32
UI.Image Blur Shader with layering and masking support
Shader "Custom/UIBlur"
{
Properties
{
[Toggle(IS_BLUR_ALPHA_MASKED)] _IsAlphaMasked("Image Alpha Masks Blur", Float) = 1
[Toggle(IS_SPRITE_VISIBLE)] _IsSpriteVisible("Show Image", Float) = 1
// Internally enforced by MAX_RADIUS
_Radius("Blur Radius", Range(0, 64)) = 1
@LotteMakesStuff
LotteMakesStuff / NativeMeshTest.cs
Created August 8, 2018 00:30
[NativeCollections] How to copy a regular .C# array into a NativeArray suuuuuper quick using memcpy. its about as fast as its ever gunna get!
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Mathematics;
using UnityEngine;
public class NativeMeshTest : MonoBehaviour
{
private NativeArray<float3> vertexBuffer;
private Vector3[] vertexArray;