Beispiel #1
0
    /// <summary>
    /// Populate a scrolling list with Area Descriptions. Each element will check if there is any associated
    /// mesh data tied to the Area Description by UUID. The Area Description file and linked mesh data are
    /// loaded when starting the game.
    /// </summary>
    private void _PopulateAreaDescriptionUIList()
    {
        // Load Area Descriptions.
        foreach (Transform t in m_listContentParent.transform)
        {
            Destroy(t.gameObject);
        }

        // Update Tango space Area Description list.
        AreaDescription[] areaDescriptionList = AreaDescription.GetList();

        if (areaDescriptionList == null)
        {
            return;
        }

        foreach (AreaDescription areaDescription in areaDescriptionList)
        {
            GameObject newElement = Instantiate(m_listElement) as GameObject;
            MeshOcclusionAreaDescriptionListElement listElement = newElement.GetComponent <MeshOcclusionAreaDescriptionListElement>();
            listElement.m_toggle.group             = m_toggleGroup;
            listElement.m_areaDescriptionName.text = areaDescription.GetMetadata().m_name;
            listElement.m_areaDescriptionUUID.text = areaDescription.m_uuid;

            // Check if there is an associated Area Description mesh.
            bool hasMeshData = File.Exists(m_meshSavePath + "/" + areaDescription.m_uuid) ? true : false;
            listElement.m_hasMeshData.gameObject.SetActive(hasMeshData);

            // Ensure the lambda makes a copy of areaDescription.
            AreaDescription lambdaParam = areaDescription;
            listElement.m_toggle.onValueChanged.AddListener((value) => _OnToggleChanged(lambdaParam, value));
            newElement.transform.SetParent(m_listContentParent.transform, false);
        }
    }
Beispiel #2
0
    /// <summary>
    /// Refresh the scrolling list's content for both list.
    ///
    /// This function will query from the Tango API for the Tango space Area Description. Also, when it populates
    /// the scrolling list content, it will connect the delegate for each button in the list. The delegate is
    /// responsible for the actual import/export  through the Tango API.
    /// </summary>
    private void _PopulateList()
    {
        foreach (Transform t in m_listContentParent.transform)
        {
            Destroy(t.gameObject);
        }

        // Update Tango space Area Description list.
        AreaDescription[] areaDescriptionList = AreaDescription.GetList();

        if (areaDescriptionList == null)
        {
            return;
        }

        foreach (AreaDescription areaDescription in areaDescriptionList)
        {
            GameObject newElement = Instantiate(m_listElement) as GameObject;
            AreaDescriptionListElement listElement = newElement.GetComponent <AreaDescriptionListElement>();
            listElement.m_toggle.group             = m_toggleGroup;
            listElement.m_areaDescriptionName.text = areaDescription.GetMetadata().m_name;
            listElement.m_areaDescriptionUUID.text = areaDescription.m_uuid;

            // Ensure the lambda makes a copy of areaDescription.
            AreaDescription lambdaParam = areaDescription;
            listElement.m_toggle.onValueChanged.AddListener((value) => _OnToggleChanged(lambdaParam, value));
            newElement.transform.SetParent(m_listContentParent.transform, false);
        }
    }
Beispiel #3
0
 // Retrieves the latest named ADF found in the disk.
 // Null if the permission is granted but the file is not found.
 // The behavior is undefined when a user permission has not been granted.
 public static AreaDescription FindAdfByName(string name)
 {
     return(AreaDescription.GetList()
            .Where(d => d.GetMetadata().m_name == name) // Matches name.
            .OrderBy(n => n.GetMetadata().m_dateTime)   // Sorts by date & time.
            .LastOrDefault());                          // Null if not found.
 }
    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.");
            }
        }
    }
Beispiel #5
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;
         }
     }
 }
Beispiel #6
0
    public void InitTangoScene()
    {
        string     prefabPath = "Prefabs/UI/SceneUI";
        GameObject content    = transform.FindChild("Top/SceneBtn/Scroll View/Viewport/Content").gameObject;

        AreaDescription[] areaDescriptionList = AreaDescription.GetList();
        if (areaDescriptionList == null)
        {
            return;
        }
        for (int i = 0; i < areaDescriptionList.Length; i++)
        {
            AreaDescription desc = areaDescriptionList [i];
            _AreaDescription.Add(desc);             //保存所有的描述

            GameObject data = Instantiate(Resources.Load(prefabPath, typeof(GameObject))) as GameObject;
            data.transform.SetParent(content.transform, false);

            Text name = data.transform.FindChild("desc").GetComponent <Text> ();
            name.text = desc.GetMetadata().m_name;

            int    pos    = i;
            Button button = data.gameObject.GetComponent <Button> ();
            button.onClick.AddListener(delegate() {
                this.PressLoad(pos);
            });
        }
    }
Beispiel #7
0
 // Fetch the list of ADFs from the device sorted by their name.
 IEnumerable <AreaDescription> GetAllSortedADFs()
 {
     // The list is null when permissions haven't been granted,
     // so in that case, proceed with an empty list.
     // The service procudes a warning, so we don't warn it here.
     return((AreaDescription.GetList() ?? new AreaDescription[0])
            .OrderByDescending(adf => adf.GetMetadata().m_dateTime));
 }
Beispiel #8
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;
            }
        }
    }
Beispiel #9
0
    public void OnTangoPermissions(bool permissionsGranted)
    {
        if (permissionsGranted)
        {
            AreaDescription[] list = AreaDescription.GetList();

            if (list.Length > 0)
            {
                foreach (var adf in list)
                {
                    Debug.Log("ajax adf found:" + adf.m_uuid);
                }
            }
            else
            {
                // No Area Descriptions available.
                Debug.Log("ajax No area descriptions available.");
            }
        }
    }
Beispiel #10
0
    private void _PopulateList()
    {
        vAreaDescription.Clear();
        // Update Tango space Area Description list.
        AreaDescription[] areaDescriptionList = AreaDescription.GetList();

        if (areaDescriptionList == null)
        {
            return;
        }

        for (int i = 0; i < areaDescriptionList.Length; i++)
        {
            Debug.Log(areaDescriptionList [i].GetMetadata().m_name);
            vAreaDescription.Add(areaDescriptionList [i]);             //保存所有的描述
        }
//		if (vAreaDescription.Count > 0){
//			m_curAreaDescription = vAreaDescription [0];//默认选第一个
//			m_curAreaDescriptionUUID = vAreaDescription[0].m_uuid;
//		}
    }
    /// <summary>
    /// Return UUID of the first Area Description named by the parameter, if none then return null.
    /// This function will query from the Tango API for the Tango space Area Description.
    /// </summary>
    public static string GetAreaDescriptionUUIDbyName(string name)
    {
        // Get Tango space Area Description list.
        AreaDescription[] areaDescriptionList = AreaDescription.GetList();

        if (areaDescriptionList == null)
        {
            return(null);
        }

        // Look for the specific Area Description in the list
        foreach (AreaDescription areaDescription in areaDescriptionList)
        {
            if (areaDescription.GetMetadata().m_name.Equals(name))
            {
                return(areaDescription.m_uuid);
            }
        }

        return(null);
    }
Beispiel #12
0
    public void OnTangoPermissions(bool permissionsGranted)
    {
        // AndroidHelper.StartTangoPermissionsActivity("Dataset Read/Write");

        dropdown.options.Clear();
        if (!permissionsGranted)
        {
            return;
        }
        dropdown.options.Add(new Dropdown.OptionData {
            text = "No ADF"
        });
        list = AreaDescription.GetList();
        if (list != null)
        {
            foreach (AreaDescription ad in list)
            {
                dropdown.options.Add(new Dropdown.OptionData(ad.GetMetadata().m_name + "_" + ad.m_uuid));
            }
        }
        dropdown.RefreshShownValue();
    }
    /// <summary>
    /// Refresh the UI list of Area Descriptions.
    /// </summary>
    public void RefreshAreaDescriptionList()
    {
        AreaDescription[] areaDescriptions = AreaDescription.GetList();
        _SelectAreaDescription(null);

        // Always remove all old children.
        foreach (Transform child in m_listParent)
        {
            Destroy(child.gameObject);
        }

        if (areaDescriptions != null)
        {
            // Add new children
            ToggleGroup toggleGroup = GetComponent <ToggleGroup>();
            foreach (AreaDescription areaDescription in areaDescriptions)
            {
                AreaDescriptionListElement button = GameObject.Instantiate(m_listElement) as AreaDescriptionListElement;
                button.m_areaDescriptionName.text = areaDescription.GetMetadata().m_name;
                button.m_areaDescriptionUUID.text = areaDescription.m_uuid;
                button.m_toggle.group             = toggleGroup;

                // Ensure the lambda gets a copy of the reference to areaDescription in its current state.
                // (See https://resnikb.wordpress.com/2009/06/17/c-lambda-and-foreach-variable/)
                AreaDescription lambdaParam = areaDescription;
                button.m_toggle.onValueChanged.AddListener((value) => _OnAreaDescriptionToggleChanged(lambdaParam, value));
                button.transform.SetParent(m_listParent, false);
            }

            m_listEmptyText.gameObject.SetActive(false);
        }
        else
        {
            m_listEmptyText.gameObject.SetActive(true);
        }
    }