Skip to content

Instantly share code, notes, and snippets.

@adammyhre
adammyhre / RadialMenuRoot.uxml
Created April 12, 2026 11:06
UI Toolkit radial menu that uses the Painter API and Unity 6.3 gradients, layout, rendering, and input selection.
<ui:UXML xmlns:ui="UnityEngine.UIElements" editor-extension-mode="False">
<Style src="RadialMenuStyles.uss" />
<ui:VisualElement name="radial-root" class="radial-root" picking-mode="Ignore">
<ui:VisualElement name="dimmer" class="radial-dimmer" picking-mode="Position" />
<ui:VisualElement name="wheel" class="radial-wheel" picking-mode="Ignore">
<ui:VisualElement name="items-host" class="radial-items-host" picking-mode="Position" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
@adammyhre
adammyhre / SimpleBuildPart.cs
Created April 5, 2026 10:38
A simple Unity survival building system using modular pieces and socket-based snapping for clean placement.
using UnityEngine;
public enum SimpleBuildPieceType { Floor, Wall, Door }
public class SimpleBuildPart : MonoBehaviour {
[SerializeField] SimpleBuildPieceType pieceType = SimpleBuildPieceType.Floor; // identity for occupancy and placer logic
public SimpleBuildPieceType Type => pieceType;
public void SetPieceType(SimpleBuildPieceType value) => pieceType = value;
@adammyhre
adammyhre / SceneDirtyDiagnostics.cs
Created March 21, 2026 07:30
Unity Editor Tool: Finding What Marks Scenes Dirty
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;
using Debug = UnityEngine.Debug;
@adammyhre
adammyhre / DataBindingHelper.cs
Created January 18, 2026 13:52
Helper to Abstract Runtime Data Binding Methods
using UnityEngine;
using UnityEngine.UIElements;
using Unity.Properties;
public static class DataBindingHelper {
static string GetDefaultTargetProperty<T>() where T : VisualElement {
return typeof(T) == typeof(Label) ? "text" : "value";
}
/// <summary>
@adammyhre
adammyhre / MainToolbarButtons.cs
Created December 28, 2025 13:08
Unity 6.3 Custom Main Toolbar
using UnityEditor;
using UnityEditor.Toolbars;
using UnityEngine;
using UnityEngine.UIElements;
public class MainToolbarButtons {
[MainToolbarElement("Project/Open Project Settings", defaultDockPosition = MainToolbarDockPosition.Middle)]
public static MainToolbarElement ProjectSettingsButton() {
var icon = EditorGUIUtility.IconContent("SettingsIcon").image as Texture2D;
var content = new MainToolbarContent(icon);
@adammyhre
adammyhre / content.js
Created December 24, 2025 11:45
Udemy Progress Tooltip 2026 (Chrome Extension)
(async function () {
// ================= utilities =================
function secondsToHMS(seconds) {
seconds = Math.floor(seconds);
const h = Math.floor(seconds / 3600);
const m = Math.floor((seconds % 3600) / 60);
const s = seconds % 60;
return `${h}h ${m}m ${s}s`;
@adammyhre
adammyhre / CrowdInstance.shader
Created December 21, 2025 12:25
Compute Shader Example
Shader "Crowd/InstancedAgent" {
SubShader {
Tags { "RenderPipeline"="UniversalRenderPipeline" "RenderType"="Opaque" }
Pass {
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
# Unity text-based assets that are safe for Smart Merge / YAMLMerge
*.unity merge=unityyamlmerge
*.prefab merge=unityyamlmerge
*.mat merge=unityyamlmerge
*.physicMaterial merge=unityyamlmerge
*.physicsMaterial2D merge=unityyamlmerge
*.controller merge=unityyamlmerge
*.anim merge=unityyamlmerge
*.overrideController merge=unityyamlmerge
*.mask merge=unityyamlmerge
@adammyhre
adammyhre / Processor.cs
Created November 23, 2025 10:36
Generic Processing Chains
using System;
using UnityEngine;
public interface IProcessor<in TIn, out TOut> {
TOut Process(TIn input);
}
public delegate TOut ProcessorDelegate<in TIn, out TOut>(TIn input);
public class ThresholdFilter : IProcessor<float, bool> {
@adammyhre
adammyhre / CharacterStateMachine.cs
Last active January 18, 2026 02:51
Curiously Recurring Template Pattern (CRTP) in C#
using System.Collections.Generic;
using UnityEngine;
public class MoveState : CharacterState<MoveState> {
protected override void OnEnter() {
Debug.Log("#State# Entered Move");
}
protected override void OnExit() {
Debug.Log("#State# Exited Move");