Skip to content

Instantly share code, notes, and snippets.

View Long18's full-sized avatar
:octocat:
// TODO: Add status

Thành Long (WiIIiam) Long18

:octocat:
// TODO: Add status
View GitHub Profile

Unity Event Functions for Application Flow

Unity provides several event functions to manage the application’s lifecycle:

1. OnApplicationFocus()

Called when the app gains or loses focus.

  • Input: bool hasFocus (true = focused, false = unfocused).
  • Use Case: Pause or resume real-time processes like music or updates.

2. OnApplicationPause()

using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Provides tools to find, log, select, and remove missing scripts in a Unity project.
/// Includes options to search active/inactive GameObjects and prefabs.
/// </summary>
public class FixMissingScript : EditorWindow
{
@Long18
Long18 / ExportSubSprites.cs
Last active October 3, 2024 03:11
This Unity editor script exports individual sub-sprites from a selected sprite asset as PNG files.
using System.IO;
using UnityEditor;
using UnityEngine;
namespace Long18.Utils
{
/// <summary>
/// Utility class for exporting individual sub-sprites from a selected sprite asset to PNG files.
/// </summary>
public class ExportSubSprites : Editor
@Long18
Long18 / [Windows] Icon DLL Paths.md
Created August 10, 2024 05:14
Common Windows Icon DLL Paths

Common Windows Icon DLL Paths

This gist provides paths to some of the common .dll files that contain system icons in Windows. These .dll files are typically located in the System32 directory, but some might be found in other locations as well.

System Icon Libraries

  1. Shell32.dll
    Path: %SystemRoot%\System32\shell32.dll
    Description: Contains many of the standard icons used throughout the Windows operating system.
.editor-group-watermark {
max-width: 500px !important;
padding-left: 1em;
padding-right: 1em;
}
.editor-group-watermark>.letterpress {
background-image: url("https://raw.githubusercontent.com/SAWARATSUKI/ServiceLogos/main/404Notfound/NotFound.png") !important;
aspect-ratio: 8/5 !important;
}
{
"version": 1,
"notes": "",
"documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
"keyboard": "planck/rev6_drop",
"keymap": "planck_rev6_drop_planck_rev6_drop_layout_ortho_4x12_william",
"layout": "LAYOUT_ortho_4x12",
"layers": [
[
"KC_TAB",

Clear Browser Cache Script

This script allows you to clear the browser cache using JavaScript.

javascript:(function(){
  'caches' in window && caches.keys().then(cacheNames => cacheNames.forEach(cacheName => caches.delete(cacheName)));
  localStorage.clear();
  sessionStorage.clear();
 indexedDB.databases().then(databases =&gt; databases.forEach(db =&gt; indexedDB.deleteDatabase(db.name))).catch(error =&gt; console.error('Failed to clear IndexedDB:', error));
@Long18
Long18 / .gitconfig
Last active March 15, 2024 03:09
The error: "fatal: unable to create thread: Resource temporarily unavailable" when you using git in command line without ssh. In my case:
# Set the window memory size for Git's pack operation to 100 MB
git config --global pack.windowMemory "100m"
# Set the maximum size limit for a pack file in Git to 100 MB
git config --global pack.packSizeLimit "100m"
# Limit the number of threads Git will use for packing operations to 1
git config --global pack.threads "1"
@Long18
Long18 / BuildAddressablesEditorWindow.cs
Created January 23, 2024 04:13
The BuildAddressablesEditorWindow class streamlines Unity Addressable Assets building in the Editor, providing a shortcut (Alt+ B) under "Tools." It automates asset cleanup, initiates the build, and logs success/errors, enhancing the efficiency of the Addressable Assets build process.
public class BuildAddressablesEditorWindow: EditorWindow
{
[MenuItem("Tools/BuildAddressable &b")]
public static void BuildAndRun()
{
var window = GetWindow<BuildAddressablesEditorWindow>();
window.Close();
}
private void OnEnable()
{"version":1,"resource":"file:///c%3A/Users/long.le/Desktop/Project/github-action-test/.github/workflows/clean-manually.yml","entries":[{"id":"u6lL.yml","source":"renamed.source","timestamp":1710153308295},{"id":"HmP6.yml","timestamp":1710153333685}]}