mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-05-14 07:09:09 +08:00
fixing issues with error reporting and dependent component cleanup
This commit is contained in:
parent
eaf01d8c31
commit
6ba3f95177
@ -23,8 +23,10 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
||||
@ -144,6 +146,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
var vrcAvatarDescriptor = avatarGameObject.GetComponent<VRCAvatarDescriptor>();
|
||||
|
||||
using (BuildReport.CurrentReport.ReportingOnAvatar(vrcAvatarDescriptor))
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -201,9 +205,38 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
// Ensure that we clean up AvatarTagComponents after failed processing. This ensures we don't re-enter
|
||||
// processing from the Awake method on the unprocessed AvatarTagComponents
|
||||
foreach (var component in avatarGameObject.GetComponentsInChildren<AvatarTagComponent>(true))
|
||||
var toDestroy = avatarGameObject.GetComponentsInChildren<AvatarTagComponent>(true).ToList();
|
||||
var retryDestroy = new List<AvatarTagComponent>();
|
||||
|
||||
// Sometimes AvatarTagComponents have interdependencies and need to be deleted in the right order;
|
||||
// retry until we purge them all.
|
||||
bool madeProgress = true;
|
||||
while (toDestroy.Count > 0)
|
||||
{
|
||||
if (!madeProgress)
|
||||
{
|
||||
throw new Exception("One or more components failed to destroy." +
|
||||
RuntimeUtil.AvatarRootPath(toDestroy[0].gameObject));
|
||||
}
|
||||
|
||||
foreach (var component in toDestroy)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (component != null)
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(component);
|
||||
madeProgress = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
retryDestroy.Add(component);
|
||||
}
|
||||
}
|
||||
|
||||
toDestroy = retryDestroy;
|
||||
retryDestroy = new List<AvatarTagComponent>();
|
||||
}
|
||||
|
||||
var activator = avatarGameObject.GetComponent<AvatarActivator>();
|
||||
@ -221,6 +254,17 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
Resources.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BuildReport.LogException(e);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (!BuildReport.CurrentReport.CurrentAvatar.successful)
|
||||
{
|
||||
throw new Exception("Fatal error reported during avatar processing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearEditorOnlyTagComponents(Transform obj)
|
||||
|
Loading…
x
Reference in New Issue
Block a user