Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@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
Last active March 22, 2026 14:10
[greasemonkey] youtube remove shorts link and scale thumbnails
// ==UserScript==
// @name Replace YouTube Menu Item with My Channel
// @namespace http://unitycoder.com
// @version 1.3
// @description Fix youtube layout : https://gist.github.com/unitycoder/cfc311ac35d9c8da15401ca3f34fdf9a
// @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/",
@unitycoder
unitycoder / DSShaderGUI.cs
Created November 3, 2025 11:03
DSShaderGUI from DigitalSalmon
// https://www.twitch.tv/digitalsalmon
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using DigitalSalmon.Extensions;
using UnityEditor;
using UnityEditor.Graphs;
using UnityEditor.Rendering;
using System;
using UnityEngine;
using UnityEngine.Rendering;
using Random = System.Random;
namespace StellarConquest.Presentation.Unity
{
public class StarfieldMeshBuilder : MonoBehaviour
{
public float SphereRadius = 4000;