This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
// helper script for testing angle calculation | |
// USAGE: | |
// - Attach this script to objectA and assign objectB as target | |
// - Then select objectA and move it around ObjectB and you can see angle values in inspector | |
[ExecuteInEditMode] | |
public class GetAngle : MonoBehaviour |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Matrix PlayGround Shader - UnityCoder.com | |
// References: | |
// Matrices http://www.codinglabs.net/article_world_view_projection_matrix.aspx | |
// Rotation: http://www.gamedev.net/topic/610115-solved-rotation-deforming-mesh-opengl-es-20/#entry4859756 | |
Shader "UnityCoder/MatrixPlayground" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: copy Midi.dll to Assets/Plugins/ folder | |
// Get it from https://code.google.com/p/midi-dot-net/ | |
using UnityEngine; | |
using System.Collections; | |
using Midi; // needs this | |
public class MidiSound : MonoBehaviour | |
{ | |
OutputDevice outputDevice; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Midi Player - unitycoder.com | |
// MidiOutCaps struct from http://svn.tapr.org/repos_sdr_windows/PowerSDR/trunk/Source/Console/midi.cs | |
// Midi code from http://www.codeguru.com/columns/dotnet/making-music-with-midi-and-c.html | |
// USAGE: set proper path+filename inside PlayMidi(), attach this scrip to gameobject in scene and hit play! | |
// Get midi files from internets, like: http://www.vgmusic.com/music/computer/commodore/commodore/ | |
using UnityEngine; | |
using System.Runtime.InteropServices; | |
using System.Text; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public LayerMask layerMask = 1 << 0; // default layer (0) | |
public LayerMask layerMask2 = ~0; // everything | |
public LayerMask layerMask2b = -1; // everything | |
public LayerMask layerMask3 = default;// nothing | |
public LayerMask layerMask4 = 0;// nothing | |
public LayerMask layerMask4b; // nothing | |
public LayerMask layerMask5 = 1 << 5;// layer 5 (UI) | |
public LayerMask layerMask6 = 1 << 2 | 1 << 5;// Ignore Raycast (Layer 2) AND UI (Layer 5) | |
public LayerMask layerMask7 = ~(1 << 4 | 1 << 5); // all except layer 4 and 5 | |
public LayerMask layerMask8 = ~(1 << 4); // all except layer 4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class DrawLine : MonoBehaviour | |
{ | |
Color lineColor = Color.red; | |
float distance = 100; | |
Material lineMaterial; | |
void CreateLineMaterial() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class DrawGizmos | |
{ | |
[DrawGizmo(GizmoType.Active)] // there are also other options for gizmotypes | |
static void DrawMyGizmo(MyScript script, GizmoType gizmoType) // set MyScript as your script class/name | |
{ | |
Debug.DrawRay(script.transform.position, script.transform.up*10, Color.red); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using UnityEditor; | |
using UnityEngine; | |
// from http://docs.unity3d.com/Manual/BuildingAssetBundles.html | |
public class CreateAssetBundles | |
{ | |
[MenuItem("Assets/Build AssetBundles")] | |
static void BuildAllAssetBundles() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
using Random = UnityEngine.Random; // now random is not conflicted, uses from unityengine | |
public class RandomAlias : MonoBehaviour | |
{ | |
void Start () | |
{ | |
var r = Random.value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Sprites/DefaultWithShadow" | |
{ | |
Properties | |
{ | |
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} | |
_Color ("Tint", Color) = (1,1,1,1) | |
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0 | |
_ShadowOffset ("ShadowOffset", Vector) = (0,-0.1,0,0) | |
} |