mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-24 13:29:01 +08:00
fix: animation clips are not added to the persistent asset object on build
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
274f88ee41
@ -9,6 +9,7 @@ using nadena.dev.ndmf;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Animations;
|
using UnityEditor.Animations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Profiling;
|
||||||
using BuildContext = nadena.dev.ndmf.BuildContext;
|
using BuildContext = nadena.dev.ndmf.BuildContext;
|
||||||
#if MA_VRCSDK3_AVATARS
|
#if MA_VRCSDK3_AVATARS
|
||||||
using VRC.SDK3.Avatars.Components;
|
using VRC.SDK3.Avatars.Components;
|
||||||
@ -192,7 +193,11 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
var clipHolder = RegisterMotion(state.motion, state, processClip, _originalToHolder);
|
var clipHolder = RegisterMotion(state.motion, state, processClip, _originalToHolder);
|
||||||
state.motion = clipHolder.CurrentClip;
|
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)
|
internal void ForeachClip(Action<ClipHolder> processClip)
|
||||||
@ -368,6 +373,8 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
children[i].motion = curClip;
|
children[i].motion = curClip;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaybeSaveClip(curClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirty)
|
if (dirty)
|
||||||
@ -379,5 +386,23 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
|
|
||||||
return treeHolder;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -94,6 +94,11 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
ObjectRegistry.RegisterReplacedObject(original, obj);
|
ObjectRegistry.RegisterReplacedObject(original, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_isSaved && !EditorUtility.IsPersistent(obj))
|
||||||
|
{
|
||||||
|
AssetDatabase.AddObjectToAsset(obj, _combined);
|
||||||
|
}
|
||||||
|
|
||||||
return (T)obj;
|
return (T)obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user