Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Added ability to destroy mirrored wing menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
RequiDev committed Jul 14, 2022
1 parent 8061110 commit 06d2c47
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions UI/Wings/ReMirroredWingMenu.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System;
using ReMod.Core.VRChat;
using UnityEngine;
using Object = System.Object;

namespace ReMod.Core.UI.Wings
{
public class ReMirroredWingMenu
{
private readonly ReWingMenu _leftMenu;
private readonly ReWingMenu _rightMenu;
private ReWingMenu _leftMenu;
private ReWingMenu _rightMenu;

public bool Active
{
Expand Down Expand Up @@ -40,20 +41,44 @@ public static ReMirroredWingMenu Create(string text, string tooltip, Sprite spri
public ReMirroredWingButton AddButton(string text, string tooltip, Action onClick, Sprite sprite = null, bool arrow = true, bool background = true,
bool separator = false)
{
if (_leftMenu == null || _rightMenu == null)
{
throw new NullReferenceException("This wing menu has been destroyed.");
}

return new ReMirroredWingButton(text, tooltip, onClick, _leftMenu.Container, _rightMenu.Container, sprite, arrow, background, separator);
}

public ReMirroredWingToggle AddToggle(string text, string tooltip, Action<bool> onToggle, bool defaultValue)
{
if (_leftMenu == null || _rightMenu == null)
{
throw new NullReferenceException("This wing menu has been destroyed.");
}

return new ReMirroredWingToggle(text, tooltip, onToggle, _leftMenu.Container, _rightMenu.Container,
defaultValue);
}

public ReMirroredWingMenu AddSubMenu(string text, string tooltip, Sprite sprite = null, bool arrow = true,
bool background = true, bool separator = false)
{
if (_leftMenu == null || _rightMenu == null)
{
throw new NullReferenceException("This wing menu has been destroyed.");
}

return new ReMirroredWingMenu(text, tooltip, _leftMenu.Container, _rightMenu.Container, sprite, arrow,
background, separator);
}

public void Destroy()
{
UnityEngine.Object.Destroy(_leftMenu.GameObject);
UnityEngine.Object.Destroy(_rightMenu.GameObject);

_leftMenu = null;
_rightMenu = null;
}
}
}

0 comments on commit 06d2c47

Please sign in to comment.