This file contains 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 Test : MonoBehaviour { | |
public LayerMask targetLayer; | |
Vector3 prevPos; | |
void Start () { |
This file contains 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 UnityEditor; | |
public class ClearPrefs : MonoBehaviour { | |
// otherwise adjusting player settings resolution wont do anything.. | |
// http://answers.unity3d.com/questions/516517/why-doesnt-standalone-build-resolution-settings-af.html | |
[MenuItem("Edit/Reset Playerprefs")] |
This file contains 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; | |
// modified from : http://docs.unity3d.com/ScriptReference/Mesh-uv.html | |
public class PlanarUVMap : MonoBehaviour { | |
public bool flipX=false; | |
void Start() |
This file contains 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
// ==UserScript== | |
// @name AssetStoreBuddy | |
// @namespace unitycoder.com | |
// @include https://www.assetstore.unity3d.com/en/#!/search/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
// currently need to press F5 to run these |
This file contains 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 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 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 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 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 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; |