Beispiel #1
0
    /// <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 (TouchScreenKeyboard.visible || m_saveThread != null)
        {
            yield break;
        }

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

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

        // 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();
            metadata.m_name = kb.text;
            areaDescription.SaveMetadata(metadata);
        });
        m_saveThread.Start();
    }
    /// <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);
            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();
        }
    }
    /// <summary>
    /// Actually do the Area Description save.
    /// </summary>
    /// <returns>Coroutine IEnumerator.</returns>
    private IEnumerator _DoSaveCurrentAreaDescription()
    {
        // m_guiTextInputContents = "Unnamed";

        if (m_saveThread != null)
        {
            yield break;
        }
        bool saveConfirmed = true;

        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;
                name = GetComponent <AreaLoadingStartup>().GetName();

                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();
                //m_saveThread.Join();
            }
        }
    }
    /// <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>
    /// Thread method to save an Area Description and marker data.  Make this the ThreadFunc.
    /// </summary>
    /// <param name="xmlDataList">The marker's data list.</param>
    private void _AsyncDataSaving(List <MarkerData> xmlDataList)
    {
        if (xmlDataList == null)
        {
            Debug.Log("AndroidInGameController._AsyncDataSaving(): xmlDataList is null");
        }

        if (m_tangoApplication.m_enableAreaLearning)
        {
            m_curAreaDescription = AreaDescription.SaveCurrent();
        }
        _WriteToXml(m_curAreaDescription.m_uuid + ".xml", xmlDataList);
    }
    /// <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 #8
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();
        }
    }
Beispiel #9
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 #10
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
            }
        }
    }
Beispiel #11
0
        public static IEnumerator SaveCurrentADF(string name, Action onComplete)
        {
            bool      doneSaving = false;
            Exception error      = null;

            new Thread(() => {
                try {
                    // Save ADF.
                    var currentADF = AreaDescription.SaveCurrent();

                    // If name is speficied, name the ADF.
                    if (name != null)
                    {
                        currentADF.SaveNameAs(name);
                    }
                } catch (Exception e) {
                    error = e;
                } finally {
                    doneSaving = true;
                }
            }).Start();

            while (!doneSaving)
            {
                yield return(null);
            }

            if (error != null)
            {
                Debug.LogAssertion(error);
            }

            if (onComplete != null)
            {
                onComplete();
            }
        }
    /// <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
    }