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; | |
// original : http://wiki.unity3d.com/index.php?title=CreatePlane#C.23_-_CreatePlane.cs | |
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 |
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 Melter : MonoBehaviour { | |
public Transform heatPoint; | |
public bool restoreColor=false; | |
void Start () { | |
var mesh = GetComponent<MeshFilter>().mesh; |
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
config.params["disableContextMenu"] = true; // add this line | |
var u = new UnityObject2(config); |
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
var stopwatch = new System.Diagnostics.Stopwatch(); | |
stopwatch.Start(); | |
// your function here.. | |
stopwatch.Stop(); | |
//Debug.Log("Timer: " + stopwatch.Elapsed); | |
Debug.Log("Timer: " + stopwatch.ElapsedMilliseconds); | |
stopwatch.Reset(); |
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
void GetActiveToggle(ToggleGroup group) | |
{ | |
// get first active toggle (and actually there should be only one in a group) | |
foreach (var item in group.ActiveToggles()) | |
{ | |
Debug.Log(item.name); | |
break; | |
} | |
} |