Skip to content

Instantly share code, notes, and snippets.

--!strict
--!native
--Polychrome effect - tag MeshParts with "Polychrome"
--Rewrites an editable image with some precalculate buffers each frame (because raw editableimages are memory capped!)
--Default values use about 30mb, but you can easily reduce/increase this with these two variables
--Try and be sane :)
local size : number = 128
local frameCount : number = 500
@adammyhre
adammyhre / SineWaveInstanced.cs
Created March 23, 2025 08:45
GPU Instancing Example Unity 6
using System.Collections.Generic;
using UnityEngine;
public class SineWaveInstanced : MonoBehaviour {
#region Fields
public GameObject sample;
public Mesh mesh;
public Material material;
@adammyhre
adammyhre / DamageNumberSpawner.cs
Last active July 28, 2025 20:56
World Space UI Toolkit
using PrimeTween;
using UnityEngine;
using UnityEngine.Pool;
using UnityUtils;
public class DamageNumberSpawner : MonoBehaviour {
[SerializeField] WorldSpaceUIDocument uiDocumentPrefab;
[SerializeField] float positionRandomness = 0.2f;
IObjectPool<WorldSpaceUIDocument> uiDocumentPool;
@adammyhre
adammyhre / GridManager.cs
Created February 9, 2025 12:23
Tactical Pathfinding for A*
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using TMPro;
public struct Node {
public Vector3 position;
public bool isWalkable;
public Node(Vector3 position, bool isWalkable = false) {
@adammyhre
adammyhre / AnyValue.cs
Created January 19, 2025 08:11
Serialized Callback System
using System;
using UnityEngine;
public enum ValueType { Int, Float, Bool, String, Vector3 }
[Serializable]
public struct AnyValue {
public ValueType type;
// Storage for different types of values
@adammyhre
adammyhre / PackageManagerHelper.cs
Last active August 11, 2025 22:42
Faster Unity Asset Importer (for use with Setup Script)
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
public static class PackageManagerHelper {
const string ServicesNamespace = "UnityEditor.PackageManager.UI.Internal";
/// <summary>
/// Resolves a PackageManager service by its interface name.
@adammyhre
adammyhre / HierarchyIconDrawer.cs
Created November 9, 2024 16:54
Unity Hierarchy Icons
using UnityEditor;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
[InitializeOnLoad]
public static class HierarchyIconDrawer {
static readonly Texture2D requiredIcon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/_Project/Art/RequiredIcon.png");
@yasirkula
yasirkula / CommentComponent.cs
Created November 4, 2024 19:15
Adding comments to Inspector via a component in Unity
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
[AddComponentMenu("Comment")]
public class CommentComponent : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField]
@keijiro
keijiro / FpsCapper.cs
Last active September 24, 2025 21:29
FpsCapper - Limits the frame rate of the Unity Editor in Edit Mode
using UnityEditor;
using UnityEngine;
using UnityEngine.LowLevel;
using System.Linq;
using System.Threading;
namespace EditorUtils {
//
// Serializable settings
@runevision
runevision / BurstSDFGenerator.cs
Created September 11, 2024 07:48
Signed Distance Field generator for Unity with Burst support
/*
Based on the Anti-aliased Euclidean distance transform described by Stefan Gustavson and
Robin Strand. For further information, see https://contourtextures.wikidot.com/ and
https://web.archive.org/web/20220503051209/https://weber.itn.liu.se/~stegu/edtaa/
The algorithm is an adapted version of Stefan Gustavson's code, it inherits the copyright
statement below, which applies to this file only.
The rewrite with Unity Burst support makes the execution 40 times faster by default,
and 75 times faster if the passed in textures are both of type TextureFormat.RGBAFloat.