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 Replayer : MonoBehaviour | |
| { | |
| public float delayPerFrame = 0.02f; | |
| public Transform target; | |
| Vector3[] replay; |
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 FollowPosition : MonoBehaviour | |
| { | |
| public Transform target; | |
| void LateUpdate() | |
| { | |
| transform.position = target.position; | |
| } |
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; | |
| // move transform randomly inside circle | |
| // usage: attach to gameobject, assign sprite to thing field | |
| public class RandomInsideCircle : MonoBehaviour | |
| { | |
| public float speed = 5; | |
| public float radius = 5; |
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
| #if UNITY_EDITOR | |
| using UnityEngine; | |
| using UnityEditor; | |
| // Usage: Attach to gameobject, assign target gameobject (from where the mesh is taken), Run, Press savekey | |
| public class SaveMeshInEditor : MonoBehaviour | |
| { | |
| public KeyCode saveKey = KeyCode.F12; |
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 "Custom/FakeTubeishLight" | |
| { | |
| Properties | |
| { | |
| _MainTex ("Texture", 2D) = "white" {} | |
| } | |
| SubShader | |
| { | |
| Tags { "RenderType"="Opaque" } | |
| LOD 100 |
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 UnityEditor; | |
| using UnityEngine; | |
| using System.Collections.Generic; | |
| // Hierarchy Icons http://answers.unity3d.com/answers/1113260/view.html | |
| [InitializeOnLoad] | |
| class MyHierarchyIcons | |
| { | |
| static Texture2D texturePanel; |
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
| // removes RigidbodyConstraints2D.FreezePositionY from current constraints | |
| rb.constraints = rb.constraints&~RigidbodyConstraints2D.FreezePositionY; | |
| // bitwise math: http://stackoverflow.com/questions/3920307/how-can-i-remove-a-flag-in-c |
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 UnityEngine.UI; | |
| public class SliderPingPong : MonoBehaviour | |
| { | |
| public Slider slider; | |
| public float speed = 1; | |
| float pos = 0; | |
| void Update() |
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 with some colors | |
| var colors = [ 'red', 'green', 'blue', 'magenta', 'purple', 'plum', 'orange' ]; | |
| // ... in random order | |
| colors.sort(function(a,b) { return Math.random() > 0.5; } ); |
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
| // we want to keep history of all sent messages | |
| var obj = { | |
| time: (new Date()).getTime(), | |
| text: htmlEntities(message.utf8Data), | |
| author: userName, | |
| color: userColor | |
| }; | |
| history.push(obj); | |
| history = history.slice(-100); // keep max 100 |