mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-27 21:34:38 -05:00
@@ -46,10 +46,11 @@ namespace MeshUtility
|
||||
|
||||
public readonly String Message;
|
||||
|
||||
Validation(ErrorLevels canExport, string message)
|
||||
Validation(ErrorLevels canExport, string message, Action extended = null)
|
||||
{
|
||||
ErrorLevel = canExport;
|
||||
Message = message;
|
||||
Extended = extended;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -76,7 +77,14 @@ namespace MeshUtility
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
if (Extended != null)
|
||||
{
|
||||
Extended();
|
||||
}
|
||||
}
|
||||
|
||||
public Action Extended;
|
||||
#endif
|
||||
|
||||
public static Validation Critical(string msg)
|
||||
@@ -84,9 +92,9 @@ namespace MeshUtility
|
||||
return new Validation(ErrorLevels.Critical, msg);
|
||||
}
|
||||
|
||||
public static Validation Error(string msg)
|
||||
public static Validation Error(string msg, Action action = null)
|
||||
{
|
||||
return new Validation(ErrorLevels.Error, msg);
|
||||
return new Validation(ErrorLevels.Error, msg, action);
|
||||
}
|
||||
|
||||
public static Validation Warning(string msg)
|
||||
|
||||
@@ -72,16 +72,6 @@ namespace VRM
|
||||
v.DrawGUI();
|
||||
isValid = false;
|
||||
}
|
||||
if (!isValid)
|
||||
{
|
||||
if (GUILayout.Button("reset renderers"))
|
||||
{
|
||||
m_target.TraverseRenderers();
|
||||
}
|
||||
GUILayout.Space(10);
|
||||
Separator();
|
||||
GUILayout.Space(10);
|
||||
}
|
||||
|
||||
base.OnInspectorGUI();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MeshUtility;
|
||||
@@ -8,24 +9,25 @@ namespace VRM
|
||||
public static class VRMFirstPersonValidator
|
||||
{
|
||||
public static Transform[] Hierarchy;
|
||||
static Action extended;
|
||||
|
||||
public static bool IsValid(this VRMFirstPerson.RendererFirstPersonFlags r, string name, out Validation validation)
|
||||
{
|
||||
if (r.Renderer == null)
|
||||
{
|
||||
validation = Validation.Error($"{name}.Renderer is null");
|
||||
validation = Validation.Error($"{name}.Renderer is null", extended);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Hierarchy.Contains(r.Renderer.transform))
|
||||
{
|
||||
validation = Validation.Error($"{name}.Renderer is out of hierarchy");
|
||||
validation = Validation.Error($"{name}.Renderer is out of hierarchy", extended);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!r.Renderer.EnableForExport())
|
||||
{
|
||||
validation = Validation.Error($"{name}.Renderer is not active");
|
||||
validation = Validation.Error($"{name}.Renderer is not active", extended);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -37,6 +39,14 @@ namespace VRM
|
||||
{
|
||||
Hierarchy = self.GetComponentsInChildren<Transform>(true);
|
||||
|
||||
extended = () =>
|
||||
{
|
||||
if (GUILayout.Button("reset VRMFirstPerson.Renderers"))
|
||||
{
|
||||
self.TraverseRenderers();
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < self.Renderers.Count; ++i)
|
||||
{
|
||||
if (!IsValid(self.Renderers[i], $"[VRMFirstPerson]{self.name}.Renderers[{i}]", out Validation v))
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace VRM
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
public void Reset()
|
||||
{
|
||||
SetDefault();
|
||||
TraverseRenderers();
|
||||
|
||||
Reference in New Issue
Block a user