Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / microgpt.py
Created February 12, 2026 07:03 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference 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
@unitycoder
unitycoder / fetch_vcdist.py
Created February 6, 2026 14:37 — forked from donno/fetch_vcdist.py
Downloads and extract the Visual C++ Redistributables.
"""Downloads and extract the Visual C++ Redistributables.
This is useful when working with minidump files as the user may be running
with a new different version of the runtime. This script aims to maintain
a copy of the various versions.
Versions are normally added once I encounter them, in November 2022, I added
a rather large back catalogue of versions.
This requires dark.exe from Wix (http://wixtoolset.org/releases/) and
@unitycoder
unitycoder / tgf-midi-extractor.mjs
Created January 2, 2026 11:13 — forked from nathnolt/tgf-midi-extractor.mjs
The Games Factory .gam 0C_Music.mus music file to midis converter
// The Games Factory 0C_Music.mus -> midi files
// See the following tool for actually extracting the 0C_Music.mus file from a .gam file
// https://kippykip.com/threads/cextract-the-games-factory-multimedia-fusion-game-extractor-unprotector.498/
//
import fs from 'fs'
const input = './0C_Music.mus'
const buffer = fs.readFileSync(input)
@unitycoder
unitycoder / Unity-hotswapping-notes.md
Created November 26, 2025 12:54 — forked from cobbpg/Unity-hotswapping-notes.md
Unity hotswapping notes

Unity hotswapping notes

Unity has built-in support for hotswapping, which is a huge productivity booster. This feature works not only with graphics assets like bitmaps and meshes, but also with code: if you edit the source and save it, the editor will save the state of the running game, compile and load the new code, then load the saved state and continue where it left off. Unfortunately, this feature is very easy to break, and most available 3rd party plugins have little regard for it.

It looks like there’s a lot of confusion about hotswapping in Unity, and many developers are not even aware of its existence – which is no wonder if their only experience is seeing lots of errors on the console when they forget to stop the game before recompiling... This document is an attempt to clear up some of this confusion.

Nota bene, I’m not a Unity developer, so everything below is based on blog posts and experimentation. Corrections are most welcome!

The basic flow of hotswapping

@unitycoder
unitycoder / LayerFieldAttribute.cs
Created November 26, 2025 10:01 — forked from ryan-at-melcher/LayerFieldAttribute.cs
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
{
}
@unitycoder
unitycoder / WorldSpaceHandVisual.cs
Created November 26, 2025 10:01 — forked from ryan-at-melcher/WorldSpaceHandVisual.cs
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 />
///
@unitycoder
unitycoder / FixAssetMainObjectNames.cs
Created November 26, 2025 10:00 — forked from ryan-at-melcher/FixAssetMainObjectNames.cs
Automated/batch solution to fix "Main Object Name '{0}' does not match filename '{1}'" in Unity assets
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.PackageManager;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
/// <summary>
/// Adds a menu command to find and fix all assets that have mismatched main
/// object names and file names. I.e., "Main Object Name '{0}' does not match
using System;
using UnityEngine;
using UnityEngine.Rendering;
using Random = System.Random;
namespace StellarConquest.Presentation.Unity
{
public class StarfieldMeshBuilder : MonoBehaviour
{
public float SphereRadius = 4000;
@unitycoder
unitycoder / UnityGMail.cs
Created August 28, 2025 10:04 — forked from marcotmp/UnityGMail.cs
Code to send email from unity using a Google account.
using System.ComponentModel;
using System.Net;
using System.Net.Mail;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
public class UnityGMail
{
public void SendMailFromGoogle()
{
@unitycoder
unitycoder / TexturedMeshSteps.md
Created May 21, 2025 20:13 — forked from shubhamwagh/TexturedMeshSteps.md
Steps to create textured mesh from point cloud using Meshlab

Steps to create Textured Mesh from Point Cloud using Meshlab

Get your PointCloud into MeshLab

  • Import the pointcloud file in ".ply" file format in Meshlab. Before importing make sure you do some pre-processing / cleaning on point cloud so as to ease the process of meshing.

Point Cloud Simplification and Normals Computation

  • Next we need to reduce the number of point samples for smooth meshing.
    • So go to Filters -> Point Set -> Point Cloud Simplification. Enter Number of samples circa 5% of original number of points. Make sure Best Sample Heuristic is checked.
  • After point cloud simplification, make sure to select Simplified point cloud in the Show Layer Dialog on the right hand side. If not visible, it can be opened by navigating to View -> Show Layer Dialog. Now we need to compute normals for point set.
  • So go to Filters -> Point Set -> Compute normals for point sets . Enter Neighbour num between 10 - 100. Initially try with 10 and