public static string ToSerializationString(this SerializedEnum element) { //Example of explicit translation immune to many simple enum refactor issues switch (element) { case SerializedEnum.First: return("First"); case SerializedEnum.Second: return("OldSerializedValue_1"); case SerializedEnum.Third: return("OldSerializedValue_2"); case SerializedEnum.Etc: return("ETC"); case SerializedEnum.OtherValues: return("OtherValues"); default: Debug.LogError($"Unknown SerializedEnum: {element}"); return(""); } }
public static void Initialize() { if (initialized) { return; } initialized = true; for (SerializedEnum i = 0; i < SerializedEnum.MAX; i++) { serializedEnums[i.ToSerializationString()] = i; } for (AnotherSerializedEnum i = 0; i < AnotherSerializedEnum.MAX; i++) { anotherSerializedEnums[i.ToSerializationString()] = i; } LoadSystemConfig(); }