Skip to content

solutena/ToEnumAttribute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

ToEnumAttribute

인스펙터에서

string 타입을 지정한 enum 형식으로 보여주는 어트리뷰트입니다.

예제

public enum ItemType
{
	Weapon,
	Shield,
	Armor
}
public class Item : MonoBehaviour
{
	[ToEnum(typeof(ItemType))] public string itemType;
}

image

활용

meta 파일에는 string으로 저장되기 때문에

enum의 중간에 값을 추가해도 값이 변하지 않습니다.

public enum ItemType
{
	None, //추가
	Weapon,
	Shield,
	Armor
}
public class Item : MonoBehaviour
{
	[ToEnum(typeof(ItemType))] public string stringType;
	public ItemType enumType;
}

None타입 추가 전

image

None타입 추가 후

image