mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2024-12-29 18:55:06 +08:00
chore: use binary serialization for generated assets
Thanks to @anatawa12 for the suggestion
This commit is contained in:
parent
806841481c
commit
dec90cb6ca
@ -24,6 +24,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@ -31,11 +32,11 @@ using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using nadena.dev.modular_avatar.editor.ErrorReporting;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
using BuildReport = nadena.dev.modular_avatar.editor.ErrorReporting.BuildReport;
|
||||
using Debug = UnityEngine.Debug;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
[assembly: InternalsVisibleTo("Tests")]
|
||||
@ -158,6 +159,9 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
var vrcAvatarDescriptor = avatarGameObject.GetComponent<VRCAvatarDescriptor>();
|
||||
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
using (BuildReport.CurrentReport.ReportingOnAvatar(vrcAvatarDescriptor))
|
||||
{
|
||||
try
|
||||
@ -283,6 +287,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
throw new Exception("Fatal error reported during avatar processing.");
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"Processed avatar " + avatarGameObject.name + " in " + sw.ElapsedMilliseconds + "ms");
|
||||
}
|
||||
|
||||
private static void ClearEditorOnlyTagComponents(Transform obj)
|
||||
|
@ -14,7 +14,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
{
|
||||
internal readonly VRCAvatarDescriptor AvatarDescriptor;
|
||||
internal readonly AnimationDatabase AnimationDatabase = new AnimationDatabase();
|
||||
internal readonly AnimatorController AssetContainer;
|
||||
internal readonly UnityEngine.Object AssetContainer;
|
||||
|
||||
internal readonly Dictionary<VRCExpressionsMenu, VRCExpressionsMenu> ClonedMenus
|
||||
= new Dictionary<VRCExpressionsMenu, VRCExpressionsMenu>();
|
||||
@ -32,9 +32,10 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
AvatarDescriptor = avatarDescriptor;
|
||||
|
||||
// AssetDatabase.CreateAsset is super slow - so only do it once, and add everything else as sub-assets.
|
||||
// This animator controller exists for the sole purpose of providing a placeholder to dump everything we
|
||||
// generate into.
|
||||
AssetContainer = new AnimatorController();
|
||||
// This scriptable object exists for the sole purpose of providing a placeholder to dump everything we
|
||||
// generate into. Note that we use a custom component here to force binary serialization; this saves both
|
||||
// time as well as disk space (if you're using manual bake).
|
||||
AssetContainer = ScriptableObject.CreateInstance<MAAssetBundle>();
|
||||
AssetDatabase.CreateAsset(AssetContainer, Util.GenerateAssetPath());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace nadena.dev.modular_avatar.core
|
||||
{
|
||||
[PreferBinarySerialization]
|
||||
class MAAssetBundle : ScriptableObject
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e82ebb24aca47b7bc95ca94668015a6
|
||||
timeCreated: 1690643821
|
Loading…
Reference in New Issue
Block a user