λΉ„μ£Όμ–ΌμŠ€νŠœλ””μ˜€ λ‹·λ„·ν”„λ ˆμž„μ›Œν¬ λ˜λŠ” λ‹·λ„·μ½”μ–΄ ν™˜κ²½μ—μ„œ RPGκ²Œμž„ λ‘œμ§μ„ μ§€ λ•Œ


// λͺ¨λ“  λ°©λ“€μ˜ λΆ€λͺ¨ 클래슀

public abstract class Field /* μœ λ‹ˆν‹°μ— κ°€λ©΄Β : MonoBehaviour λ₯Ό μƒμ†μ‹œν‚¨λ‹€ λ©”λͺ¨*/

{

public virtual bool Locked { get; set; }Β  = false;

}


λΌλŠ” 클래슀λ₯Ό λ§Œλ“€μ–΄ 놓고


public abstract class Building : Field

{


}


λΌλŠ” μžμ‹ 클래슀λ₯Ό μž‘μ„±ν•˜κ³ 


public class MyBuilding : Building

{

public override bool Locked { get; set; } = true;

}


λΌλŠ” μ†μž 클래슀λ₯Ό μž‘μ„±ν•˜λŠ” λ°©μ‹μœΌλ‘œ 상속 ꡬ쑰λ₯Ό κ³΅λΆ€ν–ˆμŒ



그리고 이 클래슀 λ­‰μΉ˜λ₯Ό μœ λ‹ˆν‹°λ‘œ κ·ΈλŒ€λ‘œ λ“€κ³  μ™€μ„œ κ²Œμž„μ˜€λΈŒμ νŠΈμ˜ μ»΄ν¬λ„ŒνŠΈλ‘œ 써먹으렀고 μ‹œλ„ν•¨


using TestGame;


public class MyBuilding : Field.Building.MyBuilding



κ²°κ³Ό :


The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(MyBuilding) <IsLocked>k__BackingField


응 μ•ˆ 돼 γ…‹



μ±—λ΄‡λ‹˜ 이게 μ•ˆλ˜λŠ” μ΄μœ κ°€ λ­”κ°€μš”?


"직렬화 μ‹œμŠ€ν…œμ΄ λ‹¬λΌμ„œ κ·Έλž˜μš”. μ†μžκ°œμ²΄ 속성 μ•žμ— [SerializeField]λ₯Ό λΆ™μ΄μ„Έμš”"


...직?λ ¬ν™”λŠ” μ„Έμ΄λΈŒ λ‘œλ“œν• λ•Œ μ“°λŠ”κ±° μ•„λ‹˜?


μ•„λ¬΄νŠΌ λͺ»μ•Œμ•„λ“€μ—ˆλŠ”λ° μ‹œν‚€λŠ”λŒ€λ‘œ 함



κ²°κ³Ό :


The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(MyBuilding) <IsLocked>k__BackingField


응 또 μ•ˆλΌ γ…‹



μ±—λ΄‡λ‹˜ μ•ˆλ˜λŠ”λ°μš”?


"μ™œλƒλ©΄ μ‘°λΆ€λͺ¨μ˜ virtual isLocked에 { get; set; }이 μžˆμ–΄μ„œ κ·Έλž˜μš”. 이건 직렬화 λͺ»ν•΄μš”. setter μ§€μš°μ„Έμš”"


그럼 제 λ‘œμ§μ„ λͺ»μ“°λŠ”λ°μš”... μžλ™κ΅¬ν˜„μ†μ„± λ‹€ 버리고 private μ§€μ—­λ³€μˆ˜λ‘œ λ§Œλ“  λ‹€μŒ GetIsLocked() SetIsLocked() λ©”μ„œλ“œλ₯Ό 일일이 μž‘μ„±ν•˜λΌλŠ” λ§μ”€μ΄μ‹ κ°€μš”?


"예"


μ•„



λ­”κ°€ ꡉμž₯히 μ‹¬κΈ°λΆˆνŽΈν•¨