Skip to content

Instantly share code, notes, and snippets.

@maoyeedy
maoyeedy / UnityDocsRedirect.user.js
Last active April 29, 2025 20:17
[Userscript] Redirect Unity docs to latest LTS version
// ==UserScript==
// @name Unity Docs Redirect
// @namespace https://github.com/Maoyeedy/
// @version 1.1
// @author Yidi Mao
// @license MIT
// @description Redirect old Unity docs to latest LTS version
// @icon https://unity.com/favicon.ico
// @match https://docs.unity3d.com/*/Documentation/**
// @run-at document-start
@maoyeedy
maoyeedy / MixamoRenamer.cs
Last active April 28, 2025 20:16
[Unity] Rename Mixamo animation clips to match filename
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
public class MixamoAnimationRenamingProcessor : AssetPostprocessor
{
private static readonly HashSet<string> NamesToReplace = new()
{
"mixamo.com"
@maoyeedy
maoyeedy / UnityDocsHighlight.user.js
Last active April 29, 2025 20:21
[Userscript] Unity Document Syntax Highlight
// ==UserScript==
// @name Unity Docs Syntax Highlighter
// @namespace https://github.com/Maoyeedy
// @version 1.3.1
// @author Yidi Mao, hyblocker
// @license MIT
// @description Adds syntax highlighting to the Unity Documentation. Forked from hyblocker.
// @icon https://unity.com/favicon.ico
//
// @match https://docs.unity3d.com/Manual/*
@maoyeedy
maoyeedy / Set-UnityAssetStoreProtocolHandler.ps1
Last active April 4, 2025 23:02
[Windows] Fix Unity Asset Store "Open in Unity" button not working
$EditorRootPath = "C:\Program Files\Unity\Hub\Editor"
$versions = Get-ChildItem -Directory $EditorRootPath | Select-Object -Expand Name
$latestVersion = ($versions | Sort-Object -Descending | Select-Object -First 1)
$unityExe = Join-Path $EditorRootPath "$latestVersion\Editor\Unity.exe"
Write-Host "Try registering URL:com.unity3d.kharma for $unityExe"
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\UnityAssetStore" -Recurse -ErrorAction SilentlyContinue
New-Item -Path "Registry::HKEY_CLASSES_ROOT\UnityAssetStore" | Out-Null
New-Item -Path "Registry::HKEY_CLASSES_ROOT\UnityAssetStore\DefaultIcon" | Out-Null
function extendImagesWithPicture () {
let imgElements = document.querySelectorAll("img")
imgElements.forEach(function (img) {
let dataSrc = img.getAttribute("data-src")
let path = dataSrc.substring(0, dataSrc.lastIndexOf("/") + 1)
let imageName = dataSrc.substring(dataSrc.lastIndexOf("/") + 1, dataSrc.lastIndexOf("."))
let picture = document.createElement("picture")
let sourceAVIF = document.createElement("source")
#!/bin/sh
const imgElements = document.querySelectorAll('.fullscreenable img')
imgElements.forEach(img => {
img.addEventListener('click', () => {
const src = img.getAttribute('src')
const overlay = document.createElement('div')
overlay.style.width = '100%'
overlay.style.height = '100%'
overlay.style.position = 'fixed'
.gist .blob-code-inner,
.gist .blob-num {
font-family: 'Spline Sans Mono', monospace !important;
font-size: 0.8rem !important;
}
.gist .gist-file {
margin: 0 !important;
border-radius: 1em !important;
}
const img = document.querySelectorAll('img');
img.forEach((image) => {
image.draggable = false;
});
const anchors = document.querySelectorAll('a');
anchors.forEach((anchor) => {
anchor.target = '_blank';
anchor.rel = 'noopener';
anchor.draggable = false;
@maoyeedy
maoyeedy / Screenshot.cs
Last active October 14, 2023 08:49
A minimal Unity screenshot script
using System;
using System.IO;
using UnityEngine;
public class ScreenshotScript : MonoBehaviour
{
public string folderPath = Path.Combine(Application.dataPath, "..", "SampleRecordings");
public KeyCode captureKey = KeyCode.Tab;
private void Start()
@maoyeedy
maoyeedy / DialogPlayer.cs
Last active January 30, 2023 05:32
Unity Dialog Script
using System;
using System.Collections;
using TMPro;
using UnityEngine;
public class DialogPlayer : MonoBehaviour
{
public Dialog[] dialogs;
public TextMeshProUGUI dialogText, nameText;
public float characterInterval = 0.05f, autoNextLineTime = 2.5f;