Beispiel #1
0
    IEnumerator Download(string guid)
    {
        var form   = new WWWForm();
        var server = "https://finchserver.azurewebsites.net/uploads/";

        using (var www = UnityWebRequest.Get(server + guid + ".bin"))
        {
            yield return(www.Send());

            if (www.isError)
            {
                Debug.Log("ajax error: " + www.error);
            }
            else
            {
                var bytes = www.downloadHandler.data;
                Debug.Log("ajax downloadbytes: " + bytes.Length);

                File.WriteAllBytes("/sdcard/" + guid, bytes);

                var res = AreaDescription.ImportFromFile("/sdcard/" + guid);
                Debug.Log("ajax result importfromfile: " + res);
            }
        }
    }
    /// <summary>
    /// Actually do the Area Description import.
    /// 
    /// This runs over multiple frames, so a Unity coroutine is used.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoImportAreaDescription()
	{#if UNITY_ANDROID 
        if (TouchScreenKeyboard.visible)
        {
            yield break;
        }
        
        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("/sdcard/", TouchScreenKeyboardType.Default, false);
	
		while (!kb.done && !kb.wasCanceled)
        {
            yield return null;
        }
        
        if (kb.done)
        {
            AreaDescription.ImportFromFile(kb.text);
        }
		#else 
		yield return null;

		#endif


    }
    /// <summary>
    /// Callback from FileSender. Called when the m_fileSender finished transfering the full package.
    /// </summary>
    /// <param name="fullAreaDescription">The full buffer that has been transferred.</param>
    private void _OnAreaDescriptionTransferFinished(byte[] fullAreaDescription)
    {
        m_progressPanel.SetActive(false);
#if !UNITY_EDITOR
        if (fullAreaDescription[0] == 0 && fullAreaDescription[1] == 1 &&
            fullAreaDescription[2] == 2 && fullAreaDescription[3] == 3)
        {
            // If first 4 values of full Area Description is 0, we consider the file sender is a debugging host.
            // In that case, we will start play in motion tracking mode.
            m_tangoApplication.GetComponent <RelocalizingOverlay>().SetOverlayActive(false);
            m_tangoApplication.m_enableAreaDescriptions = false;
            m_tangoApplication.Startup(null);
            _StartPlayer();
            m_localPlayer.GetComponent <TangoDeltaPoseController>().m_useAreaDescriptionPose = false;
        }
        else
        {
            Directory.CreateDirectory(TEMP_FILE_PATH);
            string path = TEMP_FILE_PATH + "received_area_description";
            File.WriteAllBytes(path, fullAreaDescription);
            AreaDescription.ImportFromFile(path);
        }
#endif
    }