Skip to content

Instantly share code, notes, and snippets.

@adammyhre
adammyhre / HeatmapCompute.compute
Last active April 13, 2025 18:14
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 / AnimationController.cs
Created May 25, 2025 10:13
Animation Controller
using ImprovedTimers;
using UnityEngine;
namespace AdvancedController {
[RequireComponent(typeof(PlayerController))]
public class AnimationController : MonoBehaviour {
PlayerController controller;
Animator animator;
CountdownTimer animationTimer;
@adammyhre
adammyhre / AbilityData.cs
Created May 25, 2025 10:34
Modular Ability Effects
using System;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "AbilityData", menuName = "ScriptableObjects/AbilityData")]
class AbilityData : ScriptableObject {
public string label;
public AnimationClip animationClip;
[Range(0.1f, 4f)] public float castTime = 2f;
@adammyhre
adammyhre / ArenaAllocator.cs
Created June 8, 2025 07:18
Unity Memory Arena
using System;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
public unsafe class ArenaAllocator : IDisposable {
byte* buffer; // 'buffer' is a pointer to a byte (i.e., byte*)
int offset;
readonly int capacity;
public ArenaAllocator(int sizeInBytes) {