Skip to content

Instantly share code, notes, and snippets.

View mandarinx's full-sized avatar

Thomas Viktil mandarinx

View GitHub Profile
@mandarinx
mandarinx / SnekSolver.cs
Created September 29, 2017 06:43
Snek solver
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SnekSolver : MonoBehaviour {
[Header("Joints")]
public int totalJoints = 10;
[Space]
public float maxLength = 1;
@mandarinx
mandarinx / Trails.cs
Created August 28, 2017 17:59
Trails
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// tester part here, scroll for smartTrail class
public class testSmartTrail : MonoBehaviour {
[Header("Line parameters")]
@mandarinx
mandarinx / ScrollRectAutoScroll.cs
Created August 22, 2017 11:30 — forked from QubitsDev/ScrollRectAutoScroll.cs
Unity3d ScrollRect Auto-Scroll, Dropdown Use: Places this component in the Template of Dropdown (with the ScrollRect component)
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(ScrollRect))]
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public float scrollSpeed = 10f;
private bool mouseOver = false;
@mandarinx
mandarinx / sway.shader
Created August 9, 2017 13:01
Sway shader
Shader "Toon/Lit Swaying" {
Properties {
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_Speed ("MoveSpeed", Range(20,50)) = 25 // speed of the swaying
_Rigidness("Rigidness", Range(1,50)) = 25 // lower makes it look more "liquid" higher makes it look rigid
_SwayMax("Sway Max", Range(0, 0.1)) = .005 // how far the swaying goes
_YOffset("Y offset", float) = 0.5// y offset, below this is no animation
@mandarinx
mandarinx / explode.cs
Created March 20, 2017 08:33
Explode sprites
IEnumerator slowExplodeCO(SpriteRenderer spriteRendrr, float duration=1, bool reuseSprite=true) {
if(spriteRendrr==null)
spriteRendrr=GetComponent<SpriteRenderer>();
sprite = spriteRendrr.sprite;
width=(int)sprite.textureRect.width;
height=(int)sprite.textureRect.height;
ox=(int)sprite.textureRect.position.x;
@mandarinx
mandarinx / Distort.shader
Created February 22, 2017 07:48
Shader for distoring, like heat waves
// Per pixel bumped refraction.
// Uses a normal map to distort the image behind, and
// an additional texture to tint the color.
Shader "FX/Glass/Stained BumpDistort Orthographic" {
Properties {
_BumpAmt ("Distortion", range (0,128)) = 10
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
[Toggle(ORTHO)] _ORTHO("Orthographic", Float) = 0
@mandarinx
mandarinx / 2DCamera.cs
Created February 3, 2017 11:28
2D Camera
using UnityEngine;
public class Camera2D : MonoBehaviour
{
//The background image to use
public Transform Area;
//Sprite details
private Sprite Sprite;
private float PixelUnits;
@mandarinx
mandarinx / SceneHistoryWidget.cs
Created January 24, 2017 11:21 — forked from jringrose/SceneHistoryWidget.cs
Drop this into an Editor folder in your project to add a history widget to your scene view. Supports going backwards and forwards through your recent scene history, as well as a dropdown of all recently edited scenes. Also supports the back/forwards buttons on your mouse! Doesn't support multi-scene editing very well, though.
/*
MIT License
Copyright (c) 2016 Jesse Ringrose
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
@mandarinx
mandarinx / index.html
Created December 7, 2016 21:05 — forked from anonymous/index.html
Air sys proto 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
body {
margin: 50px 25px 0 25px;
background-color: #ccc;
@mandarinx
mandarinx / RasterizeGradient.cs
Created November 28, 2016 07:26
Rasterize a gradient
using UnityEditor;
using UnityEngine;
public class RasterizeGradient : EditorWindow {
private AnimationCurve curve;
private int imageWidth;
[MenuItem("Window/Rasterize Gradient")]
public static void OpenTPImporter() {