Ejemplo n.º 1
0
        void GenerateLinks(NavLinkGenerator gen)
        {
            var tri       = NavMesh.CalculateTriangulation();
            var edge_list = CreateEdges(tri);

            foreach (var edge in edge_list)
            {
                edge.ComputeDerivedData();
            }
            if (edge_list.Count() == 0)
            {
                return;
            }

            RemoveLinks();
            m_CreatedLinks.Clear();
            var parent = NavEdUtil.GetNamedRoot(k_LinkRootName);

            foreach (var edge in edge_list)
            {
                var mid  = edge.GetMidpoint();
                var fwd  = edge.m_Normal;
                var link = CreateNavLink(parent, gen, edge, mid, fwd);
                if (link != null)
                {
                    m_CreatedLinks.Add(link);
                }
            }
        }
Ejemplo n.º 2
0
        void RemoveLinks()
        {
            var nav_links = NavEdUtil.GetNamedRoot(k_LinkRootName).GetComponentsInChildren <NavMeshLink>();

            foreach (var link in nav_links)
            {
                GameObject.DestroyImmediate(link.gameObject);
            }
        }
        static NavNonWalkableCollection Get()
        {
            var root = NavEdUtil.GetNamedRoot(k_NoMeshVolumeRootName);

            if (root == null)
            {
                root = new GameObject(k_NoMeshVolumeRootName).transform;
            }
            var collection = root.GetComponent <NavNonWalkableCollection>();

            if (collection == null)
            {
                collection = root.gameObject.AddComponent <NavNonWalkableCollection>();
            }
            return(collection);
        }