diff options
Diffstat (limited to 'Assets/ThirdParty/VRM/VRM/UniVRM/Scripts/Validation.cs')
-rw-r--r-- | Assets/ThirdParty/VRM/VRM/UniVRM/Scripts/Validation.cs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Assets/ThirdParty/VRM/VRM/UniVRM/Scripts/Validation.cs b/Assets/ThirdParty/VRM/VRM/UniVRM/Scripts/Validation.cs new file mode 100644 index 00000000..df2d03a8 --- /dev/null +++ b/Assets/ThirdParty/VRM/VRM/UniVRM/Scripts/Validation.cs @@ -0,0 +1,55 @@ +using System; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace VRM +{ + public struct Validation + { + /// <summary> + /// エクスポート可能か否か。 + /// true のメッセージは警告 + /// false のメッセージはエラー + /// </summary> + public readonly bool CanExport; + public readonly String Message; + + Validation(bool canExport, string message) + { + CanExport = canExport; + Message = message; + } + +#if UNITY_EDITOR + public void DrawGUI() + { + if (string.IsNullOrEmpty(Message)) + { + return; + } + + if (CanExport) + { + // warning + EditorGUILayout.HelpBox(Message, MessageType.Warning); + } + else + { + // error + EditorGUILayout.HelpBox(Message, MessageType.Error); + } + } +#endif + + public static Validation Error(string msg) + { + return new Validation(false, msg); + } + + public static Validation Warning(string msg) + { + return new Validation(true, msg); + } + } +}
\ No newline at end of file |