private static void ReceiveExternalCallAndroid(string param = "arguments") { string arguments = ""; AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject intent = ca.Call <AndroidJavaObject>("getIntent"); bool hasExtra = intent.Call <bool>("hasExtra", "arguments"); if (hasExtra) { AndroidJavaObject extras = intent.Call <AndroidJavaObject>("getExtras"); arguments = extras.Call <string>("getString", param); SGDebug.Log("Received external call: " + arguments); SGEnvironment.SetExternalCallParam(arguments); // dispose extras.Dispose(); } // dispose up.Dispose(); ca.Dispose(); intent.Dispose(); }
public static T LoadLocal <T>() where T : new() { object dataDeserialize = new T(); if (string.IsNullOrEmpty(LocalFilePath)) { return((T)dataDeserialize); } if (!File.Exists(LocalFilePath + localFileExtension)) { return((T)dataDeserialize); } BinaryFormatter bf = new BinaryFormatter(); try { FileStream file = File.Open(LocalFilePath + localFileExtension, FileMode.Open); dataDeserialize = bf.Deserialize(file); file.Close(); return((T)dataDeserialize); } catch (System.Exception e) { SGDebug.LogWarning("Failed to open the saved games file in " + LocalFilePath + localFileExtension); SGDebug.LogWarning(e); } return(new T()); }
public static bool DeleteLocal() { if (string.IsNullOrEmpty(LocalFilePath)) { return(false); } if (!File.Exists(LocalFilePath + localFileExtension)) { return(false); } try { File.Delete(LocalFilePath + localFileExtension); return(true); } catch (System.Exception e) { SGDebug.LogWarning("Failed to delete the saved games file in " + LocalFilePath + localFileExtension); SGDebug.LogWarning(e); } return(false); }
private void DestroyInterstitial() { if (interstitialAd != null) { interstitialAd.Destroy(); SGDebug.Log("AdInterstitial: Destroy"); } }
private void OnValueChanged_ForceCrashlytics() { if (forceCrashlytics.isOn) { forceCrashlytics.isOn = false; SGDebug.ForceException(); StartCoroutine(SGEnvironment.Quit()); } }
public void Request() { if (interstitialAd != null && interstitialAd.IsLoaded() && enable != "0") { firstTime = true; interstitialAd.Show(); SGDebug.Log("AdInterstitial: Show"); } }
public void DestroyBanner() { if (bannerView != null) { bannerView.Destroy(); showBanner = false; SGDebug.Log("AdBanner: Destroy"); } }
public void Request() { if (isLoaded) { firstTime = true; bannerView.Show(); SGDebug.Log("AdBanner: Show"); showBanner = true; } }
private void ValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { SGDebug.LogWarning("Realtime Database: " + args.DatabaseError.Message); return; } UpdateValues(args.Snapshot); }
void CheckGenuineApp() { if (checkGenuineApp) { if (!SGSecurity.CheckGenuine()) { SGDebug.LogWarning("CheckGenuine=false"); SGDebug.SetCustomKey("CheckGenuine", "False"); SGDebug.ForceException(); StartCoroutine(SGEnvironment.Quit()); } } }
// ref: https://stackoverflow.com/questions/48521807/firebase-remote-config-in-unity-get-only-default-values-and-not-real-ones private static void RemoteSettingsFetch(Task fetchTask) { if (fetchTask.IsCanceled) { Debug.Log("Remote Settings: Fetch canceled."); } else if (fetchTask.IsFaulted) { Debug.Log("Remote Settings: Fetch encountered an error."); } else if (fetchTask.IsCompleted) { Debug.Log("Remote Settings: Fetch completed!"); var info = FirebaseRemoteConfig.Info; switch (info.LastFetchStatus) { case LastFetchStatus.Success: Debug.Log(string.Format("Remote Settings: Data loaded and ready (last fetch time {0}).", info.FetchTime)); if (FirebaseRemoteConfig.ActivateFetched()) { rsActivateFetched = true; SGDebug.Log(string.Format("Remote Settings: Activate Fetched and Data loaded and ready (last fetch time {0}).", info.FetchTime)); } break; case LastFetchStatus.Failure: switch (info.LastFetchFailureReason) { case FetchFailureReason.Error: Debug.LogError("Remote Settings: Fetch failed for unknown reason"); break; case FetchFailureReason.Throttled: Debug.LogError("Remote Settings: Fetch throttled until " + info.ThrottledEndTime); break; } break; case LastFetchStatus.Pending: Debug.LogWarning("Remote Settings: Latest Fetch call still pending."); break; default: Debug.LogWarning(string.Format("Remote Settings: Something get wrong. Data: {0}", info)); break; } } }
public static void OnDynamicLink(object sender, EventArgs args) { if (!setupReady) { return; } var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs; string link = dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString; SGDebug.Log("Received dynamic link: " + link); SGEnvironment.SetDynamicLink(link); }
private static bool LaunchAndriodApp(string bundleId, string param = "arguments") { bool fail = false; // get the current activity AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject pm = ca.Call <AndroidJavaObject>("getPackageManager"); AndroidJavaObject launchIntent = null; try { launchIntent = pm.Call <AndroidJavaObject>("getLaunchIntentForPackage", bundleId); if (launchIntent == null) { fail = true; } else { launchIntent.Call <AndroidJavaObject>("putExtra", param, defaultMessage); } } catch (System.Exception e) { fail = true; SGDebug.Exception(e); } //open the app if (!fail) { ca.Call("startActivity", launchIntent); } up.Dispose(); ca.Dispose(); pm.Dispose(); launchIntent.Dispose(); return(!fail); }
public bool CheckAppInstallation(string bundleId) { bool installed = false; AndroidJavaClass up = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject ca = up.GetStatic <AndroidJavaObject>("currentActivity"); AndroidJavaObject pm = ca.Call <AndroidJavaObject>("getPackageManager"); AndroidJavaObject launchIntent = null; try { launchIntent = pm.Call <AndroidJavaObject>("getLaunchIntentForPackage", bundleId); if (launchIntent == null) { installed = false; } else { installed = true; } } catch (System.Exception e) { SGDebug.Exception(e); installed = false; } // dispose up.Dispose(); ca.Dispose(); pm.Dispose(); launchIntent.Dispose(); return(installed); }
public static bool SaveLocal(object dataSerializable) { if (string.IsNullOrEmpty(LocalFilePath)) { return(false); } BinaryFormatter bf = new BinaryFormatter(); try { FileStream file = File.Create(LocalFilePath + localFileExtension); //you can call it anything you want bf.Serialize(file, dataSerializable); file.Close(); return(true); } catch (System.Exception e) { SGDebug.LogWarning("Failed to save the saved games file in " + LocalFilePath + localFileExtension); SGDebug.LogWarning(e); } return(false); }
private void HandleOnAdLeavingApplication(object sender, EventArgs args) { SGDebug.Log("AdInterstitial: HandleAdLeavingApplication event received"); }
private void HandleOnAdClosed(object sender, EventArgs args) { SGDebug.Log("AdInterstitial: HandleAdClosed event received"); SGAnalytics.AnalyticsTraking(SGAnalytics.AnalyticsEvents.AdClose, "type", "Interstitial"); }
private void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args) { SGDebug.LogError("AdInterstitial: HandleFailedToReceiveAd event received with message: " + args.Message); SGAnalytics.AnalyticsTraking(SGAnalytics.AnalyticsEvents.AdFailed, "type", "Interstitial"); }
private void HandleOnAdOpened(object sender, EventArgs args) { SGDebug.Log("AdBanner: HandleAdOpened event received"); SGAnalytics.AnalyticsTraking(SGAnalytics.AnalyticsEvents.AdCompleted, "type", "Banner"); }
private void HandleOnAdLoaded(object sender, EventArgs args) { SGDebug.Log("AdBanner: HandleAdLoaded event received"); SGAnalytics.AnalyticsTraking(SGAnalytics.AnalyticsEvents.AdStart, "type", "Banner"); isLoaded = true; }