Exemple #1
0
    IEnumerator UploadFileCo(string localFileName, string uploadURL)
    {
        WWW localFile = new WWW("file:///" + localFileName);

        yield return(localFile);

        if (localFile.error == null)
        {
            Debug.Log("Loaded file successfully");
        }
        else
        {
            Debug.Log("Open file error: " + localFile.error);
            yield break;             // stop the coroutine here
        }
        WWWForm postForm = new WWWForm();

        postForm.AddBinaryData("theFile", localFile.bytes, localFileName, "text/plain");
        WWW upload = new WWW(uploadURL, postForm);

        yield return(upload);

        if (upload.error == null)
        {
            string url = upload.text;

            SoundLoc soundLoc = new SoundLoc(myLat, myLong, url);
            reference.Push().SetRawJsonValueAsync(JsonUtility.ToJson(soundLoc));
            Debug.Log("Uploaded!");
        }
        else
        {
            Debug.Log("Error during upload: " + upload.error);
        }
    }
Exemple #2
0
    float DistanceToSound(SoundLoc soundLoc)
    {
        float distance = Mathf.Sqrt(Mathf.Pow(myLat - soundLoc.latitude, 2) + Mathf.Pow(myLong - soundLoc.longitude, 2));

        return(distance);
    }