UGS에 커스텀 클래스 추가하는 부분에서 오류가 났다.
namespace Hamster.ZG.Type
{
public class CombineRule
{
public CombineType RuleType;
public BlockType AllowedType; // 유형 허용
public List<int> AllowedBlocksIds = new(); // 특정 블럭 허용
}
[Type(typeof(CombineRule), new string[] {"CombineRule"})]
public class CombineRuleType : IType
{
public object DefaultValue => null;
/// <summary>
/// value는 스프레드 시트에 적혀있는 값
/// </summary>
public object Read(string value)
{
string[] split = value.Split(',');
List<int> idList = new List<int>();
for (int i = 2; i < split.Length; i++)
{
split[i].Replace("[", string.Empty);
split[i].Replace("]", string.Empty);
if (int.TryParse(split[i].Trim(), out int id))
{
idList.Add(id);
}
else Debug.Log($"{i} empty");
}
return new CombineRule()
{
RuleType = (CombineType)Enum.Parse(typeof(CombineType), split[0]),
AllowedType = (BlockType)Enum.Parse(typeof(BlockType), split[1]),
AllowedBlocksIds = idList
};
}
/// <summary>
/// value write to google sheet
/// </summary>
public string Write(object value)
{
return null;
}
}
}
namespace를 추가 안해주면 경로를 못찾아서 오류가 난다.
추가해줘도 key값을 못찾는 오류가 발생했다.
CombineRule은 Enum값을 포함하는데, 구글 시트에 비워둔 것이 문제였다.
Enum에 None을 추가하여 다 넣어줘서 해결했다.