Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@adrenak
adrenak / BoxColliderEditFaceCenterDots.cs
Last active April 22, 2026 06:04
BoxColliderEditFaceCenterDots makes resizing BoxColiders easy
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.EditorTools;
using UnityEngine;
using UnityEngine.Rendering;
/// <summary>
/// While Unity’s built-in box collider edit tool is active, draws camera-facing
"""
The most atomic way to train and run inference for a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@meredoth
meredoth / Check-Discourse-Topic-Links.ps1
Last active August 3, 2025 13:33
A PowerShell script that takes a Discourse topic URL and prints all posts containing external links. This is useful for identifying spam posts that hide links in subtle places, such as within commas or periods. If a post seems suspicious, run this script with the Discourse topic URL as a parameter to display all external links found in the posts.
@adammyhre
adammyhre / HeatmapCompute.compute
Last active April 7, 2026 09:07
Compute Shader + Render Feature Heatmap
#pragma kernel CSMain
RWTexture2D<float> heatmapTexture;
float2 texSize;
StructuredBuffer<float2> enemyPositions;
int enemyCount;
[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
@adammyhre
adammyhre / DamageNumberSpawner.cs
Last active January 20, 2026 14:13
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;
@stenuto
stenuto / hls.sh
Created November 7, 2024 16:58
HLS ffmpeg script
#!/bin/bash
# Function to display usage information
usage() {
echo "Usage: $0 /path/to/input.mp4 [ /path/to/output_directory ]"
exit 1
}
# Check if at least one argument (input file) is provided
if [ $# -lt 1 ]; then
@keijiro
keijiro / FpsCapper.cs
Last active March 17, 2026 06:10
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
@ryan-at-melcher
ryan-at-melcher / LayerFieldAttribute.cs
Created August 21, 2024 17:58
A simple attribute for Unity to display an int field in the inspector as a GameObject layer dropdown that is limited to one selection.
using UnityEngine;
/// <summary>
/// Allows a single GameObject layer to be selected from the inspector when applied to an
/// <see langword="int" /> field. Intended to be used when a <see cref="LayerMask" />'s
/// multiselection is not suitable.
/// </summary>
public class LayerFieldAttribute : PropertyAttribute
{
}
@ryan-at-melcher
ryan-at-melcher / WorldSpaceHandVisual.cs
Last active November 26, 2025 10:01
Unity fix for OVRControllerHands prefab incorrectly positioning synthetic hands using a local-pose rather than world-pose.
using Oculus.Interaction;
using Oculus.Interaction.Input;
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Renders the hand.
/// <br /><br />
///
@runevision
runevision / BurstMethodTester.cs
Last active February 27, 2026 22:09
Using Unity Burst directly on methods without jobs - unofficial example code
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine;
// This example code demonstrates using Unity Burst directly on a static method without jobs.
// Unity NativeArrays can't be used directly in Unity Burst methods (only in Burst jobs),
// so we have to pass pointers to arrays instead.