Skip to content

Instantly share code, notes, and snippets.

View grapefrukt's full-sized avatar
💭
🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭

martin jonasson grapefrukt

💭
🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭🌭
View GitHub Profile
@grapefrukt
grapefrukt / UISDFIcon.shader
Created May 31, 2023 08:21
SDF UI for Unity
Shader "UI/SDF Icon" {
Properties {
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_EdgeColor ("Edge Color", Color) = (1, 1, 1, 1)
_Bleed("Bleed", Range(-1, 1)) = 0
_EdgeRadius("Edge Radius", Range(-1, 1)) = 0
_EdgeFeather("Edge Feather", Range(0, 1)) = 0
_Sharpness("Sharpness", Range(0, 2048)) = 1024
[Toggle(MULTIPLY_ALPHA)] _MultiplyAlpha("Multiply Intensity by Alpha", Float) = 0
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor.U2D;
using UnityEngine;
using UnityEngine.U2D;
internal class TextureCompressionToggler : IPreprocessBuildWithReport, IPostprocessBuildWithReport {
public int callbackOrder => 2;
@grapefrukt
grapefrukt / CornerCheat.cs
Created April 7, 2021 12:01
Makes a CircleCollider2D slide smoothly along the inner edge of a rounded EdgeCollider2D
using UnityEngine;
public class CornerCheat : MonoBehaviour {
public CircleCollider2D circle;
public Rigidbody2D body;
EdgeCollider2D edge;
[Range(0, .2f)] public float distanceThreshold = .03f;
[Range(0, 1)] public float dotThreshold = .96f;
@grapefrukt
grapefrukt / UnityTemplateFixer.cs
Last active June 28, 2022 11:19
Replaces/modifies the Unity behavior templates using a handful of regexes.
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using Debug = UnityEngine.Debug;
/// <summary>
/// Unity template fixer by grapefrukt (m@grapefrukt.com)
/// Runs a series of regexes on
/// </summary>
@grapefrukt
grapefrukt / URPPostProcessStripper.cs
Last active January 3, 2024 11:44
Strips all post-processing shaders and related assets from Unity builds using URP
/*
Copyright 2020 Martin Jonasson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
@grapefrukt
grapefrukt / Polylabel.cs
Last active February 1, 2024 09:18
Polylabel Algorithm for Unity
// modified for usage in Unity by grapefrukt, (removed support for polygons with holes as I do not need it)
// based C# port of Polylabel found here: https://github.com/mapbox/polylabel/issues/26#issue-211932869
// which in turn, is based on Polylabel from https://github.com/mapbox/polylabel
// as the name implies this is useful for placing labels on a polygon
using System.Collections.Generic;
using UnityEngine;
namespace Utilities {
using UnityEngine;
public class Wave : MonoBehaviour {
public float stayLow = 2f;
public float stayHigh = 2f;
private void OnDrawGizmos() {
var p0 = Vector2.zero;
for (var i = 0; i < 400; i++) {
@grapefrukt
grapefrukt / igfplaylist.py
Last active December 7, 2023 11:06
Fills a pre-created playlist with videos from the IGF json feed.
#!/usr/bin/python
import os
import json
import google.oauth2.credentials
import google_auth_oauthlib.flow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from google_auth_oauthlib.flow import InstalledAppFlow
@grapefrukt
grapefrukt / run.sh
Created May 27, 2016 14:18
Run script that fixes missing libraries for 32 bit builds only
#!/bin/bash
# making sure we're in the correct dir
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; cd ${DIR}
# get the architecture
arch=$(uname -m)
# this hack is only needed on 32 bit for some reason
if [[ ''$arch'' == ''i686'' ]]; then
# make sure libraries are loaded from the local directory
class Test {
static function main() {
var input = '()()(()()()(()()((()((()))((()((((()()((((()))()((((())(((((((()(((((((((()(((())(()()(()((()()(()(())(()((((()((()()()((((())((((((()(()(((()())(()((((()))())(())(()(()()))))))))((((((((((((()())()())())(())))(((()()()((((()(((()(()(()()(()(()()(()(((((((())(())(())())))((()())()((((()()((()))(((()()()())))(())))((((())(((()())(())(()))(()((((()())))())((()(())(((()((((()((()(())())))((()))()()(()(()))))((((((((()())((((()()((((()(()())(((((()(()())()))())(((()))()(()(()(()((((()(())(()))(((((()()(()()()(()(((())())(((()()(()()))(((()()(((())())(()(())())()()(())()()()((()(((()(())((()()((())()))((()()))((()()())((((()(()()(()(((()))()(()))))((()(((()()()))(()(((())()(()((()())(()(()()(()())(())()(((()(()())()((((()((()))))())()))((()()()()(())()())()()()((((()))))(()(((()()(((((((())()))()((((()((())()(()())(())()))(()(()())(((((((())))(((()))())))))()))())((())(()()((())()())()))))()((()()())(())((())((((()())())()()()(((()))())))()()))())(()()