Initial Commit
This commit is contained in:
commit
13767d3f40
160 changed files with 51070 additions and 0 deletions
76
MenuStyling/Editor/MenuStylingPlugin.cs
Normal file
76
MenuStyling/Editor/MenuStylingPlugin.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System.Collections.Generic;
|
||||
using gay.lilyy.MenuStyling;
|
||||
using nadena.dev.ndmf;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.ScriptableObjects;
|
||||
using static VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu;
|
||||
|
||||
[assembly: ExportsPlugin(typeof(MenuStylingPlugin))]
|
||||
|
||||
namespace gay.lilyy.MenuStyling
|
||||
{
|
||||
public class MenuStylingPlugin : Plugin<MenuStylingPlugin>
|
||||
{
|
||||
public override string DisplayName => "MenuStyling";
|
||||
public override string QualifiedName => "gay.lilyy.MenuStyling";
|
||||
protected override void Configure()
|
||||
{
|
||||
InPhase(BuildPhase.Optimizing).AfterPlugin("gay.lilyy.MenuIconRemover").Run("SetMenuStyling", ctx =>
|
||||
{
|
||||
var obj = ctx.AvatarRootObject.GetComponent<MenuStylingConfig>();
|
||||
if (obj != null)
|
||||
{
|
||||
ctx.AvatarDescriptor.expressionsMenu = DuplicateMenu(ctx.AvatarDescriptor.expressionsMenu);
|
||||
WalkMenu(obj, ctx.AvatarDescriptor.expressionsMenu);
|
||||
Object.DestroyImmediate(obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private VRCExpressionsMenu DuplicateMenu(VRCExpressionsMenu menu)
|
||||
{
|
||||
if (menu == null) return null;
|
||||
|
||||
var newMenu = ScriptableObject.CreateInstance<VRCExpressionsMenu>();
|
||||
newMenu.controls = new List<Control>();
|
||||
|
||||
foreach (var control in menu.controls)
|
||||
{
|
||||
var newControl = new Control
|
||||
{
|
||||
name = control.name,
|
||||
type = control.type,
|
||||
icon = control.icon,
|
||||
parameter = control.parameter,
|
||||
subMenu = DuplicateMenu(control.subMenu),
|
||||
value = control.value,
|
||||
style = control.style,
|
||||
labels = control.labels,
|
||||
subParameters = control.subParameters
|
||||
};
|
||||
newMenu.controls.Add(newControl);
|
||||
}
|
||||
|
||||
return newMenu;
|
||||
}
|
||||
|
||||
private void WalkMenu(MenuStylingConfig config, VRCExpressionsMenu menu)
|
||||
{
|
||||
foreach (var child in menu.controls)
|
||||
{
|
||||
if (!child.name.StartsWith(config.Prefix))
|
||||
{
|
||||
child.name = config.Prefix + child.name;
|
||||
}
|
||||
if (!child.name.EndsWith(config.Suffix))
|
||||
{
|
||||
child.name += config.Suffix;
|
||||
}
|
||||
if (child.type == Control.ControlType.SubMenu && child.subMenu != null)
|
||||
{
|
||||
WalkMenu(config, child.subMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue