@@ -59,16 +59,18 @@ public static class Alert
59
59
{
60
60
61
61
[ DllImport ( "__Internal" ) ]
62
- private static extern void IOSUIAlertController ( string title , string message ) ;
62
+ private static extern void IOSUIAlertController ( string title , string message , string okGameObjectName , string cancelGameObjectName ) ;
63
63
64
64
public static void IOSUIAlertController ( string title , string message , Action okCallback , Action cancelCallback )
65
65
{
66
66
67
- var okGameObject = new GameObject ( "IOSBridgeEvents - UIAlertController - OK" ) ;
67
+ var okGameObjectName = "IOSBridgeEvents - UIAlertController - OK" ;
68
+ var okGameObject = new GameObject ( okGameObjectName ) ;
68
69
var okBridgeEvents = okGameObject . AddComponent < IOSBridgeEvents > ( ) ;
69
70
okBridgeEvents . action += okCallback ;
70
71
71
- var cancelGameObject = new GameObject ( "IOSBridgeEvents - UIAlertController - Cancel" ) ;
72
+ var cancelGameObjectName = "IOSBridgeEvents - UIAlertController - Cancel" ;
73
+ var cancelGameObject = new GameObject ( cancelGameObjectName ) ;
72
74
var cancelBridgeEvents = cancelGameObject . AddComponent < IOSBridgeEvents > ( ) ;
73
75
cancelBridgeEvents . action += cancelCallback ;
74
76
@@ -86,14 +88,25 @@ public static void IOSUIAlertController(string title, string message, Action okC
86
88
87
89
} ;
88
90
89
- IOSUIAlertController ( title , message ) ;
91
+ IOSUIAlertController ( title , message , okGameObjectName , cancelGameObjectName ) ;
90
92
91
93
}
92
94
93
95
public static void IOSUIAlertController ( string title , string message , Action okCallback )
94
96
{
95
97
96
- IOSUIAlertController ( title , message , okCallback , ( ) => { } ) ;
98
+ var okGameObjectName = "IOSBridgeEvents - UIAlertController - OK" ;
99
+ var okGameObject = new GameObject ( okGameObjectName ) ;
100
+ var okBridgeEvents = okGameObject . AddComponent < IOSBridgeEvents > ( ) ;
101
+ okBridgeEvents . action += okCallback ;
102
+
103
+ okBridgeEvents . action += ( ) => {
104
+
105
+ UnityEngine . Object . Destroy ( okGameObject ) ;
106
+
107
+ } ;
108
+
109
+ IOSUIAlertController ( title , message , okGameObjectName , "" ) ;
97
110
98
111
}
99
112
0 commit comments