Skip to content

Instantly share code, notes, and snippets.

View JT5D's full-sized avatar
💭
Multiversing...

JT5D JT5D

💭
Multiversing...
View GitHub Profile
foreach(var prop in terrain.terrainData.GetType().GetProperties())
{
Debug.Log(prop.Name +" : "+ prop.GetValue(terrain.terrainData, null));
}
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;
using System;
public struct Vector2i
{
private int X;
private int Y;
private int x
{
set { X = value; }
// example: Debug.Log(FormatTime((float)Time.time));
string FormatTime(int t)
{
return System.TimeSpan.FromSeconds(t).ToString();
}
using UnityEngine;
using UnityEditor;
using System.Collections;
public class CreatePlane : ScriptableWizard
{
public enum Orientation
{
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;
// 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
public InputField myField;
//..
myField.Select();
myField.ActivateInputField();
EventSystem eventSystem;
//..
void Start ()
{
GameObject go = GameObject.Find("EventSystem");
if (go==null)
{
Debug.LogError("EventSystem not founded..");
}else{
eventSystem = go.GetComponent<UnityEngine.EventSystems.EventSystem>();
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