Initial Commit
This commit is contained in:
commit
13767d3f40
160 changed files with 51070 additions and 0 deletions
80
MenuIconRemover/Editor/MenuIconRemoverPlugin.cs
Normal file
80
MenuIconRemover/Editor/MenuIconRemoverPlugin.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
using System.Collections.Generic;
|
||||
using gay.lilyy.MenuIconRemover;
|
||||
using nadena.dev.ndmf;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDK3.Avatars.ScriptableObjects;
|
||||
using static VRC.SDK3.Avatars.ScriptableObjects.VRCExpressionsMenu;
|
||||
|
||||
[assembly: ExportsPlugin(typeof(MenuIconRemoverPlugin))]
|
||||
|
||||
namespace gay.lilyy.MenuIconRemover
|
||||
{
|
||||
public class MenuIconRemoverPlugin : Plugin<MenuIconRemoverPlugin>
|
||||
{
|
||||
public override string DisplayName => "MenuIconRemover";
|
||||
public override string QualifiedName => "gay.lilyy.MenuIconRemover";
|
||||
|
||||
protected override void Configure()
|
||||
{
|
||||
InPhase(BuildPhase.Optimizing).BeforePlugin("gay.lilyy.MenuStyling").Run("RemoveMenuIcons", ctx =>
|
||||
{
|
||||
var obj = ctx.AvatarRootObject.GetComponent<MenuIconRemoverConfig>();
|
||||
if (obj != null)
|
||||
{
|
||||
var shouldRemove = false;
|
||||
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
|
||||
{
|
||||
shouldRemove = obj.removeOnQuest;
|
||||
}
|
||||
else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows ||
|
||||
EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64)
|
||||
{
|
||||
shouldRemove = obj.removeOnPc;
|
||||
}
|
||||
if (shouldRemove)
|
||||
{
|
||||
ctx.AvatarDescriptor.expressionsMenu = DuplicateMenu(obj, ctx.AvatarDescriptor.expressionsMenu);
|
||||
Object.DestroyImmediate(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private VRCExpressionsMenu DuplicateMenu(MenuIconRemoverConfig 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 shouldEdit = true;
|
||||
foreach (var exclude in cfg.exclude)
|
||||
{
|
||||
if (control.name == exclude)
|
||||
{
|
||||
shouldEdit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var newControl = new Control
|
||||
{
|
||||
name = control.name,
|
||||
type = control.type,
|
||||
icon = shouldEdit ? null : control.icon,
|
||||
parameter = control.parameter,
|
||||
subMenu = shouldEdit ? DuplicateMenu(cfg, control.subMenu) : 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