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 / PerformanceMetrics.cs
Created May 16, 2024 07:29 — forked from anarkila/PerformanceMetrics.cs
Expose Unity Profiler stats with Unity ProfilerRecorder API
// MIT License
// Copyright (c) 2022 anarkila - https://github.com/anarkila
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@moto2002
moto2002 / WorldSpaceUIDocument.cs
Created April 29, 2024 09:31 — forked from Anthelmed/WorldSpaceUIDocument.cs
Until Unity decide to make it official, this is a custom WorldSpaceUIDocument component. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem.UI;
#endif
#if UNITY_EDITOR
using UnityEditor;
@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
{