Last active
November 24, 2015 21:31
-
-
Save bholota/e459577cd07f0efd76d7 to your computer and use it in GitHub Desktop.
Fire and forget Unity3d remote logger for mobile (Android/iOS) devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class Logger : MonoBehaviour | |
| { | |
| public static string URL = "XXX"; | |
| void Start() | |
| { | |
| if (Input.location.isEnabledByUser) | |
| { | |
| Input.location.Start(); | |
| } | |
| } | |
| public void AndroidLog(string message) | |
| { | |
| StartCoroutine(uploadLog(message)); | |
| } | |
| private IEnumerator uploadLog(string msg) | |
| { | |
| string deviceInfo = SystemInfo.deviceModel + " " + SystemInfo.deviceName + " " + SystemInfo.deviceType; | |
| string lastLocation = null; | |
| if (Input.location.status == LocationServiceStatus.Running) | |
| { | |
| lastLocation = Input.location.lastData.latitude + "," + Input.location.lastData.longitude; | |
| } | |
| WWWForm form = new WWWForm(); | |
| form.AddField("message", deviceInfo + " " + lastLocation + " " + msg); | |
| WWW w = new WWW(URL, form); | |
| yield return w; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment