Skip to content

Instantly share code, notes, and snippets.

@JochenHeckl
JochenHeckl / GenerateTagsAndLayers.cs
Last active March 26, 2026 07:47
Unity Editor script to generate constants for layer names.
// Find the newest version of this code here:
// https://gist.github.com/JochenHeckl/7775fd206671a347ddf6b375f08219fc
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
public static class TagsAndLayersConstantsGenerator
{
@JochenHeckl
JochenHeckl / VisualElementStyleExtensions.cs
Last active December 24, 2024 12:23
Unity UI Toolkit - VisualElement Style Extensions
using UnityEngine;
using UnityEngine.UIElements;
public static class VisualElementStyleExtensions
{
public static StyleLength FromPixels(int pixels)
{
return new StyleLength(new Length(pixels, LengthUnit.Pixel));
}
@JochenHeckl
JochenHeckl / IPAddressFromHostname.cs
Created February 23, 2024 06:45
c# System.Net.IPAddress From hostname
using System.Net;
var ipv6Address = Dns.GetHostAddresses(hostname)
.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetworkV6);
var ipAddress = Dns.GetHostAddresses(hostname)
.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);
var address = ipv6Address ?? ipAddress;
@JochenHeckl
JochenHeckl / flutterDevShell.ps1
Last active March 26, 2026 07:03
PowerShell script to install Flutter environment
function Install-Flutter {
if (Test-Path flutter -PathType Container) {
Write-Host("Assuming flutter is installed in $PSScriptRoot/flutter");
}
else {
Write-Host('Downloading flutter to $PSScriptRoot/flutter');
git clone https://github.com/flutter/flutter.git $PSScriptRoot/flutter -b stable
}
$env:Path += ";$PSScriptRoot/flutter/bin"
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using UnityEngine;
public class TimeSampler<SampleKeyType>
{
private struct SampleData