Skip to content

Instantly share code, notes, and snippets.

View moto2002's full-sized avatar
🌴
On vacation

Jack moto2002

🌴
On vacation
  • NetEase
  • Guangzhou
View GitHub Profile
@moto2002
moto2002 / getOS.lua
Created April 2, 2024 07:54 — forked from Zbizu/getOS.lua
operating system (OS) detection in Lua
function getOS()
-- ask LuaJIT first
if jit then
return jit.os
end
-- Unix, Linux variants
local fh,err = assert(io.popen("uname -o 2>/dev/null","r"))
if fh then
osname = fh:read()
@moto2002
moto2002 / .billboard-shadow.shadergraph.md
Created November 23, 2023 11:19 — forked from andrew-raphael-lukasik/.billboard-shadow.shadergraph.md
Shader Graph files to create billboard trees with billboard shadows. Exported from Unity 2023.2 and Shader Graph 16.0.4

Shader Graph files to create billboard trees with billboard shadows. Exported from Unity 2023.2 and Shader Graph 16.0.4

GIF 17 11 2023 14-38-35

Note: Shaders written for default Quad meshes in mind.

To make sure shadows are being drawn always behind tree billboards change shadow material’s Sorting Priority to a negative value:

Screenshot 2023-11-17 145239

@moto2002
moto2002 / .UIDocumentLocalization.cs.md
Created November 23, 2023 11:18 — forked from andrew-raphael-lukasik/.UIDocumentLocalization.cs.md
Text localization script for UIDocument (UI Toolkit @ Unity)

pattern to follow

// NOTE: this class assumes that you designate StringTable keys in label fields (as seen in Label, Button, etc) // and start them all with '#' char (so other labels will be left be)

@moto2002
moto2002 / DebugNode.hlsl
Created November 2, 2023 10:40 — forked from bestknighter/DebugNode.hlsl
"Print a value" custom function node code for Unity ShaderGraph, aware of +Inf/-Inf and nan
// This gist can be found at https://gist.github.com/bestknighter/660e6a53cf6a6643618d8531f962be2c
// I modified Aras Pranckevičius's awesome shader code to be able to handle Infinite and Not A Number numbers
// Tested on Unity 2023.1.0a15 with ShaderGraph 15.0.1.
// Quick try at doing a "print value" node for Unity ShaderGraph.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
@moto2002
moto2002 / EditPrefabInScene.cs
Created May 17, 2023 04:40 — forked from JohannesDeml/EditPrefabInScene.cs
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement;
// From https://gist.github.com/JohannesDeml/5802473b569718c9c86de906b7039aec
// Original https://gist.github.com/ulrikdamm/338392c3b0900de225ec6dd10864cab4
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
@moto2002
moto2002 / PostBuildProcess.cs
Created February 25, 2021 02:49 — forked from suakig/PostBuildProcess.cs
PostBuildProcess.cs
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
using System.Collections.Generic;
public class PostBuildProcess : MonoBehaviour
{
internal static void CopyAndReplaceDirectory(string srcPath, string dstPath)
@moto2002
moto2002 / XcodeSettingsPostProcesser.cs
Created February 25, 2021 02:39 — forked from sanukin39/XcodeSettingsPostProcesser.cs
Unity XcodeAPI Settings Sample
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using UnityEditor.Callbacks;
using System.Collections;
public class XcodeSettingsPostProcesser
{
@moto2002
moto2002 / UI-Fast-Default
Created November 4, 2020 11:39 — forked from ArturoNereu/UI-Fast-Default
A simpler version of the UI Shader for mobile and low spec devices
Shader "UI/Fast-Default"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
}
SubShader
{
// Updated requestAnimationFrame polyfill that uses new high-resolution timestamp
//
// References:
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// https://gist.github.com/1579671
// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision
//
// Note: this is my initial stab at it, *requires additional testing*
(function () {