Skip to content

Commit

Permalink
Merge pull request #889 from ousttrue/feature/mv_validation
Browse files Browse the repository at this point in the history
Feature/mv validation
  • Loading branch information
PoChang007 authored Apr 20, 2021
2 parents e72bce9 + b790a9a commit 737359b
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 53 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UniGLTF.M17N;
using UnityEngine;

namespace VRM
namespace UniGLTF
{
public static class HumanoidValidator
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/UniGLTF/Editor/UniGLTF/Validation/ValidationExtensions.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/UniGLTF/Runtime/UniGLTF/Validation.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -46,49 +52,18 @@ public bool CanExport

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);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using MeshUtility;
using UniGLTF;
using UnityEditor;
using UnityEngine;

Expand Down

0 comments on commit 737359b

Please sign in to comment.