feat: expose per-component toggles to the NDMF plugin preview UI (#941)

This commit is contained in:
bd_ 2024-08-03 21:05:10 -07:00 committed by GitHub
parent 32dc864d8d
commit c50b3526f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 54 additions and 3 deletions

View File

@ -19,7 +19,7 @@
"dependencies": {}
},
"nadena.dev.ndmf": {
"version": "1.5.0-beta.0"
"version": "1.5.0-beta.2"
}
}
}

View File

@ -1,12 +1,14 @@
#region
using System;
using System.Collections.Generic;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core.ArmatureAwase;
using nadena.dev.modular_avatar.core.editor.plugin;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using nadena.dev.ndmf;
using nadena.dev.ndmf.fluent;
using nadena.dev.ndmf.preview;
using UnityEngine;
using Object = UnityEngine.Object;

View File

@ -9,6 +9,22 @@ namespace nadena.dev.modular_avatar.core.editor
{
internal class ObjectSwitcherPreview : IRenderFilter
{
static TogglablePreviewNode EnableNode = TogglablePreviewNode.Create(
() => "Object Switcher",
qualifiedName: "nadena.dev.modular-avatar/ObjectSwitcherPreview",
true
);
public IEnumerable<TogglablePreviewNode> GetPreviewControlNodes()
{
yield return EnableNode;
}
public bool IsEnabled(ComputeContext context)
{
return context.Observe(EnableNode.IsEnabled);
}
public ImmutableList<RenderGroup> GetTargetGroups(ComputeContext context)
{
var allToggles = context.GetComponentsByType<ModularAvatarObjectToggle>();

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using nadena.dev.modular_avatar.core.editor.plugin;
using nadena.dev.ndmf.preview;
using UnityEngine;
using Object = UnityEngine.Object;
@ -15,6 +16,22 @@ namespace nadena.dev.modular_avatar.core.editor
{
public class ShapeChangerPreview : IRenderFilter
{
private static TogglablePreviewNode EnableNode = TogglablePreviewNode.Create(
() => "Shape Changer",
qualifiedName: "nadena.dev.modular-avatar/ShapeChangerPreview",
true
);
public IEnumerable<TogglablePreviewNode> GetPreviewControlNodes()
{
yield return EnableNode;
}
public bool IsEnabled(ComputeContext context)
{
return context.Observe(EnableNode.IsEnabled);
}
public ImmutableList<RenderGroup> GetTargetGroups(ComputeContext ctx)
{
var allChangers = ctx.GetComponentsByType<ModularAvatarShapeChanger>();

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
using nadena.dev.modular_avatar.core.editor.plugin;
using nadena.dev.modular_avatar.core.editor.ScaleAdjuster;
using nadena.dev.ndmf.preview;
using UnityEditor;
@ -15,12 +16,27 @@ namespace nadena.dev.modular_avatar.core.editor
{
internal class ScaleAdjusterPreview : IRenderFilter
{
private static TogglablePreviewNode EnableNode = TogglablePreviewNode.Create(
() => "Scale Adjuster",
qualifiedName: "nadena.dev.modular-avatar/ScaleAdjusterPreview",
true
);
[InitializeOnLoadMethod]
private static void StaticInit()
{
}
public IEnumerable<TogglablePreviewNode> GetPreviewControlNodes()
{
yield return EnableNode;
}
public bool IsEnabled(ComputeContext context)
{
return context.Observe(EnableNode.IsEnabled);
}
private static GameObject FindAvatarRootObserving(ComputeContext ctx, GameObject ptr)
{
while (ptr != null)

View File

@ -16,6 +16,6 @@
},
"vpmDependencies": {
"com.vrchat.avatars": ">=3.4.0",
"nadena.dev.ndmf": ">=1.5.0-beta.0 <2.0.0-a"
"nadena.dev.ndmf": ">=1.5.0-beta.2 <2.0.0-a"
}
}