mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-04-30 08:19:01 +08:00
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using nadena.dev.modular_avatar.core.menu;
|
|||
|
using UnityEngine;
|
|||
|
using VRC.SDK3.Avatars.ScriptableObjects;
|
|||
|
|
|||
|
namespace nadena.dev.modular_avatar.core
|
|||
|
{
|
|||
|
public enum SubmenuSource
|
|||
|
{
|
|||
|
MenuAsset,
|
|||
|
Children,
|
|||
|
}
|
|||
|
|
|||
|
[AddComponentMenu("Modular Avatar/MA Menu Item")]
|
|||
|
public class ModularAvatarMenuItem : MenuSourceComponent
|
|||
|
{
|
|||
|
public VRCExpressionsMenu.Control Control;
|
|||
|
public SubmenuSource MenuSource;
|
|||
|
|
|||
|
public GameObject menuSource_otherObjectChildren;
|
|||
|
|
|||
|
public override void Visit(NodeContext context)
|
|||
|
{
|
|||
|
var cloned = new VirtualControl(Control);
|
|||
|
cloned.subMenu = null;
|
|||
|
cloned.name = gameObject.name;
|
|||
|
|
|||
|
if (cloned.type == VRCExpressionsMenu.Control.ControlType.SubMenu)
|
|||
|
{
|
|||
|
switch (this.MenuSource)
|
|||
|
{
|
|||
|
case SubmenuSource.MenuAsset:
|
|||
|
cloned.SubmenuNode = context.NodeFor(this.Control.subMenu);
|
|||
|
break;
|
|||
|
case SubmenuSource.Children:
|
|||
|
{
|
|||
|
var root = this.menuSource_otherObjectChildren != null
|
|||
|
? this.menuSource_otherObjectChildren
|
|||
|
: this.gameObject;
|
|||
|
|
|||
|
cloned.SubmenuNode = context.NodeFor(new MenuNodesUnder(root));
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
context.PushControl(cloned);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|