mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-03-09 23:34:56 +08:00
fix: animation clips are not added to the persistent asset object on build (#1182)
This resulted in data loss when `AssetDatabase.StopAssetEditing()` was called, which can happen if VRCF triggers Poi lockdown.
This commit is contained in:
parent
c11a76642c
commit
7bf5106246
@ -9,6 +9,7 @@ using nadena.dev.ndmf;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Profiling;
|
||||
using BuildContext = nadena.dev.ndmf.BuildContext;
|
||||
#if MA_VRCSDK3_AVATARS
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
@ -192,7 +193,11 @@ namespace nadena.dev.modular_avatar.animation
|
||||
var clipHolder = RegisterMotion(state.motion, state, processClip, _originalToHolder);
|
||||
state.motion = clipHolder.CurrentClip;
|
||||
|
||||
_clipCommitActions.Add(() => { state.motion = clipHolder.CurrentClip; });
|
||||
_clipCommitActions.Add(() =>
|
||||
{
|
||||
state.motion = clipHolder.CurrentClip;
|
||||
MaybeSaveClip(clipHolder.CurrentClip);
|
||||
});
|
||||
}
|
||||
|
||||
internal void ForeachClip(Action<ClipHolder> processClip)
|
||||
@ -368,6 +373,8 @@ namespace nadena.dev.modular_avatar.animation
|
||||
children[i].motion = curClip;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
MaybeSaveClip(curClip);
|
||||
}
|
||||
|
||||
if (dirty)
|
||||
@ -379,5 +386,23 @@ namespace nadena.dev.modular_avatar.animation
|
||||
|
||||
return treeHolder;
|
||||
}
|
||||
|
||||
private void MaybeSaveClip(Motion curClip)
|
||||
{
|
||||
Profiler.BeginSample("MaybeSaveClip");
|
||||
if (curClip != null && !EditorUtility.IsPersistent(curClip) && EditorUtility.IsPersistent(_context.AssetContainer) && _context.AssetContainer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
AssetDatabase.AddObjectToAsset(curClip, _context.AssetContainer);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
Profiler.EndSample();
|
||||
}
|
||||
}
|
||||
}
|
@ -93,6 +93,11 @@ namespace nadena.dev.modular_avatar.animation
|
||||
{
|
||||
ObjectRegistry.RegisterReplacedObject(original, obj);
|
||||
}
|
||||
|
||||
if (_isSaved && !EditorUtility.IsPersistent(obj))
|
||||
{
|
||||
AssetDatabase.AddObjectToAsset(obj, _combined);
|
||||
}
|
||||
|
||||
return (T)obj;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user