using UnityEngine;

using System.Collections;


public class ExWhile : MonoBehaviour {


// Use this for initialization

void Start () {

string[] names = new string[]{

"Hello", "Inha", "Pass","Pass1", "Quit", "Morning" 

} ;

int i = -1;

while(true){

i++;

if(names[i] == "Pass"){

continue;

}

if(names[i] == "Pass1"){

continue;

}

print (names[i]);

if(names[i] == "Quit")

break;

}

}

// Update is called once per frame

void Update () {

}


}

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

npc 최대값 최소값 이름 출력  (0) 2014.04.04
while문& for문 별찍기 놀이  (0) 2014.04.04
배열  (0) 2014.03.31
C# String Format  (0) 2014.03.31
형변환  (0) 2014.03.31

void Start () {

int[] numbers = new int[5]{10, 30, 40, 50, 70} ;

string[] names = new string[3]{"KIM", "Lee", "Park"} ;

float[] numbers2 = new float[]{10.2f, 30.4f, 40.5f, 50.6f, 70.33f} ;

int i;

int max = 0;

int sum = 0;

string text;

for (i = 0; i < numbers2.Length; i++){

//if(max < numbers[i])

// max = numbers[i];

text = string.Format("names[{0}] = {1:F3}" , i, numbers2[i]);

print (text);

}

print ("max = " + max);

for(i =0; i < numbers.Length; i++){

sum = numbers[i] + sum;

}

print ("Rank = " + ((System.Array)numbers).Rank);

print ("sum=" + sum);

}



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

while문& for문 별찍기 놀이  (0) 2014.04.04
while  (0) 2014.04.04
C# String Format  (0) 2014.03.31
형변환  (0) 2014.03.31
boolean  (0) 2014.03.31

void ShowStringFormat2 ()

{

// C# string format 

string s = string.Format (

        "(C) Currency: . . . . . . . . {0:C}\n" +

        "(D) Decimal:. . . . . . . . . {0:D}\n" +

        "(E) Scientific: . . . . . . . {1:E}\n" +

        "(F) Fixed point:. . . . . . . {1:F5}\n" +

        "(G) General:. . . . . . . . . {0:G}\n" +

        "    (default):. . . . . . . . {0} (default = 'G')\n" +

        "(N) Number: . . . . . . . . . {0:N0}\n" +

        "(P) Percent:. . . . . . . . . {1:P}\n" +

        "(R) Round-trip: . . . . . . . {1:R}\n" +

        "(X) Hexadecimal:. . . . . . . {0:X}\n",

        12300, -12300.45678f); 

print (s);

}



Number가 주로 잘 쓰입니다.

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

while  (0) 2014.04.04
배열  (0) 2014.03.31
형변환  (0) 2014.03.31
boolean  (0) 2014.03.31
이스케이프 문자  (0) 2014.03.31


using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

byte a = 250;   //0~255

short b = a;       //-32765 ~ 32765

ushort c = 2000; //65535

sbyte d = (sbyte)c;         //-128~127 

print("b =" + b);  

print ("d=" + d);

}

// Update is called once per frame

void Update () {

}

}

가지고 있는 값보다 크다면 형변환을 해줘야 함. 하지만 그 값은 범위내에 있어야 제대로 표현됨.

범위내에 없다면 다른 값을 리턴

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

배열  (0) 2014.03.31
C# String Format  (0) 2014.03.31
boolean  (0) 2014.03.31
이스케이프 문자  (0) 2014.03.31
문자형  (0) 2014.03.31

using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

//bool isStudent = false;

System.Boolean isStudent = false;

int age1 = 10;

int age2 = 30;

if(age1<19)

isStudent = true;

else

isStudent = false;

print ("age1 isStudent ="  + isStudent);

if(age2<19)

isStudent = true;

else

isStudent = false;

print ("age2 isStudent ="  + isStudent);

}

// Update is called once per frame

void Update () {

}


int age1 = 10;

bool isArmy = 20 <=age1  && age1 < 30;

print("age1 isStudent = " + isArmy);



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

C# String Format  (0) 2014.03.31
형변환  (0) 2014.03.31
이스케이프 문자  (0) 2014.03.31
문자형  (0) 2014.03.31
실수를 많이 해서 실수형.  (0) 2014.03.31

void Start () {

string text = @"\tHello\nWorld";

print (text);

string text2 = "\\tHello\\nWorld";

print (text2);

string text3 = "\tHello\nWorld";

print (text3);

}

}


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

형변환  (0) 2014.03.31
boolean  (0) 2014.03.31
문자형  (0) 2014.03.31
실수를 많이 해서 실수형.  (0) 2014.03.31
자료형(실수)  (0) 2014.03.31

public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

char ch1 = 'a';

char ch2 = 'b';

char ch3 = '\\';

char t = '\t';

char n = '\n';

string e = "Hello" + n + t + t + "World";   //앞에 더 크면 뒤에꺼 자동 형변환 해줌니다.

string a = "Hello, World";

string b = "Hello,\tWorld";

string c = "Hello,\nWorld";

string d = e + c;

print ("ch1 " + ch1);

print ("ch2 " + ch2);

print ("ch3 " + ch3);

print ("a " + a);

print ("b" + b);

print ("c " + c);

print ("d" + d);

}

// Update is called once per frame

void Update () {

}

}


char 2바이트 연산이 안된다. char tostring으로 바꿔줘야 한다.




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

boolean  (0) 2014.03.31
이스케이프 문자  (0) 2014.03.31
실수를 많이 해서 실수형.  (0) 2014.03.31
자료형(실수)  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31

using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

float f1 = 0.1f - 0.2f;

float f2 = 43.1f - 43.2f;

double d3 = 0.1 - 0.2;

print("0.1-0.2=" + f1);

print ("43.1f-43.2f = " + f2);

if(f1 == f2)

{

print("Equal");

}

else{

print ("Not Equal");

}

}

// Update is called once per frame

void Update () {

}

}

실수형은 실수를 많이 한다.


using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

decimal a = 0.1m - 0.2m;

decimal b = 43.1m - 43.2m;

print (" 0.1m - 0.2m = " + a);

print (" 43.1m - 43.2m = " + b);

if(a == b)

print ("equal");

else

print ("Not Equal");

}

// Update is called once per frame

void Update () {

}

}
decimal은 오차가 없다




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

이스케이프 문자  (0) 2014.03.31
문자형  (0) 2014.03.31
자료형(실수)  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31

void Start () {

Debug.Log("float Min = " + float.MinValue + ", Max = " + float.MaxValue);

Debug.Log ("double Min = " + double.MaxValue + ", Max = " + double.MaxValue);

Debug.Log ("decimial Min = " + decimal.MaxValue + ",Max = " + decimal.MaxValue);

}


decimal 돈 계산시 사용, 29자리. 속도가 느리다

float double 계산이 정확하지 않음. 그나마 더블이 정확한데 오차가 많다.

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

문자형  (0) 2014.03.31
실수를 많이 해서 실수형.  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31
탱크 이동  (0) 2014.03.28

using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

PrintTableData();

PrintSystemTableData();

}

// Update is called once per frame

void Update () {

}

void PrintSystemTableData(){

Debug.Log("System.Sbyte Min = "+ System.SByte.MinValue + "  Max = " + System.SByte.MaxValue);

Debug.Log("System.Byte Min = "+ System.Byte.MinValue + "  Max = " + System.Byte.MaxValue);

Debug.Log("System.Int16 Min = "+ System.Int16.MinValue + " Max = " + System.Int16.MaxValue);

Debug.Log("System.UInt16 Min = "+ System.UInt16.MinValue + "  Max = " + System.UInt16.MaxValue);

Debug.Log("System.int32 Min = "+ System.Int32.MinValue + "  Max = " + System.Int32.MaxValue);

Debug.Log("System.UInt32 Min = "+ System.UInt32.MinValue + "  Max = " + System.UInt32.MaxValue);

Debug.Log("System.Int64 Min = "+ System.Int64.MinValue + " Max = " + System.Int64.MaxValue);

Debug.Log("System.UInt64 Min = "+ System.UInt64.MinValue + "  Max = " + System.UInt64.MaxValue);

}

void PrintTableData(){

Debug.Log("sbyte Min = "+ sbyte.MinValue + " sbyte Max = " + sbyte.MaxValue);

Debug.Log ("byte Min = " + byte.MinValue + " byte Max = " + byte.MaxValue);

Debug.Log("short Min = "+ short.MinValue + " short Max = " + short.MaxValue);

Debug.Log("ushort Min = " + ushort.MinValue + " ushort Max = " + ushort.MaxValue);

Debug.Log("int Min = "+ int.MinValue + " int Max = " + int.MaxValue);

Debug.Log("usint Min = " + uint.MinValue + " uint Max = " + uint.MaxValue);

Debug.Log ("long Min = " + long.MinValue + " long Max = " + ulong.MaxValue);

Debug.Log("ulong Min = " + ulong.MinValue + " ulong max = " + ulong.MaxValue);

}

void PrintTableData2(){

Debug.Log("float Min = " + float.MinValue + ", Max = " + float.MaxValue);

Debug.Log ("double Min = " + double.MaxValue + ", Max = " + double.MaxValue);

Debug.Log ("decimial Min = " + decimal.MaxValue + ",Max = " + decimal.MaxValue);

}

}




+ Recent posts