Skip to content

Instantly share code, notes, and snippets.

View stonstad's full-sized avatar

Shaun Tonstad stonstad

View GitHub Profile
This file has been truncated, but you can view the full file.
using System.Collections.Generic;
using Unity.Scripting.LifecycleManagement;
public class ReferenceType
{
public int Value01 = 1;
public int Value02 = 2;
public int Value03 = 3;
public int Value04 = 4;
public int Value05 = 5;
@stonstad
stonstad / Program.cs
Last active August 5, 2026 19:26
Benchmark: Reset Static State for 1000 Types
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace StaticResetBenchmark;
public abstract class StaticStateMarker
{
}
using System;
using System.Collections.Generic;
using System.Text.Json;
using NUnit.Framework;
using Unity.PerformanceTesting;
using UnityEngine;
public class JsonSerializationPerformanceTests
{
private const int ItemCount = 1000;
@stonstad
stonstad / FrameTimingScript.cs
Last active February 28, 2026 21:51
FrameTimingScript
using UnityEngine;
public class FrameTimingScript : MonoBehaviour
{
public float intervalSeconds = 1f;
private readonly FrameTiming[] _timings = new FrameTiming[1];
private double _cpuSumMs;
private int _cpuSamples;
private void AddGreedyQuad(float x, float y, float z, int axisU, int axisV, int axisD, int width, int height, int faceDir,
List<Vector3> verts, List<int> tris, List<Vector2> uvs)
{
float p0x;
float p0y;
float p0z;
float p1x;
float p1y;
float p1z;
using System;
using UnityEngine;
using UnityEngine.Rendering;
using Random = System.Random;
namespace StellarConquest.Presentation.Unity
{
public class StarfieldMeshBuilder : MonoBehaviour
{
public float SphereRadius = 4000;
@stonstad
stonstad / gist:5bc490365ad72b10a65b6ed3bcb9a6bb
Created June 27, 2025 12:02
Disable Windows 11 Game Bar
The Windows 11 Game Bar process causes Unity editor and Unity built games to freeze when the parent window is resized.
Powershell (Admin)
Get-AppxPackage Microsoft.XboxGamingOverlay | Remove-AppxPackage
reg add HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR /f /t REG_DWORD /v "AppCaptureEnabled" /d 0
reg add HKEY_CURRENT_USER\System\GameConfigStore /f /t REG_DWORD /v "GameDVR_Enabled" /d 0
@stonstad
stonstad / Bootloader.cs
Created June 10, 2025 13:14
Example Unity Scene Bootloader w/ Local Physics
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
namespace Example
{
@stonstad
stonstad / BenchmarkCustomColumn.cs
Last active April 22, 2024 15:03
BenchmarkDotNet Metadata Column
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using System.Linq;
namespace Example.Benchmarking
{
public class BenchmarkCustomColumn : IColumn
{
public string Id => nameof(BenchmarkCustomColumn);
@stonstad
stonstad / GPTClient.cs
Last active September 14, 2023 13:58
Simple GPT-3.5-Turbo C# Client
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace GPTClient
{
class Program
{
static async Task Main(string[] args)