Skip to content

Instantly share code, notes, and snippets.

@maoyeedy
maoyeedy / Get-UnityInstallationRoot.ps1
Created May 7, 2025 18:50
Find Unity editor installations from Unity Hub
function Get-UnityInstallationRoot {
$userPathFile = "$env:APPDATA\UnityHub\secondaryInstallPath.json"
# Check if Unity Hub is installed, if installed, then must come with this file
if (-not (Test-Path $userPathFile)) {
Write-Warning "Unity Hub not installed."
return $null
}
# By default, it only has two quotes: ""
@maoyeedy
maoyeedy / CameraAmbientOverride.cs
Last active April 29, 2025 03:02
[Unity] Override Camera Ambient Color for SRP
using UnityEngine;
using UnityEngine.Rendering;
namespace CameraAmbientOverride
{
/// <summary>
/// Attach it to camera. Supports both URP and HDRP.
/// </summary>
[DisallowMultipleComponent]
[RequireComponent(typeof(Camera))]
@maoyeedy
maoyeedy / PlaymodeGamepadToggle.cs
Last active April 29, 2025 21:48
[Unity] Toggle Play Mode with Gamepad Buttons
#if UNITY_EDITOR && ENABLE_INPUT_SYSTEM
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Project.Editor
{
/// <summary>
/// Toggles play mode when pressing both Start and Select.
/// You may alter the trigger at the <see cref="IsGamepadPressed" />> method.
@maoyeedy
maoyeedy / ScreenshotRecorder.cs
Last active April 29, 2025 20:15
[Unity] Advanced Screenshot Recorder
#if UNITY_EDITOR
using System;
using System.IO;
using UnityEditor;
using UnityEditor.Recorder;
using UnityEditor.Recorder.Input;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Screenshot
@maoyeedy
maoyeedy / QuadSpriteProcessor.ps1
Created April 19, 2025 20:26
QuadSpriteProcessor-Powershell
<#
.SYNOPSIS
Make Textures Quad-Divisible
.DESCRIPTION
Resize PNG and JPG images so their dimensions are divisible by 4.
Useful for textures in game engines that require quad-divisible dimensions to be compressed with DXT or BC formats.
.NOTES
Requires ImageMagick to be installed and available in the PATH.
#>
@maoyeedy
maoyeedy / ChineseFontOverride.user.js
Last active April 9, 2025 09:23
[Userscript] Override font to 'HarmonyOS Sans SC' for Chinese sites
// ==UserScript==
// @name Change Font to HarmonyOS Sans SC
// @namespace https://github.com/Maoyeedy
// @grant GM_addStyle
// @version 1.1
// @author Maoyeedy
// @description Override font to 'HarmonyOS Sans SC' for Chinese sites
// @match *://*.nate.com/*
// @match *://*.huya.com/*
// @match *://*.douyu.com/*
@maoyeedy
maoyeedy / ClaudeSidebarToggle.user.js
Last active April 8, 2025 00:58
[Userscript] Toggles claude.ai sidebar with "Ctrl+\"
// ==UserScript==
// @name Claude Sidebar Toggle
// @namespace https://github.com/Maoyeedy
// @version 1.0
// @description Toggle Claude sidebar with a keyboard shortcut
// @author Maoyeedy
// @match https://claude.ai/*
// @grant none
// ==/UserScript==
@maoyeedy
maoyeedy / UnityAutoSave.cs
Last active April 29, 2025 21:48
[Unity] Autosave the modified scenes when exiting playmode.
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
namespace Project.Editor
{
/// <summary>
/// Autosave the modified scenes when exiting playmode.
/// </summary>
@maoyeedy
maoyeedy / HideMetaFiles.cs
Last active April 23, 2025 20:04
[Unity] Hides meta files in Windows Explorer.
#if UNITY_EDITOR
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Editor
{
/// <summary>
/// It runs after each assembly reload.
/// </summary>
@maoyeedy
maoyeedy / UnityManualRedirectTo2022.user.js
Last active October 19, 2024 19:23
Redirect old Unity docs to 2022.3 version
// ==UserScript==
// @name Unity Manual Redirect
// @namespace https://github.com/Maoyeedy/
// @version 1.0
// @description Redirect Unity Manual to 2022.3
// @author Maoyeedy
// @match https://docs.unity3d.com/Manual/*
// @icon https://unity.com/favicon.ico
// @grant none
// ==/UserScript==