using UnityEngine;

using System.Collections;


public class Example1 : MonoBehaviour {

/*

string GetInfo(string lastName, string firstName, int age){

return firstName + "," + lastName + ",Age"=+age;

}

*/

int Add(int a, int b){

return a+b;

}

public GameObject Cube;

public GameObject Silinder;

public int dir = 0;

/*

int Calc(int a, int b, out int result){

result = a + b;

result3 = "ok";

return a - b;

}

*/

public int Count = 10;

int Sum(int Count){

int sum1 = 0;

int sum = 0;

for(int i = 1; i<=Count; i++){

sum = Add (sum1, i);

sum1++;

}

return sum;

}

// Use this for initialization

void Start () {

int count = 10;

int result = Sum (Count);

Debug.Log (count+ result);

/*

string fullname = GetFullName("kim", "yuna");

Debug.Log (fullname);

int result = Add (30, 20);

Debug.Log(result);

//int result4;

//Add(30,20, out result2);

//Debug.Log (result);

int result3;

Calc (30, 20, out result3);

Debug.Log("result3_1="+result3 +"result3_2="+result);

*/

}

void moveLeft(GameObject object1){

object1.transform.Translate(new Vector3(-0.1f, 0, 0));

//object1.transform.Rotate(new Vector3(10f, 10f, 10f));

//object1.transform.localScale = new Vector3(10, 10, 10);

}

void moveRight(GameObject object2){

object2.transform.Translate(new Vector3(0.1f, 0, 0));

}

// Update is called once per frame

void Update () {

if (dir <0//director

moveLeft (Cube);

else if(dir >0)

moveRight(Cube);

}

//1per 60

void OnGUI(){

if(GUI.Button(new Rect(10,10,100,100), "Move Left")){

Debug.Log ("Clicked1");

//moveLeft(Cube);

dir = -1;

}

if(GUI.Button(new Rect(120,10,100,100), "stop")){

Debug.Log ("Clicked2");

//moveRight(Silinder);

dir = 0;

}

if(GUI.Button(new Rect(230,10,100,100), "Move Right")){

Debug.Log ("Clicked2");

//moveRight(Silinder);

dir = 1;

}

}

}




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

자료형(실수)  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
탱크 이동  (0) 2014.03.28
고스톱 만들기(두 좌표의 차이를 이용하여 이동)  (0) 2014.03.28
큐브 회전  (0) 2014.03.28

+ Recent posts