Exemple #1
0
 public void OnTangoPermissions(bool permissionsGranted)
 {
     if (permissionsGranted)
     {
         AreaDescription[]        list = AreaDescription.GetList();
         AreaDescription.Metadata mostRecentMetadata = null;
         if (list.Length > 0)
         {
             // Find and load the most recent Area Description
             area = list[0];
             mostRecentMetadata = area.GetMetadata();
             foreach (AreaDescription areaDescription in list)
             {
                 AreaDescription.Metadata metadata = areaDescription.GetMetadata();
                 if (metadata.m_name.Contains("nathanbrandon00"))
                 {
                     area = areaDescription;
                     break;
                 }
             }
             loadedMessage = "AREA LOADED" + Environment.NewLine;
             m_tangoApplication.Startup(area);
             loadSuccess = true;
         }
     }
 }
Exemple #2
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()
    {
        // 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();
            }
        }
    }
    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            AreaDescription[]        list               = AreaDescription.GetList();
            AreaDescription          mostRecent         = null;
            AreaDescription.Metadata mostRecentMetadata = null;
            if (list.Length > 0)
            {
                // Find and load the most recent Area Description
                mostRecent         = list[0];
                mostRecentMetadata = mostRecent.GetMetadata();
                foreach (AreaDescription areaDescription in list)
                {
                    AreaDescription.Metadata metadata = areaDescription.GetMetadata();
                    if (metadata.m_dateTime > mostRecentMetadata.m_dateTime)
                    {
                        mostRecent         = areaDescription;
                        mostRecentMetadata = metadata;
                    }
                }

                m_tangoApplication.Startup(mostRecent);
            }
            else
            {
                // No Area Descriptions available.
                Debug.Log("No area descriptions available.");
            }
        }
    }
    /// <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>
    /// Select a specific Area Description to show details.
    /// </summary>
    /// <param name="areaDescription">Area Description to show details for, or <c>null</c> if details should be hidden.</param>
    private void _SelectAreaDescription(AreaDescription areaDescription)
    {
        m_selectedAreaDescription = areaDescription;

        if (areaDescription != null)
        {
            m_selectedMetadata = areaDescription.GetMetadata();
            m_detailsParent.gameObject.SetActive(true);

            m_detailsDate.text = m_selectedMetadata.m_dateTime.ToLongDateString() + ", " + m_selectedMetadata.m_dateTime.ToLongTimeString();

            m_detailsEditableName.text  = m_selectedMetadata.m_name;
            m_detailsEditablePosX.text  = m_selectedMetadata.m_transformationPosition[0].ToString();
            m_detailsEditablePosY.text  = m_selectedMetadata.m_transformationPosition[1].ToString();
            m_detailsEditablePosZ.text  = m_selectedMetadata.m_transformationPosition[2].ToString();
            m_detailsEditableRotQX.text = m_selectedMetadata.m_transformationRotation[0].ToString();
            m_detailsEditableRotQY.text = m_selectedMetadata.m_transformationRotation[1].ToString();
            m_detailsEditableRotQZ.text = m_selectedMetadata.m_transformationRotation[2].ToString();
            m_detailsEditableRotQW.text = m_selectedMetadata.m_transformationRotation[3].ToString();
        }
        else
        {
            m_selectedMetadata = null;
            m_detailsParent.gameObject.SetActive(false);
        }
    }
    /// <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
    }
Exemple #10
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();
        }
    }
Exemple #11
0
    void SelectMapButton(string metadataName)
    {
        foreach (AreaDescription areaDescription in list)
        {
            AreaDescription.Metadata metadata = areaDescription.GetMetadata();
            if (metadata.m_name == metadataName)
            {
                FindObjectOfType <TangoApplication>().AreaDescriptionLearningMode = false;
                mapName = metadataName;

                UIManager.gs = UIManager.guistate.InGame;
                m_tangoApplication.Startup(areaDescription);
                GetComponent <PhotonManager>().ConnectPlayer();
                return;
            }
        }
    }
Exemple #12
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();
     }
 }
Exemple #13
0
    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            if (!isNewMap)
            {
                list = AreaDescription.GetList();
                if (list.Length > 0)
                {
                    foreach (AreaDescription areaDescription in list)
                    {
                        AreaDescription.Metadata metadata = areaDescription.GetMetadata();

                        GameObject b = Instantiate(MapSelectorButton);
                        b.transform.SetParent(MapSelectorPanel.transform);
                        Button tempButton = b.GetComponent <Button>();
                        tempButton.GetComponentInChildren <Text>().text = metadata.m_name;
                        tempButton.onClick.AddListener(() => SelectMapButton(tempButton.GetComponentInChildren <Text>().text));
                    }
                }
                else
                {
                    // No Area Descriptions available.
                    m_tangoApplication.AreaDescriptionLearningMode = true;
                    isNewMap = true;
                    mapName  = "NewMap";
                    m_tangoApplication.Startup(null);
                    //GetComponent<PhotonManager>().ConnectPlayer();
                    //UIManager.gs = UIManager.guistate.InGameLearning;
                    GameManager.gs = GameManager.gamestate.InGameCreatingMap;
                }
            }
            else
            {
                m_tangoApplication.AreaDescriptionLearningMode = true;
                m_tangoApplication.Startup(null);
                //GetComponent<PhotonManager>().ConnectPlayer();
                //UIManager.gs = UIManager.guistate.InGameLearning;
                GameManager.gs = GameManager.gamestate.InGameCreatingMap;
            }
        }
    }
Exemple #14
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
    }