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
| foreach(var prop in terrain.terrainData.GetType().GetProperties()) | |
| { | |
| Debug.Log(prop.Name +" : "+ prop.GetValue(terrain.terrainData, null)); | |
| } |
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.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 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; | |
| public struct Vector2i | |
| { | |
| private int X; | |
| private int Y; | |
| private int x | |
| { | |
| set { X = 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
| // example: Debug.Log(FormatTime((float)Time.time)); | |
| string FormatTime(int t) | |
| { | |
| return System.TimeSpan.FromSeconds(t).ToString(); | |
| } |
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; | |
| using System.Collections; | |
| public class CreatePlane : ScriptableWizard | |
| { | |
| public enum Orientation | |
| { |
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
| carves.Sort(delegate(Carve a, Carve b) { return a.cumulativeDifference.CompareTo(b.cumulativeDifference); }); | |
| /* | |
| // example struct values | |
| public struct Carve | |
| { | |
| public float cumulativeDifference; | |
| public List<int> x; | |
| public List<int> y; |
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
| // need to create new sprite, cannot assign or convert Texture2D into sprite | |
| Sprite sprite = Sprite.Create (tex, new Rect(0,0,tex.width,tex.height), new Vector2 (0, 0), pixelToUnits); | |
| GetComponent<SpriteRenderer>().sprite = sprite; | |
| http://docs.unity3d.com/ScriptReference/Sprite.Create.html |
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 InputField myField; | |
| //.. | |
| myField.Select(); | |
| myField.ActivateInputField(); |
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
| EventSystem eventSystem; | |
| //.. | |
| void Start () | |
| { | |
| GameObject go = GameObject.Find("EventSystem"); | |
| if (go==null) | |
| { | |
| Debug.LogError("EventSystem not founded.."); | |
| }else{ | |
| eventSystem = go.GetComponent<UnityEngine.EventSystems.EventSystem>(); |
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/MeshMelt2" { | |
| Properties { | |
| _MainTex ("Texture", 2D) = "white" {} | |
| _LavaTex ("LavaTexture", 2D) = "white" {} | |
| _Amount ("Extrusion Amount", Range(-1,1)) = 0.5 | |
| } | |
| SubShader { | |
| Tags { "RenderType" = "Opaque" } | |
| CGPROGRAM |