Skip to content

Instantly share code, notes, and snippets.

View MattRix's full-sized avatar

Matt Rix MattRix

View GitHub Profile
@munkbusiness
munkbusiness / EmoPacker.cs
Last active May 29, 2024 16:38 — forked from MattRix/EmoPacker.cs
2022 version of the EmoPacker script that creates a image for a TMP sprite asset to use. There is still some wierd issues, with files needing to be exist already, and the TMP asset is updating wierdly. Specifically instead of using metadata it now uses the new spriterects, which is the replacement.
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using TMPro;
using UnityEditor.U2D.Sprites;
public class EmoPacker
{
@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>();
@WahlbeckUEFN
WahlbeckUEFN / boss_fight.verse
Created May 10, 2023 00:16
Code for boss fight and health bar in UEFN and Verse
using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/UI }
using { /UnrealEngine.com/Temporary/SpatialMath}
using { /Verse.org/Colors }
@h3r2tic
h3r2tic / raymarch.hlsl
Last active April 14, 2025 09:52
Depth buffer raymarching for contact shadows, SSGI, SSR, etc.
// Copyright (c) 2023 Tomasz Stachowiak
//
// This contribution is dual licensed under EITHER OF
//
// Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
// MIT license (http://opensource.org/licenses/MIT)
//
// at your option.
#include "/inc/frame_constants.hlsl"
@ChristopherSchubert
ChristopherSchubert / EditorGUIIconGenerator.cs
Last active October 23, 2024 14:33
This script makes using Unity3D EditorGUI icons simple. It should work in any version of the Editor, because it scans the editor for icons rather than hard-coding them. Drop the script in your project, and then navigate to the menu "Tools > EditorGUI Icons > Explore". The UI will show you the icons, let you regex search them, and if you click th…
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditor.Experimental;
using UnityEngine;
@mattyellen
mattyellen / UnityAsyncOperationAwaiter.cs
Created July 26, 2020 19:36
Allows the use of async/await (instead of yield) with any Unity AsyncOperation
public static class ExtensionMethods
{
public static TaskAwaiter GetAwaiter(this AsyncOperation asyncOp)
{
var tcs = new TaskCompletionSource<object>();
asyncOp.completed += obj => { tcs.SetResult(null); };
return ((Task)tcs.Task).GetAwaiter();
}
}
@AsherVo
AsherVo / RequireReferenceAlert.cs
Last active October 26, 2020 04:03
Using unity's standard ObjectField in RequireReferenceDrawer to fix bugs and improve prefab workflow.
// PLEASE NOTE: This will add ~1sec to your save time
// If that is unacceptable (which it was to me), then you can change all the
// references to "MonoBehaviour" in this file to your own custom behaviour type
// that this script will search through each time you save
using UnityEditor;
using UnityEngine;
using System.Linq;
using System.Reflection;
using System.Collections;
@sinbad
sinbad / SpriteMeshRaycastFilter.cs
Last active May 11, 2023 05:35
SpriteMeshRaycastFilter: easy Unity UI non-rectangular click detector without reading textures
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
// Restrict raycasting to a sprite mesh shape
// Could use Image.alphaHitTestMinimumThreshold to mask but that requires read/write images which can't be packed
[RequireComponent(typeof(Image))]
public class SpriteMeshRaycastFilter : MonoBehaviour, ICanvasRaycastFilter {
private RectTransform rectTransform;
@MattRix
MattRix / EditorZoomer.cs
Created October 27, 2019 23:18
EditorZoomer - an easy way to do panning and zooming inside Unity Editor IMGUI
using UnityEngine;
using System.Collections;
using System;
//based on the code in this post: http://martinecker.com/martincodes/unity-editor-window-zooming/
//but I changed how the API works and made it much more flexible
//usage: create an EditorZoomer instance wherever you want to use it (it tracks the pan + zoom state)
//in your OnGUI, draw your scrollable content between zoomer.Begin() and zoomer.End();
//you also must offset your content by zoomer.GetContentOffset();
@Split82
Split82 / UnityShadersCheatSheet.shader
Created April 17, 2018 10:07
Unity Shaders Cheat Sheet
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)