mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-30 10:12:59 +08:00
wip
This commit is contained in:
parent
1ab38e4ba1
commit
3211c15417
@ -2,10 +2,12 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using nadena.dev.modular_avatar.core.menu;
|
||||
using nadena.dev.ndmf;
|
||||
using nadena.dev.ndmf.preview;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.Components;
|
||||
@ -21,6 +23,32 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
protected override string localizationPrefix => "submenu_source";
|
||||
}
|
||||
|
||||
internal static class ParameterIntrospectionCache
|
||||
{
|
||||
internal static PropCache<GameObject, ImmutableList<ProvidedParameter>> ProvidedParameterCache = new (GetParametersForObject_miss);
|
||||
internal static PropCache<GameObject, ImmutableDictionary<(ParameterNamespace, string), ParameterMapping>> ParameterRemappingCache = new (GetRemappingsForAvatar);
|
||||
|
||||
private static ImmutableList<ProvidedParameter> GetParametersForObject_miss(ComputeContext ctx, GameObject avatar)
|
||||
{
|
||||
return ParameterInfo.ForPreview(ctx).GetParametersForObject(avatar).ToImmutableList();
|
||||
}
|
||||
|
||||
private static ImmutableDictionary<(ParameterNamespace, string), ParameterMapping> GetParameterRemappingsAt_miss(ComputeContext ctx, GameObject avatar)
|
||||
{
|
||||
return ParameterInfo.ForPreview(ctx).GetParameterRemappingsAt(avatar);
|
||||
}
|
||||
|
||||
internal static ImmutableList<ProvidedParameter> GetParametersForObject(GameObject avatar)
|
||||
{
|
||||
return ProvidedParameterCache.Get(ComputeContext.NullContext, avatar);
|
||||
}
|
||||
|
||||
internal static ImmutableDictionary<(ParameterNamespace, string), ParameterMapping> GetParameterRemappingsAt(GameObject avatar)
|
||||
{
|
||||
return ParameterRemappingCache.Get(ComputeContext.NullContext, avatar);
|
||||
}
|
||||
}
|
||||
|
||||
internal class MenuItemCoreGUI
|
||||
{
|
||||
private static readonly ObjectIDGenerator IdGenerator = new ObjectIDGenerator();
|
||||
@ -134,12 +162,12 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
|
||||
Dictionary<string, ProvidedParameter> rootParameters = new();
|
||||
|
||||
foreach (var param in ParameterInfo.ForUI.GetParametersForObject(parentAvatar.gameObject)
|
||||
foreach (var param in ParameterIntrospectionCache.GetParametersForObject(parentAvatar.gameObject)
|
||||
.Where(p => p.Namespace == ParameterNamespace.Animator)
|
||||
)
|
||||
rootParameters[param.EffectiveName] = param;
|
||||
|
||||
var remaps = ParameterInfo.ForUI.GetParameterRemappingsAt(paramRef);
|
||||
var remaps = ParameterIntrospectionCache.GetParameterRemappingsAt(paramRef);
|
||||
foreach (var remap in remaps)
|
||||
{
|
||||
if (remap.Key.Item1 != ParameterNamespace.Animator) continue;
|
||||
@ -613,7 +641,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
var myParameterName = myMenuItem.Control.parameter.name;
|
||||
if (string.IsNullOrEmpty(myParameterName)) return new List<ModularAvatarMenuItem>();
|
||||
|
||||
var myMappings = ParameterInfo.ForUI.GetParameterRemappingsAt(myMenuItem.gameObject);
|
||||
var myMappings = ParameterIntrospectionCache.GetParameterRemappingsAt(myMenuItem.gameObject);
|
||||
if (myMappings.TryGetValue((ParameterNamespace.Animator, myParameterName), out var myReplacement))
|
||||
myParameterName = myReplacement.ParameterName;
|
||||
|
||||
@ -627,7 +655,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
var otherParameterName = otherMenuItem.Control.parameter.name;
|
||||
if (string.IsNullOrEmpty(otherParameterName)) continue;
|
||||
|
||||
var otherMappings = ParameterInfo.ForUI.GetParameterRemappingsAt(otherMenuItem.gameObject);
|
||||
var otherMappings = ParameterIntrospectionCache.GetParameterRemappingsAt(otherMenuItem.gameObject);
|
||||
if (otherMappings.TryGetValue((ParameterNamespace.Animator, otherParameterName),
|
||||
out var otherReplacement))
|
||||
otherParameterName = otherReplacement.ParameterName;
|
||||
|
Loading…
Reference in New Issue
Block a user