11using System ;
22using ReMod . Core . VRChat ;
33using UnityEngine ;
4+ using Object = System . Object ;
45
56namespace ReMod . Core . UI . Wings
67{
78 public class ReMirroredWingMenu
89 {
9- private readonly ReWingMenu _leftMenu ;
10- private readonly ReWingMenu _rightMenu ;
10+ private ReWingMenu _leftMenu ;
11+ private ReWingMenu _rightMenu ;
1112
1213 public bool Active
1314 {
@@ -40,20 +41,44 @@ public static ReMirroredWingMenu Create(string text, string tooltip, Sprite spri
4041 public ReMirroredWingButton AddButton ( string text , string tooltip , Action onClick , Sprite sprite = null , bool arrow = true , bool background = true ,
4142 bool separator = false )
4243 {
44+ if ( _leftMenu == null || _rightMenu == null )
45+ {
46+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
47+ }
48+
4349 return new ReMirroredWingButton ( text , tooltip , onClick , _leftMenu . Container , _rightMenu . Container , sprite , arrow , background , separator ) ;
4450 }
4551
4652 public ReMirroredWingToggle AddToggle ( string text , string tooltip , Action < bool > onToggle , bool defaultValue )
4753 {
54+ if ( _leftMenu == null || _rightMenu == null )
55+ {
56+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
57+ }
58+
4859 return new ReMirroredWingToggle ( text , tooltip , onToggle , _leftMenu . Container , _rightMenu . Container ,
4960 defaultValue ) ;
5061 }
5162
5263 public ReMirroredWingMenu AddSubMenu ( string text , string tooltip , Sprite sprite = null , bool arrow = true ,
5364 bool background = true , bool separator = false )
5465 {
66+ if ( _leftMenu == null || _rightMenu == null )
67+ {
68+ throw new NullReferenceException ( "This wing menu has been destroyed." ) ;
69+ }
70+
5571 return new ReMirroredWingMenu ( text , tooltip , _leftMenu . Container , _rightMenu . Container , sprite , arrow ,
5672 background , separator ) ;
5773 }
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+ }
5883 }
5984}
0 commit comments