728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// struct는 값타입
// class는 주소 타입
public enum Item{
Weapon,
Sheild,
Potion,
}
public struct MyStruct //상속이 불가
{
public int a; //class와는 다르게 직접적인 값을 대입할 수 없다.
public MyStruct(int _a, int _b, int _c, int _d){
//생성자 javaScript의 constructor와 같다
a = _a; b = _b; c = _c; d = _d;
}
public void GetA(int value){
a = 1;
}
}
public class test : MonoBehaviour
{
MyStruct keidy;
// struct는 선언할 때 MyStruct keidy;를 사용해야하지만\
// class는 MyStruct keidy = new MyStruct();
Item item;
void Start(){
// keidy.a = 2;
item = Item.Weapon;
print(item)
}
}
728x90