/// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveAreaDescriptionAndMesh()
    {
        if (m_saveThread != null)
        {
            yield break;
        }

        // Disable interaction before saving.
        m_initialized     = false;
        m_savingText.text = "Saving Area Description...";

        if (string.IsNullOrEmpty(m_savedUUID))
        {
            m_saveThread = new Thread(delegate()
            {
                // Save the Area Description to file.
                m_curAreaDescription = AreaDescription.SaveCurrent();
                AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
                m_savedUUID     = m_curAreaDescription.m_uuid;
                metadata.m_name = metadata.m_dateTime.ToLongTimeString();
                m_curAreaDescription.SaveMetadata(metadata);

                // Save the tango dynamic mesh to file.
                StartCoroutine(_DoSaveTangoDynamicMesh());
            });
            m_saveThread.Start();
        }
        else
        {
            StartCoroutine(_DoSaveTangoDynamicMesh());
        }
    }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
#if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }

        bool saveConfirmed = m_guiTextInputResult;
#else
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = kb.done;
#endif
        if (saveConfirmed)
        {
            // Disable interaction before saving.
            m_initialized = false;
            m_savingText.gameObject.SetActive(true);
            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_curAreaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
#if UNITY_EDITOR
                    metadata.m_name = m_guiTextInputContents;
#else
                    metadata.m_name = kb.text;
#endif
                    m_curAreaDescription.SaveMetadata(metadata);
                });
                m_saveThread.Start();
            }
            else
            {
                _SaveMarkerToDisk();
                SceneManager.LoadScene(SceneManager.GetActiveScene().name);
            }
        }
    }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
#if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }
#elif UNITY_ANDROID
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        // Store name so it is available when we use it from thread delegate.
        var fileNameFromKeyboard = kb.text;
#endif
#if UNITY_ANDROID || UNITY_EDITOR
        // Save the text in a background thread.
        m_savingTextParent.gameObject.SetActive(true);
        m_saveThread = new Thread(delegate()
        {
            // Save the name put in with the Area Description.
            AreaDescription areaDescription   = AreaDescription.SaveCurrent();
            AreaDescription.Metadata metadata = areaDescription.GetMetadata();
#if UNITY_EDITOR
            metadata.m_name = m_guiTextInputContents;
#else
            metadata.m_name = fileNameFromKeyboard;
#endif
            areaDescription.SaveMetadata(metadata);
        });

        m_saveThread.Start();
#else
        yield return(null);
#endif
    }
Beispiel #4
0
    /// <summary>
    /// 保存区域描述.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
                #if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }

        bool saveConfirmed = m_guiTextInputResult;
                #else
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = kb.done;
                #endif
        // 保存.
        if (saveConfirmed)
        {
            // 保存前禁用交互.
            m_tangoReady = false;
            UIManager.Instance.ShowMessage("Saving...");
            if (m_tangoApplication.m_areaDescriptionLearningMode)             // 学习模式, 保存当前区域描述.
            {
                m_curAreaDescription = AreaDescription.SaveCurrent();
                AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
                                #if UNITY_EDITOR
                metadata.m_name = m_guiTextInputContents;
                                #else
                metadata.m_name = kb.text;
                                #endif
                m_curAreaDescription.SaveMetadata(metadata);
            }
            _SaveUnitToDisk();
        }
    }
    /// <summary>
    /// Save changes made to the selected Area Description's metaata.
    /// </summary>
    public void SaveSelectedAreaDescriptionMetadata()
    {
        if (m_selectedAreaDescription != null && m_selectedMetadata != null)
        {
            m_selectedMetadata.m_name = m_detailsEditableName.text;
            double.TryParse(m_detailsEditablePosX.text, out m_selectedMetadata.m_transformationPosition[0]);
            double.TryParse(m_detailsEditablePosY.text, out m_selectedMetadata.m_transformationPosition[1]);
            double.TryParse(m_detailsEditablePosZ.text, out m_selectedMetadata.m_transformationPosition[2]);
            double.TryParse(m_detailsEditableRotQX.text, out m_selectedMetadata.m_transformationRotation[0]);
            double.TryParse(m_detailsEditableRotQY.text, out m_selectedMetadata.m_transformationRotation[1]);
            double.TryParse(m_detailsEditableRotQZ.text, out m_selectedMetadata.m_transformationRotation[2]);
            double.TryParse(m_detailsEditableRotQW.text, out m_selectedMetadata.m_transformationRotation[3]);

            m_selectedAreaDescription.SaveMetadata(m_selectedMetadata);
            RefreshAreaDescriptionList();
        }
    }
Beispiel #6
0
 private IEnumerator _DoSaveCurrentAreaDescription()
 {
     if (m_saveThread != null)
     {
         yield break;
     }
     if (m_tangoApplication.m_areaDescriptionLearningMode)
     {
         m_saveThread = new Thread(delegate()
         {
             // Start saving process in another thread.
             m_currentAreaDescription          = AreaDescription.SaveCurrent();
             AreaDescription.Metadata metadata = m_currentAreaDescription.GetMetadata();
             metadata.m_name = "Demo";
             m_currentAreaDescription.SaveMetadata(metadata);
         });
         m_saveThread.Start();
     }
 }
Beispiel #7
0
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");

        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        if (kb.done)
        {
            // Disable interaction before saving.
            m_initialized = false;
            m_savingText.gameObject.SetActive(true);
            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_curAreaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
                    metadata.m_name = kb.text;
                    m_curAreaDescription.SaveMetadata(metadata);
                });
                m_saveThread.Start();
            }
            else
            {
                _SaveMarkerToDisk();
                #pragma warning disable 618
                Application.LoadLevel(Application.loadedLevel);
                #pragma warning restore 618
            }
        }
    }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard touchScreenKeyboard = TouchScreenKeyboard.Open("Unnamed");

        while (!touchScreenKeyboard.done && !touchScreenKeyboard.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = touchScreenKeyboard.done;

        if (saveConfirmed)
        {
            // Disable interaction before saving by removing PanelScanMenu.
            m_buttonSaveScan.interactable = false;

            // Check if Area Description Learning mode was ON (it should be)
            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_areaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_areaDescription.GetMetadata();
                    metadata.m_name = touchScreenKeyboard.text;
                    m_areaDescription.SaveMetadata(metadata);
                });
                m_saveThread.Start();
            }
        }
    }
    // <summary>
    // Actually do the Area Description save.
    // </summary>
    // <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
        //MobileNativeMessage msg = new MobileNativeMessage("Test", "saving objects");
#if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }

        bool saveConfirmed = m_guiTextInputResult;
#else
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = kb.done;
#endif
        if (saveConfirmed)
        {
            Debug.Log("saving confirmed");

            // Disable interaction before saving.
            m_initialized = false;
            Debug.Log("1111111111111111111111");

            m_savingText.gameObject.SetActive(true);
            Debug.Log(m_tangoApplication.m_areaDescriptionLearningMode);

            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                Debug.Log("learningmode on");

                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_curAreaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
#if UNITY_EDITOR
                    metadata.m_name = m_guiTextInputContents;
#else
                    metadata.m_name = kb.text;
#endif
                    m_curAreaDescription.SaveMetadata(metadata);
                });
                m_saveThread.Start();
            }
            else
            {
                _SaveObjectToDisk();
#pragma warning disable 618
                Application.LoadLevel(Application.loadedLevel);
#pragma warning restore 618
            }
        }
    }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
#if UNITY_EDITOR
        // Work around lack of on-screen keyboard in editor:
        if (m_displayGuiTextInput || m_saveThread != null)
        {
            yield break;
        }

        m_displayGuiTextInput  = true;
        m_guiTextInputContents = "Unnamed";
        while (m_displayGuiTextInput)
        {
            yield return(null);
        }

        bool saveConfirmed = m_guiTextInputResult;
#elif UNITY_ANDROID
        if (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

        TouchScreenKeyboard kb = TouchScreenKeyboard.Open("Unnamed");
        while (!kb.done && !kb.wasCanceled)
        {
            yield return(null);
        }

        bool saveConfirmed = kb.done;
#endif
#if UNITY_ANDROID || UNITY_EDITOR
        if (saveConfirmed)
        {
            // Disable interaction before saving.
            m_initialized = false;
            m_savingText.gameObject.SetActive(true);
            if (m_tangoApplication.m_areaDescriptionLearningMode)
            {
                // The keyboard is not readable if you are not in the Unity main thread. Cache the value here.
                string name;
#if UNITY_EDITOR
                name = m_guiTextInputContents;
#else
                name = kb.text;
#endif

                m_saveThread = new Thread(delegate()
                {
                    // Start saving process in another thread.
                    m_curAreaDescription = AreaDescription.SaveCurrent();
                    AreaDescription.Metadata metadata = m_curAreaDescription.GetMetadata();
                    metadata.m_name = name;
                    m_curAreaDescription.SaveMetadata(metadata);
                });
                m_saveThread.Start();
            }
            else
            {
                _SaveMarkerToDisk();
                #pragma warning disable 618
                Application.LoadLevel(Application.loadedLevel);
                #pragma warning restore 618
            }
        }
#else
        yield return(null);
#endif
    }