mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-22 23:18:01 -05:00
21 lines
402 B
C#
21 lines
402 B
C#
using System;
|
|
|
|
|
|
namespace VRM
|
|
{
|
|
public static class EnumUtil
|
|
{
|
|
public static T TryParseOrDefault<T>(string src, T defaultValue=default(T)) where T : struct
|
|
{
|
|
try
|
|
{
|
|
return (T)Enum.Parse(typeof(T), src, true);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return defaultValue;
|
|
}
|
|
}
|
|
}
|
|
}
|