-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUnityNativeToasts.cs
43 lines (38 loc) · 1.24 KB
/
UnityNativeToasts.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace UnityNative.Toasts
{
public interface IUnityNativeToasts
{
void ShowLongToast(string toastText);
void ShowShortToast(string toastText);
}
public class UnityNativeToasts : IUnityNativeToasts
{
private readonly IUnityNativeToastsAdapter adapter;
public UnityNativeToasts(IUnityNativeToastsAdapter adapter)
{
this.adapter = adapter;
}
public void ShowLongToast(string toastText)
{
adapter.ShowLongToast(toastText);
}
public void ShowShortToast(string toastText)
{
adapter.ShowShortToast(toastText);
}
/// <summary>
/// Creates a UnityNativeToasts object with the correct platform setup. Use this if not being used with an IoC container
/// </summary>
/// <returns>Interface for the detected platform</returns>
public static IUnityNativeToasts Create()
{
#if UNITY_ANDROID
return new UnityNativeToasts(new AndroidUnityNativeToastsAdapter());
#elif UNITY_IOS
return new UnityNativeToasts(new IosUnityNativeToastsAdapter());
#else
return new UnityNativeToasts(new NullUnityNativeToastsAdapter());
#endif
}
}
}