diff --git a/Assets/UniGLTF/MeshUtility/Runtime/Validation.cs b/Assets/UniGLTF/MeshUtility/Runtime/Validation.cs index 71bb4ad5fa..82aee82aa5 100644 --- a/Assets/UniGLTF/MeshUtility/Runtime/Validation.cs +++ b/Assets/UniGLTF/MeshUtility/Runtime/Validation.cs @@ -46,10 +46,11 @@ public bool CanExport 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 @@ public void DrawGUI() default: throw new NotImplementedException(); } + + if (Extended != null) + { + Extended(); + } } + + public Action Extended; #endif public static Validation Critical(string msg) @@ -84,9 +92,9 @@ public static Validation Critical(string msg) 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) diff --git a/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs index 0436fc1125..53de7e2e6d 100644 --- a/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs +++ b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonEditor.cs @@ -72,16 +72,6 @@ public override void OnInspectorGUI() v.DrawGUI(); isValid = false; } - if (!isValid) - { - if (GUILayout.Button("reset renderers")) - { - m_target.TraverseRenderers(); - } - GUILayout.Space(10); - Separator(); - GUILayout.Space(10); - } base.OnInspectorGUI(); } diff --git a/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs index 9d5d422f32..e083c2137b 100644 --- a/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs +++ b/Assets/VRM/Editor/FirstPerson/VRMFirstPersonValidator.cs @@ -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 @@ public static IEnumerable Validate(this VRMFirstPerson self, GameObj { Hierarchy = self.GetComponentsInChildren(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)) diff --git a/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs index 050e4b1911..42c9953053 100644 --- a/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs +++ b/Assets/VRM/Runtime/FirstPerson/VRMFirstPerson.cs @@ -76,7 +76,7 @@ public void SetDefault() } } - private void Reset() + public void Reset() { SetDefault(); TraverseRenderers();