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
@andrew-raphael-lukasik
andrew-raphael-lukasik / .billboard-shadow.shadergraph.md
Last active December 5, 2023 11:33
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

@Anthelmed
Anthelmed / WorldSpaceUIDocument.cs
Last active April 29, 2024 09:31
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;
@bestknighter
bestknighter / DebugNode.hlsl
Last active February 23, 2024 09:56 — forked from aras-p/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.
@Zbizu
Zbizu / getOS.lua
Last active April 2, 2024 07:55
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()
@andrew-raphael-lukasik
andrew-raphael-lukasik / .UIDocumentLocalization.cs.md
Last active April 26, 2024 07:50
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)

@rob5300
rob5300 / DialogueTriggerBehaviour.cs
Last active January 8, 2020 02:43
Example of a PlayableBehaviour
using Ink.Runtime;
using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
using Dialogue;
[Serializable]
public class DialogueTriggerBehaviour : PlayableBehaviour
{
@JohannesDeml
JohannesDeml / EditPrefabInScene.cs
Last active May 17, 2023 04:40 — forked from ulrikdamm/EditPrefab.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
@slembcke
slembcke / CustomProjection.cs
Last active February 7, 2024 11:03
Custom projections for Unity2D games.
using UnityEngine;
using System.Collections;
// This script is meant to be attached to your main camera.
// If you want to use it on more than one camera at a time, it will require
// modifcations due to the Camera.on* delegates in OnEnable()/OnDisable().
[ExecuteInEditMode]
public class CustomProjection : MonoBehaviour {
private void OnEnable(){
@sanukin39
sanukin39 / XcodeSettingsPostProcesser.cs
Last active October 11, 2023 16:04
Unity XcodeAPI Settings Sample
using System.IO;
using UnityEngine;
using UnityEditor;
using UnityEditor.iOS.Xcode;
using UnityEditor.Callbacks;
using System.Collections;
public class XcodeSettingsPostProcesser
{