Skip to content

Instantly share code, notes, and snippets.

@Crushy
Crushy / MousePan.cs
Last active April 4, 2019 10:54
Pan a camera around in Unity like any modern Strategy game
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class MousePan : MonoBehaviour {
#region Settings
//Default middle mouse
public int mouseKey = 2;
@Crushy
Crushy / InGameDebug.cs
Created December 30, 2013 16:52
In game debug console using DF GUI
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System;
[RequireComponent(typeof(dfRichTextLabel))]
public class InGameDebug : MonoBehaviour {
private Queue<string> myLogQueue = new Queue<string>();
private string output = "";
@Crushy
Crushy / MoveTransform.cs
Last active June 1, 2018 21:00
Meant to be used with Easing functions. See http://easings.net/ for examples. Graphs should vary from x=0 to x=1.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class MoveTransform : IActivated {
public Transform objectMoved;
public ColliderEnterExitMovements enter, leave;
@Crushy
Crushy / AnimateUVs.cs
Last active August 29, 2015 13:56
Animates UVs. Useful for some effects that require UV maps to wobble around and such. Might expand this later.
using UnityEngine;
using System.Collections;
/// <summary>
/// Choose the material's index and plot away how it's UVs should behave
/// </summary>
[RequireComponent(typeof(Renderer))]
public class AnimateUVs : MonoBehaviour {
[System.Serializable]
Shader "Tri-Planar Bumped" {
Properties {
_Side("Side", 2D) = "white" {}
_BumpMap ("Bumpmap", 2D) = "bump" {}
_Top("Top", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
}
SubShader {
@Crushy
Crushy / Utils.cs
Last active October 12, 2019 23:50
A lot of useful Utility functions for usage in Unity3D
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details. */
using UnityEngine;
using System.Collections;
using System.IO;
@Crushy
Crushy / CallFunctionOnStart.cs
Last active August 29, 2015 14:21
A (very) simple script that allows you to call all sort of functions when a scene loads.
using UnityEngine;
using UnityEngine.Events;
public class CallFunctionOnStart : MonoBehaviour {
public UnityEvent events;
void Start () {
events.Invoke();
}
@Crushy
Crushy / WaterShader.txt
Created November 18, 2015 15:17
UE4 low poly water shader
Begin Object Class=MaterialGraphNode_Root Name="MaterialGraphNode_Root_0"
Begin Object Class=EdGraphPin Name="EdGraphPin_28022"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_28021"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_28020"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_28019"
End Object
Begin Object Class=EdGraphPin Name="EdGraphPin_28018"