Skip to content

Instantly share code, notes, and snippets.

View tk009999's full-sized avatar
🇹🇼

AceLee tk009999

🇹🇼
View GitHub Profile
using UnityEngine;
public class DontDestroyOnLoadController<T> : MonoBehaviour where T : MonoBehaviour
{
public static T Instance;
private object _lock = new object();
protected virtual void Awake()
{
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@krzys-h
krzys-h / SaveRenderTextureToFile.cs
Last active December 26, 2024 08:44
[Unity] Save RenderTexture to image file
using UnityEngine;
using UnityEditor;
public class SaveRenderTextureToFile {
[MenuItem("Assets/Save RenderTexture to file")]
public static void SaveRTToFile()
{
RenderTexture rt = Selection.activeObject as RenderTexture;
RenderTexture.active = rt;
@ditzel
ditzel / MathParabola.cs
Last active January 5, 2025 08:07
A simple Math class to calculate a point in 2D or 3D space lying on a parabola. And a more complex parabola controller that you can put on an object.
using UnityEngine;
using System;
public class MathParabola
{
public static Vector3 Parabola(Vector3 start, Vector3 end, float height, float t)
{
Func<float, float> f = x => -4 * height * x * x + 4 * height * x;