Validation, Validator を移動

This commit is contained in:
ousttrue 2021-04-20 12:50:42 +09:00
parent e72bce9c46
commit ca8eac3ec2
11 changed files with 83 additions and 50 deletions

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1c450c4a7f888424490abbbc29c10a1a
guid: bf36255fd0ad75e43805c130738d0e38
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,38 @@
using System;
using UnityEditor;
namespace UniGLTF
{
public static class ValidationExtensions
{
public static void DrawGUI(this Validation self)
{
if (string.IsNullOrEmpty(self.Message))
{
return;
}
switch (self.ErrorLevel)
{
case ErrorLevels.Info:
EditorGUILayout.HelpBox(self.Message, MessageType.Info);
break;
case ErrorLevels.Warning:
EditorGUILayout.HelpBox(self.Message, MessageType.Warning);
break;
case ErrorLevels.Critical:
case ErrorLevels.Error:
EditorGUILayout.HelpBox(self.Message, MessageType.Error);
break;
default:
throw new NotImplementedException();
}
if (self.Extended != null)
{
self.Extended();
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c3545b8a3783c8940a8fa5effa140e7a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dec9ec06b97c9e8429237751c9ce3002
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,32 +1,38 @@
using System;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UniGLTF
{
public enum ErrorLevels
{
// Exportできる。お知らせ
/// <summary>
/// Exportできる。お知らせ
/// </summary>
Info,
// Exportできる。不具合の可能性
/// <summary>
/// Exportできる。不具合の可能性
/// </summary>
Warning,
// Exportするために修正が必用
/// <summary>
/// Exportするために修正が必用
/// </summary>
Error,
// Exportの前提を満たさない
/// <summary>
/// Exportの前提を満たさない
/// </summary>
Critical,
}
public struct Validation
{
/// <summary>
/// エクスポート可能か否か。
/// true のメッセージは警告
/// false のメッセージはエラー
/// </summary>
public readonly ErrorLevels ErrorLevel;
/// <summary>
/// エクスポート可能か否か
/// </summary>
public bool CanExport
{
get
@ -46,49 +52,18 @@ namespace UniGLTF
public readonly String Message;
/// <summary>
/// DrawGUIから呼び出す。追加のGUIボタンなどを実装する
/// </summary>
public Action Extended;
Validation(ErrorLevels canExport, string message, Action extended = null)
{
ErrorLevel = canExport;
Message = message;
#if UNITY_EDITOR
Extended = extended;
#endif
}
#if UNITY_EDITOR
public void DrawGUI()
{
if (string.IsNullOrEmpty(Message))
{
return;
}
switch (ErrorLevel)
{
case ErrorLevels.Info:
EditorGUILayout.HelpBox(Message, MessageType.Info);
break;
case ErrorLevels.Warning:
EditorGUILayout.HelpBox(Message, MessageType.Warning);
break;
case ErrorLevels.Critical:
case ErrorLevels.Error:
EditorGUILayout.HelpBox(Message, MessageType.Error);
break;
default:
throw new NotImplementedException();
}
if (Extended != null)
{
Extended();
}
}
public Action Extended;
#endif
public static Validation Critical(string msg)
{
return new Validation(ErrorLevels.Critical, msg);

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 221b6a77b68c6364a9f1387cf1ede576
guid: b145055d294286a4bb7247265967b735
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,5 +1,6 @@
using System.Linq;
using MeshUtility;
using UniGLTF;
using UnityEditor;
using UnityEngine;