Skip to content

Commit 2da6a41

Browse files
authored
将iOSNative.cs中的方法分成多个子类
将iOSNative.cs中的方法按照Obj-C插件分成多个子类,例如原先的 `iOSNative.Synchronize()` 现在需要使用 `iOSNative.iCloudKeyValueStore.Synchronize()` 进行调用
1 parent 717bfe6 commit 2da6a41

1 file changed

Lines changed: 175 additions & 148 deletions

File tree

iOSNative.cs

Lines changed: 175 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -3,215 +3,242 @@
33
using System.Collections.Generic;
44
using System.Runtime.InteropServices;
55
using UnityEngine;
6-
public class iOSNative
6+
public static class iOSNative
77
{
8+
public static class iCloudKeyValueStore
9+
{
810
#if UNITY_IOS && !UNITY_EDITOR
9-
[DllImport("__Internal")]
10-
private static extern void _initialize();
11-
12-
[DllImport("__Internal")]
13-
private static extern void _ShowTempAlert(string alertString, int duration = 5);
14-
15-
[DllImport("__Internal")]
16-
private static extern void _PushNotification(string msg, string title, string identifier, int delay);
17-
18-
[DllImport("__Internal")]
19-
private static extern void _RemovePendingNotifications(string identifier);
20-
21-
[DllImport("__Internal")]
22-
private static extern void _RemoveAllPendingNotifications();
23-
24-
25-
[DllImport("__Internal")]
26-
private static extern bool _Synchronize();
27-
28-
[DllImport("__Internal")]
29-
private static extern void _PlayHaptics(int style, float intensity);//0 = Light, 1=Medium, 2=Heavy
11+
[DllImport("__Internal")]
12+
private static extern bool _Synchronize();
3013

31-
[DllImport("__Internal")]
32-
private static extern void _Share(string message, string url, string imagePath);
14+
[DllImport("__Internal")]
15+
private static extern bool _IsICloudAvailable();
3316

34-
[DllImport("__Internal")]
35-
private static extern bool _IsICloudAvailable();
17+
[DllImport("__Internal")]
18+
private static extern bool _ClearICloudSave();
3619

37-
[DllImport("__Internal")]
38-
private static extern bool _ClearICloudSave();
20+
[DllImport("__Internal")]
21+
private static extern string _iCloudGetString(string key, string defaultValue);
3922

40-
[DllImport("__Internal")]
41-
private static extern string _iCloudGetString(string key, string defaultValue);
23+
[DllImport("__Internal")]
24+
private static extern bool _iCloudSaveString(string key, string value);
4225

43-
[DllImport("__Internal")]
44-
private static extern bool _iCloudSaveString(string key, string value);
26+
[DllImport("__Internal")]
27+
private static extern int _iCloudGetInt(string key, int defaultValue);
4528

46-
[DllImport("__Internal")]
47-
private static extern int _iCloudGetInt(string key, int defaultValue);
29+
[DllImport("__Internal")]
30+
private static extern bool _iCloudSaveInt(string key, int value);
4831

49-
[DllImport("__Internal")]
50-
private static extern bool _iCloudSaveInt(string key, int value);
32+
[DllImport("__Internal")]
33+
private static extern float _iCloudGetFloat(string key, float defaultValue);
5134

52-
[DllImport("__Internal")]
53-
private static extern float _iCloudGetFloat(string key, float defaultValue);
35+
[DllImport("__Internal")]
36+
private static extern bool _iCloudSaveFloat(string key, float value);
5437

55-
[DllImport("__Internal")]
56-
private static extern bool _iCloudSaveFloat(string key, float value);
57-
58-
[DllImport("__Internal")]
59-
private static extern bool _iCloudGetBool(string key, bool defaultValue);
38+
[DllImport("__Internal")]
39+
private static extern bool _iCloudGetBool(string key, bool defaultValue);
6040

61-
[DllImport("__Internal")]
62-
private static extern bool _iCloudSaveBool(string key, bool value);
41+
[DllImport("__Internal")]
42+
private static extern bool _iCloudSaveBool(string key, bool value);
6343
#endif
64-
public static void Initialize()
65-
{
66-
#if UNITY_IOS && !UNITY_EDITOR
67-
_initialize();
68-
#endif
69-
}
70-
71-
public static void ShowTempAlert(string alertString, int duration = 5)
72-
{
73-
#if UNITY_IOS && !UNITY_EDITOR
74-
_ShowTempAlert(alertString, duration);
75-
#endif
76-
}
77-
78-
public static bool Synchronize()
79-
{
80-
#if UNITY_IOS && !UNITY_EDITOR
81-
return _Synchronize();
82-
#else
83-
return default(bool);
84-
#endif
85-
}
86-
public static bool IsICloudAvailable()
87-
{
44+
public static bool IsICloudAvailable()
45+
{
8846
#if UNITY_IOS && !UNITY_EDITOR
8947
return _IsICloudAvailable();
9048
#else
91-
return default(bool);
49+
return false;
9250
#endif
93-
}
94-
/// <summary>
95-
/// PlayHaptics
96-
/// </summary>
97-
/// <param name="style">0 = Light, 1=Medium, 2=Heavy</param>
98-
/// <param name="intensity">Intensity 0.0 - 1.0</param>
99-
public static void PlayHaptics(int style, float intensity)//0 = Light, 1=Medium, 2=Heavy; Intensity 0.0 - 1.0
100-
{
51+
}
52+
public static bool Synchronize()
53+
{
10154
#if UNITY_IOS && !UNITY_EDITOR
102-
_PlayHaptics(style, intensity);
103-
#endif
104-
}
105-
106-
107-
public static void Share(string message, string url = "", string imagePath = "", Action closeCallback = null)
108-
{
109-
#if UNITY_IOS && !UNITY_EDITOR
110-
_Share(message, url, imagePath);
111-
#endif
112-
iOSCallbackHelper.INSTANCE.SetShareCloseCallback(closeCallback);
113-
}
114-
public static void PushNotification(string msg, string title, string identifier, int delay)
115-
{
116-
#if UNITY_IOS && !UNITY_EDITOR
117-
_PushNotification(msg, title, identifier, delay);
118-
#endif
119-
}
120-
public static void RemovePendingNotifications(string identifier)
121-
{
122-
#if UNITY_IOS && !UNITY_EDITOR
123-
_RemovePendingNotifications(identifier);
124-
#endif
125-
}
126-
public static void RemoveAllPendingNotifications()
127-
{
128-
#if UNITY_IOS && !UNITY_EDITOR
129-
_RemoveAllPendingNotifications();
55+
return _Synchronize();
56+
#else
57+
return false;
13058
#endif
131-
}
132-
133-
134-
135-
136-
137-
public static bool ClearICloudSave()
138-
{
59+
}
60+
public static bool ClearICloudSave()
61+
{
13962
#if UNITY_IOS && !UNITY_EDITOR
14063
return _ClearICloudSave();
14164
#else
142-
return default(bool);
65+
return default(bool);
14366
#endif
144-
}
67+
}
14568

146-
public static string iCloudGetStringValue(string key, string defaultValue)
147-
{
69+
public static string iCloudGetStringValue(string key, string defaultValue)
70+
{
14871
#if UNITY_IOS && !UNITY_EDITOR
14972
return _iCloudGetString(key, defaultValue);
15073
#else
151-
return default(string);
74+
return string.Empty;
15275
#endif
153-
}
76+
}
15477

155-
public static bool iCloudSaveStringValue(string key, string value)
156-
{
78+
public static bool iCloudSaveStringValue(string key, string value)
79+
{
15780
#if UNITY_IOS && !UNITY_EDITOR
15881
return _iCloudSaveString(key, value);
15982
#else
160-
return default(bool);
83+
return false;
16184
#endif
162-
}
85+
}
16386

164-
public static int iCloudGetIntValue(string key, int defaultValue)
165-
{
87+
public static int iCloudGetIntValue(string key, int defaultValue)
88+
{
16689
#if UNITY_IOS && !UNITY_EDITOR
16790
return _iCloudGetInt(key, defaultValue);
16891
#else
169-
return default(int);
92+
return 0;
17093
#endif
171-
}
94+
}
17295

173-
public static bool iCloudSaveIntValue(string key, int value)
174-
{
96+
public static bool iCloudSaveIntValue(string key, int value)
97+
{
17598
#if UNITY_IOS && !UNITY_EDITOR
17699
return _iCloudSaveInt(key, value);
177100
#else
178-
return default(bool);
101+
return false;
179102
#endif
180-
}
103+
}
181104

182-
public static float iCloudGetFloatValue(string key, float defaultValue)
183-
{
105+
public static float iCloudGetFloatValue(string key, float defaultValue)
106+
{
184107
#if UNITY_IOS && !UNITY_EDITOR
185108
return _iCloudGetFloat(key, defaultValue);
186109
#else
187-
return default(float);
110+
return 0;
188111
#endif
189-
}
112+
}
190113

191-
public static bool iCloudSaveFloatValue(string key, float value)
192-
{
114+
public static bool iCloudSaveFloatValue(string key, float value)
115+
{
193116
#if UNITY_IOS && !UNITY_EDITOR
194117
return _iCloudSaveFloat(key, value);
195118
#else
196-
return default(bool);
119+
return false;
197120
#endif
198-
}
121+
}
199122

200-
public static bool iCloudGetBoolValue(string key, bool defaultValue)
201-
{
123+
public static bool iCloudGetBoolValue(string key, bool defaultValue)
124+
{
202125
#if UNITY_IOS && !UNITY_EDITOR
203126
return _iCloudGetBool(key, defaultValue);
204127
#else
205-
return default(bool);
128+
return false;
206129
#endif
207-
}
130+
}
208131

209-
public static bool iCloudSaveBoolValue(string key, bool value)
210-
{
132+
public static bool iCloudSaveBoolValue(string key, bool value)
133+
{
211134
#if UNITY_IOS && !UNITY_EDITOR
212135
return _iCloudSaveBool(key, value);
213136
#else
214-
return default(bool);
137+
return false;
138+
#endif
139+
}
140+
}
141+
142+
143+
144+
public static class iOSNotification
145+
{
146+
#if UNITY_IOS && !UNITY_EDITOR
147+
[DllImport("__Internal")]
148+
private static extern void _PushNotification(string msg, string title, string identifier, int delay);
149+
150+
[DllImport("__Internal")]
151+
private static extern void _RemovePendingNotifications(string identifier);
152+
153+
[DllImport("__Internal")]
154+
private static extern void _RemoveAllPendingNotifications();
155+
#endif
156+
public static void PushNotification(string msg, string title, string identifier, int delay)
157+
{
158+
#if UNITY_IOS && !UNITY_EDITOR
159+
_PushNotification(msg, title, identifier, delay);
160+
#endif
161+
}
162+
public static void RemovePendingNotifications(string identifier)
163+
{
164+
#if UNITY_IOS && !UNITY_EDITOR
165+
_RemovePendingNotifications(identifier);
166+
#endif
167+
}
168+
public static void RemoveAllPendingNotifications()
169+
{
170+
#if UNITY_IOS && !UNITY_EDITOR
171+
_RemoveAllPendingNotifications();
172+
#endif
173+
}
174+
}
175+
176+
177+
178+
public static class iOSUIView
179+
{
180+
#if UNITY_IOS && !UNITY_EDITOR
181+
[DllImport("__Internal")]
182+
private static extern void _ShowTempAlert(string alertString, int duration = 5);
183+
#endif
184+
public static void ShowTempAlert(string alertString, int duration = 5)
185+
{
186+
#if UNITY_IOS && !UNITY_EDITOR
187+
_ShowTempAlert(alertString, duration);
188+
#endif
189+
}
190+
}
191+
192+
193+
194+
public static class iOSDevice
195+
{
196+
#if UNITY_IOS && !UNITY_EDITOR
197+
[DllImport("__Internal")]
198+
private static extern void _PlayHaptics(int style, float intensity);//0 = Light, 1=Medium, 2=Heavy
199+
200+
#endif
201+
/// <summary>
202+
/// PlayHaptics
203+
/// </summary>
204+
/// <param name="style">0 = Light, 1=Medium, 2=Heavy</param>
205+
/// <param name="intensity">Intensity 0.0 - 1.0</param>
206+
public static void PlayHaptics(int style, float intensity)
207+
{
208+
#if UNITY_IOS && !UNITY_EDITOR
209+
_PlayHaptics(style, intensity);
210+
#endif
211+
}
212+
}
213+
214+
215+
216+
public static class iOSShare
217+
{
218+
#if UNITY_IOS && !UNITY_EDITOR
219+
[DllImport("__Internal")]
220+
private static extern void _Share(string message, string url, string imagePath);
221+
222+
#endif
223+
public static void Share(string message, string url = "", string imagePath = "", Action closeCallback = null)
224+
{
225+
#if UNITY_IOS && !UNITY_EDITOR
226+
_Share(message, url, imagePath);
227+
iOSCallbackHelper.INSTANCE.SetShareCloseCallback(closeCallback);
228+
#endif
229+
}
230+
231+
}
232+
233+
234+
235+
#if UNITY_IOS && !UNITY_EDITOR
236+
[DllImport("__Internal")]
237+
private static extern void _initialize();
238+
#endif
239+
public static void Initialize(){
240+
#if UNITY_IOS && !UNITY_EDITOR
241+
_initialize();
215242
#endif
243+
}
216244
}
217-
}

0 commit comments

Comments
 (0)