mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
perf: switch to AssetSaver API (#1372)
This commit is contained in:
parent
4a65b9f2ac
commit
f3bf07b601
4
.github/ProjectRoot/vpm-manifest-2022.json
vendored
4
.github/ProjectRoot/vpm-manifest-2022.json
vendored
@ -4,7 +4,7 @@
|
|||||||
"version": "3.7.0"
|
"version": "3.7.0"
|
||||||
},
|
},
|
||||||
"nadena.dev.ndmf": {
|
"nadena.dev.ndmf": {
|
||||||
"version": "1.5.6"
|
"version": "1.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -19,7 +19,7 @@
|
|||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
"nadena.dev.ndmf": {
|
"nadena.dev.ndmf": {
|
||||||
"version": "1.5.6"
|
"version": "1.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -416,7 +416,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(curClip, _context.AssetContainer);
|
_context.AssetSaver.SaveAsset(curClip);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +78,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
_combined = new AnimatorController();
|
_combined = new AnimatorController();
|
||||||
if (context.AssetContainer != null && EditorUtility.IsPersistent(context.AssetContainer))
|
if (context.AssetContainer != null && EditorUtility.IsPersistent(context.AssetContainer))
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(_combined, context.AssetContainer);
|
context.AssetSaver.SaveAsset(_combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
_combined.name = assetName;
|
_combined.name = assetName;
|
||||||
@ -191,7 +191,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
EditorUtility.CopySerialized(t, newTransition);
|
EditorUtility.CopySerialized(t, newTransition);
|
||||||
if (_context.AssetContainer != null)
|
if (_context.AssetContainer != null)
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(newTransition, _context.AssetContainer);
|
_context.AssetSaver.SaveAsset(newTransition);
|
||||||
}
|
}
|
||||||
t = newTransition;
|
t = newTransition;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
|
|
||||||
internal class DeepClone
|
internal class DeepClone
|
||||||
{
|
{
|
||||||
|
private BuildContext _context;
|
||||||
private bool _isSaved;
|
private bool _isSaved;
|
||||||
private UnityObject _combined;
|
private UnityObject _combined;
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
|
|
||||||
public DeepClone(BuildContext context)
|
public DeepClone(BuildContext context)
|
||||||
{
|
{
|
||||||
|
_context = context;
|
||||||
_isSaved = context.AssetContainer != null && EditorUtility.IsPersistent(context.AssetContainer);
|
_isSaved = context.AssetContainer != null && EditorUtility.IsPersistent(context.AssetContainer);
|
||||||
_combined = context.AssetContainer;
|
_combined = context.AssetContainer;
|
||||||
}
|
}
|
||||||
@ -33,6 +35,8 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
if (original == null) return null;
|
if (original == null) return null;
|
||||||
if (cloneMap == null) cloneMap = new Dictionary<UnityObject, UnityObject>();
|
if (cloneMap == null) cloneMap = new Dictionary<UnityObject, UnityObject>();
|
||||||
|
|
||||||
|
using var scope = _context.OpenSerializationScope();
|
||||||
|
|
||||||
Func<UnityObject, UnityObject> visitor = null;
|
Func<UnityObject, UnityObject> visitor = null;
|
||||||
if (basePath != null)
|
if (basePath != null)
|
||||||
{
|
{
|
||||||
@ -96,14 +100,12 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
|
|
||||||
if (_isSaved && !EditorUtility.IsPersistent(obj))
|
if (_isSaved && !EditorUtility.IsPersistent(obj))
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(obj, _combined);
|
scope.SaveAsset(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (T)obj;
|
return (T)obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var ctor = original.GetType().GetConstructor(Type.EmptyTypes);
|
var ctor = original.GetType().GetConstructor(Type.EmptyTypes);
|
||||||
if (ctor == null || original is ScriptableObject)
|
if (ctor == null || original is ScriptableObject)
|
||||||
{
|
{
|
||||||
@ -120,7 +122,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
|
|
||||||
if (_isSaved)
|
if (_isSaved)
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(obj, _combined);
|
scope.SaveAsset(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializedObject so = new SerializedObject(obj);
|
SerializedObject so = new SerializedObject(obj);
|
||||||
@ -233,7 +235,7 @@ namespace nadena.dev.modular_avatar.animation
|
|||||||
newClip.name = "rebased " + clip.name;
|
newClip.name = "rebased " + clip.name;
|
||||||
if (_isSaved)
|
if (_isSaved)
|
||||||
{
|
{
|
||||||
AssetDatabase.AddObjectToAsset(newClip, _combined);
|
_context.AssetSaver.SaveAsset(newClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var binding in AnimationUtility.GetCurveBindings(clip))
|
foreach (var binding in AnimationUtility.GetCurveBindings(clip))
|
||||||
|
@ -71,7 +71,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
{
|
{
|
||||||
if (!SaveImmediate || AssetDatabase.IsMainAsset(obj) || AssetDatabase.IsSubAsset(obj)) return;
|
if (!SaveImmediate || AssetDatabase.IsMainAsset(obj) || AssetDatabase.IsSubAsset(obj)) return;
|
||||||
|
|
||||||
AssetDatabase.AddObjectToAsset(obj, AssetContainer);
|
PluginBuildContext.AssetSaver.SaveAsset(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimatorController CreateAnimator(AnimatorController toClone = null)
|
public AnimatorController CreateAnimator(AnimatorController toClone = null)
|
||||||
|
@ -63,7 +63,7 @@ namespace _ModularAvatar.EditModeTests.SerializationTests
|
|||||||
Assert.False(string.IsNullOrEmpty(path));
|
Assert.False(string.IsNullOrEmpty(path));
|
||||||
|
|
||||||
var mainAsset = AssetDatabase.LoadMainAssetAtPath(path);
|
var mainAsset = AssetDatabase.LoadMainAssetAtPath(path);
|
||||||
Assert.IsInstanceOf<GeneratedAssets>(mainAsset);
|
Assert.IsTrue(mainAsset is GeneratedAssets or SubAssetContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,6 @@
|
|||||||
},
|
},
|
||||||
"vpmDependencies": {
|
"vpmDependencies": {
|
||||||
"com.vrchat.avatars": ">=3.7.0",
|
"com.vrchat.avatars": ">=3.7.0",
|
||||||
"nadena.dev.ndmf": ">=1.5.6 <2.0.0-a"
|
"nadena.dev.ndmf": ">=1.6.0 <2.0.0-a"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user