Skip to content

Instantly share code, notes, and snippets.

View paraself's full-sized avatar
🙆‍♂️
Coding

Yves Wang paraself

🙆‍♂️
Coding
View GitHub Profile
@paraself
paraself / EditorPlayMode
Last active October 30, 2023 14:38
Unity Play Mode Detection
//originally adopted from
//http://answers.unity3d.com/questions/447701/event-for-unity-editor-pause-and-playstop-events.html
//with a few modifications which makes the event firing nicer and cleaner
//Usage Example :
//
//using UnityEditor;
//using UnityEngine;
//
//[InitializeOnLoad]
//public class SingleEntryPoint
@paraself
paraself / AUB_BLENDS.cginc
Created May 15, 2015 10:41
Photoshop Blends shader funcitons
//Source http://forum.unity3d.com/threads/free-photoshop-blends.121661/
#ifndef AUB_BLENDS_INCLUDED
#define AUB_BLENDS_INCLUDED
/**********************INCLUDES**********************/
/**********************STRUCTS**********************/
struct a2f_uv0 {
float4 vertex : POSITION;
@paraself
paraself / RGBA2HSVA
Last active August 29, 2015 14:21
Fast RGBA to HSVA in Unity3D shader
//Original source
//http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
//http://ploobs.com.br/?p=1499
#ifndef RGBA2HSVA
#define RGBA2HSVA
fixed4 RGBA2HSVA(fixed4 rgba)
{
float K = 0;
fixed temp;
@paraself
paraself / RTAtlasCreation
Created May 6, 2014 05:53
Unity Runtime Atlas Creation
Texture texture = new Texture2D(maximunAtlasSize, maximunAtlasSize);
texture.PackTextures(frames, padding, maximunAtlasSize);
texture.name = "New Atlas";
texture.Apply();
if(!Directory.Exists(Application.dataPath + "/Atlases"))
Directory.CreateDirectory(Application.dataPath + "/Atlases");
FileStream fs = new FileStream(Application.dataPath + "/Atlases/" + texture.name + ".png", FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);