Menu: Create toast for upgrades button

parent 57f9749c
No preview for this file type
using System;
using System.Collections;
using UnityEngine;
namespace AssemblyCSharp
{
public class SoonToast : MonoBehaviour {
// Use this for initialization
void Start() {
MyShowToast();
}
string toastString { get; set; }
AndroidJavaObject currentActivity;
public void MyShowToast()
{
if (Application.platform == RuntimePlatform.Android) {
showToastOnUiThread("This feature is coming soon!");
}
}
void showToastOnUiThread(string toastString){
AndroidJavaClass UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
currentActivity = UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
this.toastString = toastString;
currentActivity.Call ("runOnUiThread", new AndroidJavaRunnable (showToast));
}
void showToast(){
Debug.Log ("Running on UI thread");
AndroidJavaObject context = currentActivity.Call<AndroidJavaObject>("getApplicationContext");
AndroidJavaClass Toast = new AndroidJavaClass("android.widget.Toast");
AndroidJavaObject javaString=new AndroidJavaObject("java.lang.String",toastString);
AndroidJavaObject toast = Toast.CallStatic<AndroidJavaObject> ("makeText", context, javaString, Toast.GetStatic<int>("LENGTH_SHORT"));
toast.Call ("show");
}
}
}
fileFormatVersion: 2
guid: 26518842e54fd49f4a8fb1233f3fb280
timeCreated: 1477630875
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment