Пример #1
0
        public void BuildNavMesh()
        {
            var sources = CollectSources();

            // Use unscaled bounds - this differs in behaviour from e.g. collider components.
            // But is similar to reflection probe - and since navmesh data has no scaling support - it is the right choice here.
            var sourcesBounds = new Bounds(m_Center, Abs(m_Size));

            if (m_CollectObjects == CollectObjects.All || m_CollectObjects == CollectObjects.Children)
            {
                sourcesBounds = CalculateWorldBounds(sources);
            }

            var data = NavMeshBuilder.BuildNavMeshData(GetBuildSettings(),
                                                       sources, sourcesBounds, transform.position, transform.rotation);

            if (data != null)
            {
                data.name = gameObject.name;
                RemoveData();
                m_NavMeshData = data;
                if (isActiveAndEnabled)
                {
                    AddData();
                }
            }
        }
Пример #2
0
        public void BuildNavMesh()
        {
            var sources = CollectSources();

            // Use unscaled bounds - this differs in behaviour from e.g. collider components.
            // But is similar to reflection probe - and since navmesh data has no scaling support - it is the right choice here.
            var sourcesBounds = new Bounds(m_Center, Abs(m_Size));

            if (m_CollectObjects == CollectObjects.All || m_CollectObjects == CollectObjects.Children)
            {
                sourcesBounds = CalculateWorldBounds(sources);
            }

            // BEGIN THREETEE GANG: Potential Modification for building navmesh in 2d
            // var alteredRotation = Quaternion.FromToRotation(Vector3.up, Vector3.forward);
            var data = NavMeshBuilder.BuildNavMeshData(GetBuildSettings(),
                                                       sources, sourcesBounds, transform.position, Quaternion.Euler(-90.0f, 0.0f, 0.0f));

            // END THREETEE GANG: Potential Modification for building navmesh in 2d

            if (data != null)
            {
                data.name = gameObject.name;
                RemoveData();
                m_NavMeshData = data;
                if (isActiveAndEnabled)
                {
                    AddData();
                }
            }
        }
Пример #3
0
        public void BuildNavMesh()
        {
            List <NavMeshBuildSource> sources = this.CollectSources();
            Bounds worldBounds;

            ((Bounds) ref worldBounds).\u002Ector(this.m_Center, NavMeshSurface.Abs(this.m_Size));
            if (this.m_CollectObjects == CollectObjects.All || this.m_CollectObjects == CollectObjects.Children)
            {
                worldBounds = this.CalculateWorldBounds(sources);
            }
            NavMeshData navMeshData = NavMeshBuilder.BuildNavMeshData(this.GetBuildSettings(), sources, worldBounds, ((Component)this).get_transform().get_position(), ((Component)this).get_transform().get_rotation());

            if (!Object.op_Inequality((Object)navMeshData, (Object)null))
            {
                return;
            }
            ((Object)navMeshData).set_name(((Object)((Component)this).get_gameObject()).get_name());
            this.RemoveData();
            this.m_NavMeshData = navMeshData;
            if (!((Behaviour)this).get_isActiveAndEnabled())
            {
                return;
            }
            this.AddData();
        }
Пример #4
0
 public static NavMeshData BuildNavMeshData(NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds, Vector3 position, Quaternion rotation)
 {
     if (sources == null)
     {
         throw new ArgumentNullException("sources");
     }
     return(NavMeshBuilder.BuildNavMeshData(buildSettings, sources, localBounds, position, rotation, default(NavMeshBuildDebugSettings)));
 }
Пример #5
0
    NavMeshData Build(NavMeshPrefabInstance instance)
    {
        var root    = instance.transform;
        var sources = new List <NavMeshBuildSource>();
        var markups = new List <NavMeshBuildMarkup>();

        NavMeshBuilder.CollectSources(root, ~0, NavMeshCollectGeometry.RenderMeshes, 0, markups, sources);
        var settings = NavMesh.GetSettingsByID(0);
        var bounds   = new Bounds(Vector3.zero, 1000.0f * Vector3.one);
        var navmesh  = NavMeshBuilder.BuildNavMeshData(settings, sources, bounds, root.position, root.rotation);

        navmesh.name = "Navmesh";
        return(navmesh);
    }
Пример #6
0
        public void BuildNavMesh()
        {
            List <NavMeshBuildSource> sources = this.CollectSources();
            Bounds localBounds = new Bounds(this.m_Center, NavMeshSurface.Abs(this.m_Size));

            if (this.m_CollectObjects == CollectObjects.All || this.m_CollectObjects == CollectObjects.Children)
            {
                localBounds = this.CalculateWorldBounds(sources);
            }
            NavMeshData navMeshData = NavMeshBuilder.BuildNavMeshData(this.GetBuildSettings(), sources, localBounds, base.transform.position, base.transform.rotation);

            if (navMeshData != null)
            {
                navMeshData.name = base.gameObject.name;
                this.RemoveData();
                this.m_NavMeshData = navMeshData;
                if (base.isActiveAndEnabled)
                {
                    this.AddData();
                }
            }
        }