Skip to content

Instantly share code, notes, and snippets.

@calderarchinuk
calderarchinuk / ShakeInputEvent.cs
Last active November 13, 2019 05:51
invokes event when a mobile device is shaken
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//https://stackoverflow.com/questions/31389598/how-can-i-detect-a-shake-motion-on-a-mobile-device-using-unity3d-c-sharp
public class ShakeInputEvent : MonoBehaviour
{
public delegate void onShakeInput();
/// when the phone is shaken
@calderarchinuk
calderarchinuk / ArcRender.cs
Created February 8, 2018 03:06
calculate and render an arc affected by gravity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ArcRender : MonoBehaviour
{
public int Count = 10;
public float PowerMultiplier = 2;
public Transform handle;
@calderarchinuk
calderarchinuk / WorldSpaceUV.shader
Created February 6, 2018 03:42
world space uv shader
Shader "Custom/World Space UV" {
Properties {
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
//_Ramp ("Toon Ramp (RGB)", 2D) = "gray" {}
_Scale ("Texture Scale", Float) = 0.1
}
SubShader {
Tags { "RenderType"="Opaque" }
@calderarchinuk
calderarchinuk / AddScenesToBuild.cs
Created January 3, 2018 04:50
add all scene files in project to build settings
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.IO;
public partial class BonusMenuItems
{
[MenuItem("Tools/Add All Scenes to Build")]
static void AddAllScenesToBuild()
@calderarchinuk
calderarchinuk / WorldCanvasMenuItem.cs
Last active February 5, 2018 18:27
unity menu item to quickly add a canvas set to worldspace
using UnityEngine;
using UnityEditor;
//Create a 2m Canvas set to RenderMode = WorldSpace in a position that isn't insane
public partial class MenuItems
{
[MenuItem("GameObject/UI/Canvas - WorldSpace", priority = 2061)]
public static void MakeWorldspaceCanvas()
{
@calderarchinuk
calderarchinuk / BonusMenuItems.cs
Last active January 13, 2019 20:31
Unity snap selection to ground
using UnityEngine;
using UnityEditor;
using System.Collections;
public partial class BonusMenuItems
{
[MenuItem("Edit/Snap To Ground %#g")]
static void SnapSelectionToGround()
{
Undo.RecordObjects(Selection.transforms,"Snap to Ground");