public void InitializeNavigation(NavigationTargetListButton button)
        {
            if (!m_managerInitialized)
            {
                Debug.LogWarning("NavigationManager: Navigation Manager not properly initialized.");
                return;
            }

            m_targetTransform = button.targetObject.transform;
            TryToFindPath(m_targetTransform);
        }
        public void TryToFindPath(NavigationTargetListButton button)
        {
            if (m_StopNavigationButton != null)
            {
                m_StopNavigationButton.SetActive(false);
            }

            if (m_NavigationPath != null)
            {
                DeletePath();
                m_Path = Instantiate(m_NavigationPath, m_ARSpace.transform);
                BuildNavigationPath navpath = m_Path.GetComponent <BuildNavigationPath>();

                navpath.m_ARSpace = m_ARSpace;
                navpath.BuildPath(button);
            }
        }
示例#3
0
        public Transform BuildPath(NavigationTargetListButton button)
        {
            m_CameraTransform = Camera.main.transform;
            m_TargetTransform = button.targetObject.transform;

            // check if main camera exists
            if (m_CameraTransform == null)
            {
                Debug.Log("Could not find the main camera. Do you have the MainCamera tag applied?");
                return(null);
            }

            // check if target from button was found
            if (m_TargetTransform == null)
            {
                Debug.Log("Target not found");
                return(null);
            }

            // check if AR Space exists
            if (m_ARSpace == null)
            {
                arSpace = gameObject.GetComponentInParent <Immersal.AR.ARSpace>();
                if (arSpace == null)
                {
                    Debug.Log("No AR Space found. Does one exist in scene?");
                    return(null);
                }
            }

            m_IsInitialized     = true;
            m_NavigationArrived = false;
            UpdatePath(false);

            // create the compass m_Arrow
            if (m_ArrowPrefab != null)
            {
                m_Arrow          = Instantiate(m_ArrowPrefab, m_CameraTransform.transform);
                m_ArrowDirection = m_Arrow.GetComponent <LookTowardsTarget>();
                m_Arrow.SetActive(false);
            }

            return(m_TargetTransform);
        }
示例#4
0
        public void GenerateButtons()
        {
            if (m_Buttons.Count > 0)
            {
                DestroyButtons();
            }

            // loops through all navigation categories
            foreach (KeyValuePair <NavigationTargets.NavigationCategory, List <GameObject> > entry in NavigationTargets.NavigationTargetsDict)
            {
                // loops through all targets in each category
                foreach (GameObject go in entry.Value)
                {
                    IsNavigationTarget isNavigationTarget = go.GetComponent <IsNavigationTarget>();
                    string             targetName         = isNavigationTarget.targetName;
                    Sprite             icon = isNavigationTarget.icon;

                    GameObject button = Instantiate(m_ButtonTemplate, m_ContentParent);
                    m_Buttons.Add(button);
                    button.SetActive(true);
                    button.name = "button " + targetName;

                    NavigationTargetListButton navigationTargetListButton = button.GetComponent <NavigationTargetListButton>();
                    navigationTargetListButton.SetText(targetName);
                    navigationTargetListButton.SetIcon(icon);
                    navigationTargetListButton.SetTarget(go);
                }
            }

            // calculate lists RectTransform size
            float         x             = m_ButtonTemplate.GetComponent <RectTransform>().sizeDelta.x;
            float         y             = m_ButtonTemplate.GetComponent <RectTransform>().sizeDelta.y *Mathf.Min(m_Buttons.Count, m_MaxButtonsOnScreen);
            RectTransform rectTransform = GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(x, y);

            ScrollToTop();
        }