mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +08:00
fix: null/missing expressions params/menus breaking builds (#441)
This commit is contained in:
parent
cda95408d5
commit
7ed0179b91
@ -6,17 +6,40 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using VRC.SDK3.Avatars.ScriptableObjects;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace nadena.dev.modular_avatar.core.editor
|
||||
{
|
||||
internal class FixupExpressionsMenuPass
|
||||
{
|
||||
private const string DEFAULT_EXP_MENU_GUID = "024fb8ef5b3988c46b446863c92f4522";
|
||||
private const string DEFAULT_EXP_PARAM_GUID = "03a6d797deb62f0429471c4e17ea99a7";
|
||||
|
||||
internal static void FixupExpressionsMenu(BuildContext context)
|
||||
{
|
||||
var expressionsMenu = context.AvatarDescriptor.expressionsMenu;
|
||||
if (expressionsMenu == null) return;
|
||||
context.AvatarDescriptor.customExpressions = true;
|
||||
|
||||
var parameters = context.AvatarDescriptor.expressionParameters?.parameters
|
||||
var expressionsMenu = context.AvatarDescriptor.expressionsMenu;
|
||||
if (expressionsMenu == null)
|
||||
{
|
||||
var defaultExpMenu = AssetDatabase.LoadAssetAtPath<VRCExpressionsMenu>(
|
||||
AssetDatabase.GUIDToAssetPath(DEFAULT_EXP_MENU_GUID)
|
||||
);
|
||||
|
||||
expressionsMenu = Object.Instantiate(defaultExpMenu);
|
||||
context.AvatarDescriptor.expressionsMenu = expressionsMenu;
|
||||
}
|
||||
|
||||
if (context.AvatarDescriptor.expressionParameters == null)
|
||||
{
|
||||
var defaultExpParam = AssetDatabase.LoadAssetAtPath<VRCExpressionParameters>(
|
||||
AssetDatabase.GUIDToAssetPath(DEFAULT_EXP_PARAM_GUID)
|
||||
);
|
||||
|
||||
context.AvatarDescriptor.expressionParameters = Object.Instantiate(defaultExpParam);
|
||||
}
|
||||
|
||||
var parameters = context.AvatarDescriptor.expressionParameters.parameters
|
||||
?? new VRCExpressionParameters.Parameter[0];
|
||||
var parameterNames = parameters.Select(p=> p.name).ToImmutableHashSet();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user