Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / ScriptableObjectHeaderPing.cs
Last active November 28, 2025 13:10
Add ping button for scriptable object Inspector
// NOTE: this executes on all selected objects.. and compares if target is ScriptableObject
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public static class ScriptableObjectHeaderPing
{
static ScriptableObjectHeaderPing()
{
// Called after Unity draws the default header of *any* inspector
@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
@unitycoder
unitycoder / return-value-ienumerator.md
Created November 26, 2025 09:46
unity return value from ienumerator

basic method

void Foo()
{
    StartCoroutine(Bar((bool myReturnValue) => {
        if(myReturnValue) { ... }
    });
}
IEnumerator Bar(System.Action<bool> callback)
{
@unitycoder
unitycoder / how to download Meta Sam3D model output.md
Created November 20, 2025 14:12
how to download Meta Sam3D model output

how to download Meta Sam3D model output (gaussian splat .ply)

  • press F12 to open browser developer tools, open Network tab
  • generate some 3d object https://aidemos.meta.com/segment-anything/editor/convert-image-to-3d
  • view Fetch/XHR requests in the network panel
  • find graphql/ request (usually the last one), with data like: data: {xfair_sam3d_3dfy_model_gaussian_splat...
  • open the data hierarchy to find "gaussian_splat: ..." and it contains url to .ply file
  • copy that url and open in browser to download file
@unitycoder
unitycoder / youtubefix.js
Created November 15, 2025 21:45
[greasemonkey] youtube remove shorts link and scale thumbnails
// ==UserScript==
// @name Replace YouTube Menu Item with My Channel
// @namespace http://unitycoder.com
// @version 1.2
// @description Replace the second YouTube menu item with a link to "My Channel" and set proper scale for channel thumbnails
// @author You
// @match https://www.youtube.com/
// @grant none
// ==/UserScript==
@unitycoder
unitycoder / ExampleFunctions.cs
Created November 7, 2025 21:00
List of lists in Inspector (Unity Editor Inspector Field)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Example : MonoBehaviour
{
public List<ListWrapper<Vector3>> example = new List<ListWrapper<Vector3>>();
public void ExampleFunctions()
{
@unitycoder
unitycoder / Search.index.json
Created November 6, 2025 20:33
Disable Unity Editor Indexing Service
// https://discussions.unity.com/t/how-to-disable-searcher-in-6-4/1693707/6
// You can disable indexing of assets for advance search (this is what is crashing) by modifyin the UserSettings/Search.index file in your project:
{
"name": "Assets",
"type": "asset",
"roots": [
],
"includes": [],
"excludes": [
"Assets/Temp/",