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
@namespace url(http://www.w3.org/1999/xhtml); | |
@-moz-document domain("forum.unity3d.com") { | |
/* | |
Unity3D Forums Style (to make the new forums bit more easier to read..) | |
Stylish plugin for Firefox : https://addons.mozilla.org/en-US/firefox/addon/stylish/ | |
WORK-IN-PROGRESS (Feel Free To Fork/Suggest new css) | |
*/ |
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 dottest : MonoBehaviour { | |
public Transform p1; | |
public Transform p2; | |
public Transform p3; | |
public GUIText guiDOT; |
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
// Rotate sprite/object towards mouse | |
// Reference: http://johnstejskal.com/wp/rotating-objects-and-sprites-in-unity3d-using-cs-c/ | |
// https://forum.unity3d.com/threads/how-to-detect-angle-from-one-object-to-another-in-2d.477510/ | |
// Usage: Attach this script to sprite, use Orthographic camera! | |
using UnityEngine; | |
using System.Collections; | |
public class RotateSpriteTowardsMouse : MonoBehaviour | |
{ |
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 pixelPos = new Vector3(x,y,0); // x,y = texture pixel pos | |
float planeWidth=transform.renderer.bounds.size.x; | |
float planeHeight=transform.renderer.bounds.size.y; | |
// convert to 0-1 uv coords | |
float localX = ((pixelPos.x / texWidth)-0.5f)*planeWidth; | |
float localY = ((pixelPos.y / texHeight)-0.5f)*planeHeight; | |
//Vector3 worldPos = transform.TransformPoint(new Vector3(localX,localY, 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
using UnityEngine; | |
using System.Collections; | |
public class PauseMode : MonoBehaviour | |
{ | |
void Update () | |
{ | |
if (Input.GetKeyDown ("p")) Time.timeScale = 1-Time.timeScale; | |
} | |
} |
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
// http://unitypatterns.com/scripting-with-coroutines/ | |
IEnumerator Wait(float duration) | |
{ | |
for (float timer = 0; timer < duration; timer += Time.deltaTime) | |
{ | |
yield return 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
foreach(var prop in terrain.terrainData.GetType().GetProperties()) | |
{ | |
Debug.Log(prop.Name +" : "+ prop.GetValue(terrain.terrainData, null)); | |
} |
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 System.Linq; | |
.. | |
// get list of objects with tag "Player" | |
GameObject[] gos = GameObject.FindGameObjectsWithTag("Player"); | |
// get closest transform from gos[] array, into target variable, as transform object | |
var target = gos.OrderBy(go => (transform.position - go.transform.position).sqrMagnitude).First().transform; |
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 System; | |
public struct Vector2i | |
{ | |
private int X; | |
private int Y; | |
private int x | |
{ | |
set { X = value; } |
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
// example: Debug.Log(FormatTime(Time.time)); | |
string FormatTime(int t) | |
{ | |
return System.TimeSpan.FromSeconds(t).ToString(); | |
} | |
// get current datetime formatted | |
DateTime.Now.ToString("dd/MM/yyyy"); |
OlderNewer