Skip to content

Instantly share code, notes, and snippets.

@Hyrtwol
Hyrtwol / UnityScraps.cs
Last active April 23, 2018 16:29
Unity scraps
// show the field as a read only label (runtime script)
[AttributeUsage(AttributeTargets.Field)]
public class ReadOnlyAttribute : PropertyAttribute { }
// read only drawer (editor script)
[CustomPropertyDrawer(typeof (ReadOnlyAttribute))]
public class ReadOnlyAttributeDrawer : PropertyDrawer
{
private static readonly GUIStyle Style = EditorStyles.label;
@Hyrtwol
Hyrtwol / UnityShaderFFS.md
Created March 27, 2018 17:43 — forked from smkplus/UnityShaderCheatSheet.md
Controlling fixed function states from materials/scripts in Unity

16999105_467532653370479_4085466863356780898_n

Shader "MaterialPropertyDrawer"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
 
[HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
@Hyrtwol
Hyrtwol / GLSL-Noise.md
Created March 25, 2018 19:45 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@Hyrtwol
Hyrtwol / ConvertSpriteToFont
Last active October 26, 2016 17:45
Convert sprite mapping to custom font settings in Unity 3D
[MenuItem(ItemNamePrefix + "Convert Font")]
public static void ConvertFont()
{
var sb = new StringBuilder();
var objs = AssetDatabase.LoadAllAssetsAtPath("Assets/Amstrad/AmstradFont.psd");
var sprites = objs.OfType<Sprite>().OrderBy(s => CalcIndex(s.name)).ToArray();
foreach (var sprite in sprites)
{
sb.AppendLine("name " + sprite.name);
sb.AppendLine("rect " + sprite.rect);
@Hyrtwol
Hyrtwol / roman.pas
Last active October 25, 2016 17:08
program roman(output);
var
x, y : integer;
begin y := 1;
repeat x := y; write(x:12, ' ');
while x >= 1000 do
begin write('m'); x := x - 1000 end;
if x >= 500 then
begin write('d'); x := x - 500 end;
while x >= 100 do