2023-08-22 17:44:02 +08:00
|
|
|
|
using nadena.dev.modular_avatar.core.menu;
|
2023-02-25 15:45:24 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using VRC.SDK3.Avatars.ScriptableObjects;
|
|
|
|
|
|
|
|
|
|
namespace nadena.dev.modular_avatar.core
|
|
|
|
|
{
|
|
|
|
|
public enum SubmenuSource
|
|
|
|
|
{
|
|
|
|
|
MenuAsset,
|
|
|
|
|
Children,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[AddComponentMenu("Modular Avatar/MA Menu Item")]
|
2023-05-14 19:24:43 +08:00
|
|
|
|
public class ModularAvatarMenuItem : AvatarTagComponent, MenuSource
|
2023-02-25 15:45:24 +08:00
|
|
|
|
{
|
|
|
|
|
public VRCExpressionsMenu.Control Control;
|
|
|
|
|
public SubmenuSource MenuSource;
|
|
|
|
|
|
|
|
|
|
public GameObject menuSource_otherObjectChildren;
|
|
|
|
|
|
2023-04-15 17:11:30 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// If no control group is set (and an action is linked), this controls whether this control is synced.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool isSynced = true;
|
|
|
|
|
|
|
|
|
|
public bool isSaved = true;
|
|
|
|
|
|
2023-04-04 18:33:19 +08:00
|
|
|
|
protected override void OnValidate()
|
|
|
|
|
{
|
|
|
|
|
base.OnValidate();
|
|
|
|
|
|
2023-04-15 17:11:30 +08:00
|
|
|
|
RuntimeUtil.InvalidateMenu();
|
|
|
|
|
|
2023-04-04 18:33:19 +08:00
|
|
|
|
if (Control == null)
|
|
|
|
|
{
|
|
|
|
|
Control = new VRCExpressionsMenu.Control();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-24 13:44:07 +08:00
|
|
|
|
public override void ResolveReferences()
|
2023-08-05 14:47:03 +08:00
|
|
|
|
{
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-15 17:11:30 +08:00
|
|
|
|
public void Visit(NodeContext context)
|
2023-02-25 15:45:24 +08:00
|
|
|
|
{
|
2023-04-04 18:33:19 +08:00
|
|
|
|
if (Control == null)
|
|
|
|
|
{
|
|
|
|
|
Control = new VRCExpressionsMenu.Control();
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-25 15:45:24 +08:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|