Menu Icon Replacer
This commit is contained in:
parent
b774208e32
commit
2f770cf724
13 changed files with 301 additions and 0 deletions
66
MenuIconReplacer/Editor/MenuIconReplacerPlugin.cs
Normal file
66
MenuIconReplacer/Editor/MenuIconReplacerPlugin.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System.Collections.Generic;
|
||||
using gay.lilyy.MenuIconReplacer;
|
||||
using nadena.dev.ndmf;
|
||||
using NUnit.Framework.Constraints;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.ScriptableObjects;
|
||||
using static VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu;
|
||||
|
||||
[assembly: ExportsPlugin(typeof(MenuIconReplacerPlugin))]
|
||||
|
||||
namespace gay.lilyy.MenuIconReplacer
|
||||
{
|
||||
public class MenuIconReplacerPlugin : Plugin<MenuIconReplacerPlugin>
|
||||
{
|
||||
public override string DisplayName => "MenuIconReplacer";
|
||||
public override string QualifiedName => "gay.lilyy.MenuIconReplacer";
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
InPhase(BuildPhase.Optimizing).BeforePlugin("gay.lilyy.MenuIconRemover").Run("ReplaceMenuIcons", ctx =>
|
||||
{
|
||||
var obj = ctx.AvatarRootObject.GetComponent<MenuIconReplacerConfig>();
|
||||
if (obj != null)
|
||||
{
|
||||
ctx.AvatarDescriptor.expressionsMenu = RecurseMenu(obj, ctx.AvatarDescriptor.expressionsMenu);
|
||||
Object.DestroyImmediate(obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private VRCExpressionsMenu RecurseMenu(MenuIconReplacerConfig cfg, VRCExpressionsMenu menu)
|
||||
{
|
||||
if (menu == null) return null;
|
||||
|
||||
var newMenu = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
|
||||
newMenu.controls = new List<Control>();
|
||||
|
||||
foreach (var control in menu.controls)
|
||||
{
|
||||
var icon = control.icon;
|
||||
foreach (var entry in cfg.replacements)
|
||||
{
|
||||
if (entry.from == icon) {
|
||||
icon = entry.to;
|
||||
}
|
||||
}
|
||||
var newControl = new Control
|
||||
{
|
||||
name = control.name,
|
||||
type = control.type,
|
||||
icon = icon,
|
||||
parameter = control.parameter,
|
||||
subMenu = RecurseMenu(cfg, control.subMenu),
|
||||
value = control.value,
|
||||
style = control.style,
|
||||
labels = control.labels,
|
||||
subParameters = control.subParameters
|
||||
};
|
||||
newMenu.controls.Add(newControl);
|
||||
}
|
||||
|
||||
return newMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue