Skip to content

Instantly share code, notes, and snippets.

View adrenak's full-sized avatar
💻

Vatsal Ambastha adrenak

💻
View GitHub Profile
@jhocking
jhocking / TintedUIBlur.shader
Created February 9, 2021 16:17
Blur the background behind UI
// blur shader from https://stackoverflow.com/questions/29030321/unity3d-blur-the-background-of-a-ui-canvas
// added toggle https://forum.unity.com/threads/shader-properties-no-bool-support.157580/#post-3013337
Shader "Custom/TintedUIBlur" {
Properties {
_Size("Blur", Range(0, 30)) = 3
[HideInInspector] _MainTex("Masking Texture", 2D) = "white" {}
_AdditiveColor("Additive Tint color", Color) = (0, 0, 0, 0)
_MultiplyColor("Multiply Tint color", Color) = (1, 1, 1, 1)
[Toggle(MAKE_DESATURATED)] _MakeDesaturated ("Desaturate", Float) = 0
@fand
fand / DepthFader.hlsl
Created May 9, 2019 10:51
Unity Standard Surface Shader with Fade by Depth
Shader "Custom/DepthFade"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_DepthNear ("Depth Near", Range(0, 1000)) = 10
_DepthFar ("Depth Far", Range(0, 1000)) = 200
@unitycoder
unitycoder / FeaturesAcceleratedSegmentTest.cs
Last active January 16, 2025 06:40
FAST Algorithm for Corner Detection (Unity)
// unity version : https://unitycoder.com/blog/2019/05/09/fast-algorithm-for-corner-detection-in-unity/
// NOTE this is not optimized in any way
// original source https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_fast/py_fast.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FeaturesAcceleratedSegmentTest : MonoBehaviour
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Runtime.CompilerServices;
[AttributeUsage(AttributeTargets.Method)]
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
{
public NotifyPropertyChangedInvocatorAttribute()
{
}
@davidfoster
davidfoster / KalmanFilterFloat.cs
Last active June 5, 2025 14:17
Simple Kalman filtering in Unity.
using System.Collections.Generic;
/// <summary>A Kalman filter implementation for <c>float</c> values.</summary>
public class KalmanFilterFloat {
//-----------------------------------------------------------------------------------------
// Constants:
//-----------------------------------------------------------------------------------------
public const float DEFAULT_Q = 0.000001f;
@SeanMcTex
SeanMcTex / PinToSafeArea.cs
Last active August 9, 2024 07:11
Restrict Unity UI to an iPhone X or other Mobile Device's Safe Area
using UnityEngine;
/// <summary>
/// Resizes a UI element with a RectTransform to respect the safe areas of the current device.
/// This is particularly useful on an iPhone X, where we have to avoid the notch and the screen
/// corners.
///
/// The easiest way to use it is to create a root Canvas object, attach this script to a game object called "SafeAreaContainer"
/// that is the child of the root canvas, and then layout the UI elements within the SafeAreaContainer, which
/// will adjust size appropriately for the current device./// </summary>
@iendsl
iendsl / ShadowNoLight.shader
Created October 4, 2017 06:14
Shader Used in A Good Gardener
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/Cutout/ShadowNoLight" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Cutoff ("Alpha Cutoff", Float) = 0.5
}
SubShader {
@heiswayi
heiswayi / repo-reset.md
Created February 5, 2017 01:32
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
@Ikalou
Ikalou / git_and_unity.md
Last active July 1, 2025 16:48
Git and Unity

EDIT: this is an old post and a lof the information in this document is outdated.

Using Git with Unity

Git logo

Git is a popular free and open source distributed version control system.

I am new to Unity, but as a long time git user, I wanted to use git for my

@gering
gering / Toolkit
Last active February 25, 2026 01:53
persitent data path handling in Unity with fallback
private static string[] _persistentDataPaths;
public static bool IsDirectoryWritable(string path) {
try {
if (!Directory.Exists(path)) return false;
string file = Path.Combine(path, Path.GetRandomFileName());
using (FileStream fs = File.Create(file, 1)) {}
File.Delete(file);
return true;
} catch {