1
1
using System ;
2
2
using ReMod . Core . VRChat ;
3
3
using UnityEngine ;
4
+ using Object = System . Object ;
4
5
5
6
namespace ReMod . Core . UI . Wings
6
7
{
7
8
public class ReMirroredWingMenu
8
9
{
9
- private readonly ReWingMenu _leftMenu ;
10
- private readonly ReWingMenu _rightMenu ;
10
+ private ReWingMenu _leftMenu ;
11
+ private ReWingMenu _rightMenu ;
11
12
12
13
public bool Active
13
14
{
@@ -40,20 +41,44 @@ public static ReMirroredWingMenu Create(string text, string tooltip, Sprite spri
40
41
public ReMirroredWingButton AddButton ( string text , string tooltip , Action onClick , Sprite sprite = null , bool arrow = true , bool background = true ,
41
42
bool separator = false )
42
43
{
44
+ if ( _leftMenu == null || _rightMenu == null )
45
+ {
46
+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
47
+ }
48
+
43
49
return new ReMirroredWingButton ( text , tooltip , onClick , _leftMenu . Container , _rightMenu . Container , sprite , arrow , background , separator ) ;
44
50
}
45
51
46
52
public ReMirroredWingToggle AddToggle ( string text , string tooltip , Action < bool > onToggle , bool defaultValue )
47
53
{
54
+ if ( _leftMenu == null || _rightMenu == null )
55
+ {
56
+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
57
+ }
58
+
48
59
return new ReMirroredWingToggle ( text , tooltip , onToggle , _leftMenu . Container , _rightMenu . Container ,
49
60
defaultValue ) ;
50
61
}
51
62
52
63
public ReMirroredWingMenu AddSubMenu ( string text , string tooltip , Sprite sprite = null , bool arrow = true ,
53
64
bool background = true , bool separator = false )
54
65
{
66
+ if ( _leftMenu == null || _rightMenu == null )
67
+ {
68
+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
69
+ }
70
+
55
71
return new ReMirroredWingMenu ( text , tooltip , _leftMenu . Container , _rightMenu . Container , sprite , arrow ,
56
72
background , separator ) ;
57
73
}
74
+
75
+ public void Destroy ( )
76
+ {
77
+ UnityEngine . Object . Destroy ( _leftMenu . GameObject ) ;
78
+ UnityEngine . Object . Destroy ( _rightMenu . GameObject ) ;
79
+
80
+ _leftMenu = null ;
81
+ _rightMenu = null ;
82
+ }
58
83
}
59
84
}
0 commit comments