using UnityEngine;

using System.Collections;


public class LightMan : MonoBehaviour {

Light myLight;

Transform t;

// Use this for initialization

void Start () {

myLight = GetComponent<Light>(); //남의 꺼를 가져올때 쓰입니다.졸려

t = GetComponent<Transform>();

t = GetComponent("Transform") as Transform;

}

// Update is called once per frame

void Update () {

if (Input.GetKeyDown(KeyCode.L)){

myLight.enabled = !myLight.enabled;

}

}

}





'Computer Language > 유니티' 카테고리의 다른 글

LookAt()  (0) 2014.05.23
vector3 사용예제  (0) 2014.05.23
껏다 켯다 하기  (0) 2014.05.23
생명 주기와 색깔 바꾸기  (0) 2014.05.23
로그 찍기  (0) 2014.05.23

using UnityEngine;

using System.Collections;


public class newsource : MonoBehaviour {

public int hp;

void Awake(){

print ("Awake name = " + name);

}

void OnEnable(){

print ("OnEnabel name = " + name);

}

void OnDisable(){

print ("OnDisable name = " + name);

}

// Use this for initialization

void Start () {

print ("Start name = " + name);

}

void Reset(){

print ("Reset name = " + name);

hp = 20;

}

void FixedUpdate(){

print ("FixedUpdate = " + Time.deltaTime);

}

// Update is called once per frame

void Update () {

if(Input.GetKeyDown(KeyCode.R)){

gameObject.renderer.material.color = Color.red;

}

if(Input.GetKeyDown(KeyCode.G)){

gameObject.renderer.material.color = Color.green;

}

if(Input.GetKeyDown(KeyCode.B)){

gameObject.renderer.material.color = Color.blue;

}

}

}


'Computer Language > 유니티' 카테고리의 다른 글

vector3 사용예제  (0) 2014.05.23
불 껏다 키기  (0) 2014.05.23
생명 주기와 색깔 바꾸기  (0) 2014.05.23
로그 찍기  (0) 2014.05.23
오브젝트 찾고 지우기 1. 태그 2. 이름  (0) 2014.05.23

using UnityEngine;

using System.Collections;


public class newsource : MonoBehaviour {

public int hp;

void Awake(){

print ("Awake name = " + name);

}

void OnEnable(){

print ("OnEnabel name = " + name);

}

void OnDisable(){

print ("OnDisable name = " + name);

}

// Use this for initialization

void Start () {

print ("Start name = " + name);

}

void Reset(){

print ("Reset name = " + name);

hp = 20;

}

void FixedUpdate(){

print ("FixedUpdate = " + Time.deltaTime);

}

// Update is called once per frame

void Update () {

if(Input.GetKeyDown(KeyCode.R)){

gameObject.renderer.material.color = Color.red;

}

if(Input.GetKeyDown(KeyCode.G)){

gameObject.renderer.material.color = Color.green;

}

if(Input.GetKeyDown(KeyCode.B)){

gameObject.renderer.material.color = Color.blue;

}

}

}


'Computer Language > 유니티' 카테고리의 다른 글

불 껏다 키기  (0) 2014.05.23
껏다 켯다 하기  (0) 2014.05.23
로그 찍기  (0) 2014.05.23
오브젝트 찾고 지우기 1. 태그 2. 이름  (0) 2014.05.23
이것만은 알고갚시다. 9장.  (0) 2014.05.20

Debug.Log ("Log Info");

Debug.LogWarning("Log Waring");

Debug.LogError("Log Error")


using UnityEngine;

using System.Collections;


public class script : MonoBehaviour {

public GameObject[] Robot;

int HP;

// Use this for initialization

void Start () {

GameObject robot = GameObject.FindGameObjectWithTag("Sphere");

robot.SetActive(false);

}

// Update is called once per frame

void Update () {

if(Time.time > 2.0f){

GameObject robot1 = GameObject.Find("Sphere");

robot1.tag = "Sphere";

robot1.SetActive(false);

}

}

}


'Computer Language > 유니티' 카테고리의 다른 글

생명 주기와 색깔 바꾸기  (0) 2014.05.23
로그 찍기  (0) 2014.05.23
이것만은 알고갚시다. 9장.  (0) 2014.05.20
남은 시간 출력 하기. 그외 시간 함수  (0) 2014.05.20
프로퍼티  (0) 2014.05.20

using UnityEngine;

using System.Collections;


public class NameCard{

private int age;

private string name;

public int Age

{

get{return age;}

set{ age = value;}

}

public string Name

{

get{return name;}

set{ name = value;}

}

}


public class test : MonoBehaviour {


// Use this for initialization

void Start () {

NameCard MyCard = new NameCard();

MyCard.Age = 24;

MyCard.Name = "SUNG SUCK";

print(string.Format("age : {0}", MyCard.Age));

print(string.Format("name : {0}", MyCard.Name));

}

// Update is called once per frame

void Update () {

}

}




using UnityEngine;

using System.Collections;


public class test2 : MonoBehaviour {


// Use this for initialization

void Start () {

var nameCard = new { Name="hamgwangho", Age=123} ;

print (string.Format("Name:{0}, Age:{1}", nameCard.Name, nameCard.Age));

var complex = new { Real = 3, Imaginary = -12} ;

print (string.Format("Real:{0}, Imaginary:{1}", complex.Real, complex.Imaginary));

}

// Update is called once per frame

void Update () {

}

}








using UnityEngine;

using System.Collections;

using System;

public class chap9_10 : MonoBehaviour {


// Use this for initialization

void Start () {

DateTime d = new DateTime(2014, 12, 31);

TimeSpan diff = d - DateTime.Now;

DateTime u = DateTime.Now.ToUniversalTime();

DateTime local = DateTime.Now.ToLocalTime();

print(u.ToShortDateString());

print (u.ToShortTimeString());

print ("Left Days to 2014, 12, 31 is" + (int)diff.TotalDays + "Days");

print("universalTime" + u);

print ("localTime" + local);

}

// Update is called once per frame

void Update () {

}

}


using UnityEngine;

using System.Collections;


class Person{

public Person(){birthYear = 2000;}

private int age;

public int birthYear;

public int Age{getreturn 2014 - birthYear;}}

// set{age = value;}

//}

public string Name{get; set;}

}


public class chap9_1 : MonoBehaviour {


// Use this for initialization

void Start () {

Person person1 = new Person(){

birthYear = 2014, Name = "Son"

} ;

Person[] persons = { 

//new Person(2014, "Son"),

//new Person(2014, "Son"),

new Person() { birthYear = 2014, Name = "Son"} ,

new Person() { birthYear = 2010, Name = "Yoon"} ,

new Person() { birthYear = 2011, Name = "Jong"} ,

} ;

person1.birthYear = 1989;

person1.Name = "son";

print("person age = " + person1.Age + ", name = " + person1.Name);

}

// Update is called once per frame

void Update () {

}

}






using UnityEngine;

using System.Collections;


public class chap11_1 : MonoBehaviour {


// Use this for initialization

void Start () {

Hashtable ht = new Hashtable();

ht["Microsoft"] = "www.microsoft.com";

ht["Google"] = "www.google.com";

ht["Naver"] = "www.naver.com";

print (string.Format("url:{0}  {1}",  ht, ht["Microsoft"]));

print (string.Format("url:{0}  {1}", ht, ht["Google"]));

print (string.Format("url{0}  {1}", ht, ht["Naver"]));

foreach(DictionaryEntry e in ht)

{

print ("company : " + e.Key + ", " + " url : "+ e.Value);

}

print(FindURL("Google"));

print(FindURL("Daum"));

}

string FindURL (string company){

if(ht.ContainsKey(company))

return ht[company] as string;

else

return "Not Found";

}

// Update is called once per frame

void Update () {

}

}


'Computer Language > 유니티' 카테고리의 다른 글

남은 시간 출력 하기. 그외 시간 함수  (0) 2014.05.20
프로퍼티  (0) 2014.05.20
상태 이상시 잘쓰는 비트 연산  (0) 2014.05.20
Item  (0) 2014.05.20
문자 짜르기 해쉬 테이블 사용  (0) 2014.05.20

using UnityEngine;

using System.Collections;


public class chap10_BitArray : MonoBehaviour {


// Use this for initialization

void Start () {

BitArray bits = new BitArray(4);

bits[0] = true;

bits[1] = false;

bits[2] = true;

bits[3] = false;

BitArray bits2 = new BitArray(new bool[]{true, true, false, false} );

string s = "";

foreach(bool b in bits){

s += b.ToString() + ", ";

}

print (s);

bits.And(bits2);

print ("And true, true, false, false");

s = "";

foreach(bool b in bits){

s += b.ToString() + ", ";

}

print (s);

}

// Update is called once per frame

void Update () {

}

}




'Computer Language > 유니티' 카테고리의 다른 글

프로퍼티  (0) 2014.05.20
해쉬 테이블 DictionaryEntry 사용 예제  (0) 2014.05.20
Item  (0) 2014.05.20
문자 짜르기 해쉬 테이블 사용  (0) 2014.05.20
해쉬 테이블 -> 어레이 리스트  (0) 2014.05.20

+ Recent posts