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 UnityEngine.UI; | |
public class ColorFader : MonoBehaviour | |
{ | |
public float delay = 2; | |
void Start () { | |
StartCoroutine(Fade(delay)); |
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
// MULTIPLY | |
a=1 | |
a << 1 == a*2 [ a=2 ] | |
a << 2 == a*4 [ a=4 ] | |
a << 3 == a*8 [ a=8 ] | |
1 << 1 == 1*2 [ a=2 ] | |
1 << 2 == 1*4 [ a=4 ] | |
1 << 3 == 1*8 [ a=8 ] |
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; | |
public class RotateByDistance : MonoBehaviour { | |
public float moveSpeed = 2f; | |
float radius = 0.5f; | |
void Start () |
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; | |
// source: http://diaryofagraphicsprogrammer.blogspot.fi/2009/10/bitmasks-packing-data-into-fp-render.html | |
public class PackTest : MonoBehaviour { | |
void Start () { |
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
rawLine = Regex.Replace(rawLine, "[^0-9 ]", ""); // remove non-numeric chars, except space |
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
Array.Sort(tiles, new Comparison<YourThing>((a, b) => b.x.CompareTo(a.x))); |
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; | |
// http://en.wikipedia.org/wiki/Dolly_zoom | |
public class DollyZoom : MonoBehaviour | |
{ | |
public Transform target; |
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
x - x % gridWidth | |
// http://stackoverflow.com/questions/1892474/c-sharp-create-snap-to-grid-functionality |
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
// 2 loops in 1 : https://jsfiddle.net/rntasz32/2/ | |
var width=3; | |
var height=3; | |
var size = width*height; | |
var x = 0; | |
var y = 0; | |
for (var i = 0; i < size; i++) | |
{ | |
x = (i / 3) | 0; |
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
Vector3 from = p1-pMiddle; | |
Vector3 to = p2-pMiddle; | |
float angle = AngleBetween(from, to); | |
float AngleBetween(Vector3 vector1, Vector3 vector2) | |
{ | |
var sin = vector1.x * vector2.y - vector2.x * vector1.y; | |
var cos = vector1.x * vector2.x + vector1.y * vector2.y; |