Skip to content

Instantly share code, notes, and snippets.

@jbgo
jbgo / git-recover-branch.md
Last active March 29, 2024 05:04
How to recover a git branch you accidentally deleted

UPDATE: A better way! (August 2015)

As pointed out by @johntyree in the comments, using git reflog is easier and more reliable. Thanks for the suggestion!

 $ git reflog
1ed7510 HEAD@{1}: checkout: moving from develop to 1ed7510
3970d09 HEAD@{2}: checkout: moving from b-fix-build to develop
1ed7510 HEAD@{3}: commit: got everything working the way I want
70b3696 HEAD@{4}: commit: upgrade rails, do some refactoring
@T5impact
T5impact / AtmosphericScattering.shader
Last active February 22, 2024 11:51
Atmospheric Scattering Shader for Unity that works in the URP (feel free to use this in any projects) (default settings are tailored towards an earth-like atmosphere)
Shader "Atmosphere/Atmospheric Scattering"
{
Properties
{
_LightIntensity("Light Intensity", Float) = 30
_LightColor("Light Color", Color) = (1,1,1)
_LightDirection("Light Direction", Vector) = (0,0,1)
_PlanetRadius("Planet Radius", Float) = 47
_AtmosphereRadius("Atmosphere Radius", Float) = 50
_Steps ("Steps", Int) = 20
@darktable
darktable / MiniJSON.cs
Created November 30, 2011 23:08
Unity3D: MiniJSON Decodes and encodes simple JSON strings. Not intended for use with massive JSON strings, probably < 32k preferred. Handy for parsing JSON from inside Unity3d.
/*
* Copyright (c) 2013 Calvin Rien
*
* Based on the JSON parser by Patrick van Bergen
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
*
* Simplified it so that it doesn't throw exceptions
* and can be used in Unity iPhone with maximum code stripping.
*
* Permission is hereby granted, free of charge, to any person obtaining
@smkplus
smkplus / SimpleInkPaint.shader
Created April 18, 2019 18:13
Unity Simple Ink Paint Shader
Shader "Unlit/SimpleInkPaint"
{
Properties{
_MainTex("MainTex", 2D) = "white" // メインテクスチャ
_Brush("Brush", 2D) = "white" // ブラシテクスチャ
_BrushScale("BrushScale", FLOAT) = 0.1 // ブラシサイズ
_ControlColor("ControlColor", VECTOR) = (0, 0, 0, 0) // ブラシの色
_PaintUV("Hit UV Position", VECTOR) = (0, 0, 0, 0) // ブラシで塗りたい位置
}
@allanolivei
allanolivei / gist:9260107
Created February 27, 2014 21:38
Unity 3d : Get Selected Folder in Project Window
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public static class UnityUtil
{
public static string GetSelectedPathOrFallback()
{
string path = "Assets";
@sttz
sttz / StoppableCoroutine.cs
Last active February 9, 2022 10:12
Simple wrapper around Unity coroutines (generator methods) that allows to stop them from the outside. Unity natively only allows this when starting the coroutine by using its lexical name.
using System;
using System.Collections;
using UnityEngine;
/// <summary>
/// Wrapper around coroutines that allows to start them without using
/// their lexical name while still being able to stop them.
/// </summary>
public class StoppableCoroutine : IEnumerator
{
@rtlsilva
rtlsilva / TimeKeeper.cs
Created May 3, 2016 04:51
Unity3D scripts that keep track of multiple independent time layers, each with its own time scale and all updated from a single timer. This allows, for example, to simultaneously have multiple entities operating at a sped up/slowed down rate and being frozen in time by simply changing their TimeLayer in the Inspector.
using System.Collections;
using System.Diagnostics;
using UnityEngine;
public enum TimeLayer {
//Unity's time
GameTime,
//Custom time layer for UI
MenuTime,
//Unity's unscaled time
using UnityEngine;
using Vectrosity;
using System.Collections.Generic;
using UnityEngine.UI;
using System.IO;
using System.Collections;
using UnityEngine.SceneManagement;
public class DrawingView : MonoBehaviour {
public Text _Console;
@Marsgames
Marsgames / ICanRewind.cs
Last active November 5, 2020 21:40
A simple system to rewind time like in Prince of Persia
// Source : https://www.twitch.tv/videos/519292916?filter=all&sort=time
#region Author
/////////////////////////////////////////
// RAPHAËL DAUMAS --> ICanRewind
// https://raphdaumas.wixsite.com/portfolio
// https://github.com/Marsgames
/////////////////////////////////////////
#endregion
public interface ICanRewind
@CKShare
CKShare / ITimeControl.cs
Created March 29, 2018 01:17
오브젝트별 타임스케일 적용
public interface ITimeControl
{
void Initialize();
void AdjustTimeScale(float timeScale);
}