using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
public class people
{
public string name {get;set;}
public int age{get;set;}
public int attack{get;set;}
}
people hyunwoo;
void Start(){
hyunwoo = new people();
hyunwoo.name="hyunwoo";
hyunwoo.age = 30;
hyunwoo.attack=3;
Debug.Log(hyunwoo.name);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour {
void Start(){
Age = 10;
Age = 25;
}
private int age;
public int Age{
get{
return age;
}
set{
if (value < 20)
{
print ("20세 미만은 사용 불가합니다.");
}
else
{ age = value;
AgeChanged ();
}
}
}
void AgeChanged (){
Debug.Log("나이가 변경되었습니다");
}
}