コード例 #1
0
 /// <summary>
 /// Show toast message to user.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="timelength"></param>
 public static void ShowToastMessage(string message, ToastTimeLength timelength = ToastTimeLength.Short)
 {
                 #if UNITY_ANDROID && !UNITY_EDITOR
     using (AndroidJavaClass nativeAndroidPlugin = new AndroidJavaClass("com.aeksaekhow.nativeandroidlib.NativeAndroidPlugin"))
     {
         using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
         {
             // Get context object.
             AndroidJavaObject context = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");
             // Call showToastMessage() method from Android script.
             nativeAndroidPlugin.CallStatic("showToastMessage", context, message, (int)timelength);
         }
     }
                 #endif
 }
コード例 #2
0
 /// <summary>
 /// Show toast message to user.
 /// </summary>
 /// <param name="message"></param>
 /// <param name="timelength"></param>
 public static void ShowToastMessage(string message, ToastTimeLength timelength = ToastTimeLength.Short)
 {
     #if UNITY_ANDROID
     using (AndroidJavaClass nativeAndroidPlugin = new AndroidJavaClass("com.aeksaekhow.nativeandroidlib.NativeAndroidPlugin"))
     {
         using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
         {
             // Get context object.
             AndroidJavaObject context = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
             // Call showToastMessage() method from Android script.
             nativeAndroidPlugin.CallStatic("showToastMessage", context, message, (int)timelength);
         }
     }
     #endif
 }