namespace UnityEngine.Rendering
{
using System;
using UnityEngine;
///
/// Class to serizalize Enum as string and recover it's state
///
[Serializable]
public class SerializableEnum
{
[SerializeField]
private string m_EnumValueAsString;
[SerializeField]
private Type m_EnumType;
///
/// Value of enum
///
public Enum value
{
get
{
if (Enum.TryParse(m_EnumType, m_EnumValueAsString, out object result))
return (Enum)result;
return default(Enum);
}
set
{
m_EnumValueAsString = value.ToString();
}
}
///
/// Construct an enum to be serialized with a type
///
/// The underliying type of the enum
public SerializableEnum(Type enumType)
{
m_EnumType = enumType;
m_EnumValueAsString = Enum.GetNames(enumType)[0];
}
}
}