コード例 #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()
        {
            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();
        }
コード例 #3
0
ファイル: NavMeshSurface.cs プロジェクト: Huxellberger/Cell
        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();
                }
            }
        }
コード例 #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
        private List <NavMeshBuildSource> CollectSources()
        {
            List <NavMeshBuildSource> list  = new List <NavMeshBuildSource>();
            List <NavMeshBuildMarkup> list2 = new List <NavMeshBuildMarkup>();
            List <NavMeshModifier>    list3;

            if (this.m_CollectObjects == CollectObjects.Children)
            {
                list3 = new List <NavMeshModifier>(base.GetComponentsInChildren <NavMeshModifier>());
                list3.RemoveAll((NavMeshModifier x) => !x.isActiveAndEnabled);
            }
            else
            {
                list3 = NavMeshModifier.activeModifiers;
            }
            foreach (NavMeshModifier navMeshModifier in list3)
            {
                if ((this.m_LayerMask & 1 << navMeshModifier.gameObject.layer) != 0)
                {
                    if (navMeshModifier.AffectsAgentType(this.m_AgentTypeID))
                    {
                        list2.Add(new NavMeshBuildMarkup
                        {
                            root            = navMeshModifier.transform,
                            overrideArea    = navMeshModifier.overrideArea,
                            area            = navMeshModifier.area,
                            ignoreFromBuild = navMeshModifier.ignoreFromBuild
                        });
                    }
                }
            }
            if (this.m_CollectObjects == CollectObjects.All)
            {
                NavMeshBuilder.CollectSources(null, this.m_LayerMask, this.m_UseGeometry, this.m_DefaultArea, list2, list);
            }
            else if (this.m_CollectObjects == CollectObjects.Children)
            {
                NavMeshBuilder.CollectSources(base.transform, this.m_LayerMask, this.m_UseGeometry, this.m_DefaultArea, list2, list);
            }
            else if (this.m_CollectObjects == CollectObjects.Volume)
            {
                Matrix4x4 mat         = Matrix4x4.TRS(base.transform.position, base.transform.rotation, Vector3.one);
                Bounds    worldBounds = NavMeshSurface.GetWorldBounds(mat, new Bounds(this.m_Center, this.m_Size));
                NavMeshBuilder.CollectSources(worldBounds, this.m_LayerMask, this.m_UseGeometry, this.m_DefaultArea, list2, list);
            }
            if (this.m_IgnoreNavMeshAgent)
            {
                list.RemoveAll((NavMeshBuildSource x) => x.component != null && x.component.gameObject.GetComponent <NavMeshAgent>() != null);
            }
            if (this.m_IgnoreNavMeshObstacle)
            {
                list.RemoveAll((NavMeshBuildSource x) => x.component != null && x.component.gameObject.GetComponent <NavMeshObstacle>() != null);
            }
            this.AppendModifierVolumes(ref list);
            return(list);
        }
コード例 #6
0
        public AsyncOperation UpdateNavMesh(NavMeshData data)
        {
            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);
            }
            return(NavMeshBuilder.UpdateNavMeshDataAsync(data, this.GetBuildSettings(), sources, localBounds));
        }
コード例 #7
0
 private static bool UpdateNavMeshData(NavMeshData data, NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds, NavMeshBuildDebugSettings debug)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (sources == null)
     {
         throw new ArgumentNullException("sources");
     }
     return(NavMeshBuilder.UpdateNavMeshDataListInternal(data, buildSettings, sources, localBounds, debug));
 }
コード例 #8
0
 public static bool UpdateNavMeshData(NavMeshData data, NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (sources == null)
     {
         throw new ArgumentNullException("sources");
     }
     return(NavMeshBuilder.UpdateNavMeshData(data, buildSettings, sources, localBounds, default(NavMeshBuildDebugSettings)));
 }
コード例 #9
0
 public static AsyncOperation UpdateNavMeshDataAsync(NavMeshData data, NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (sources == null)
     {
         throw new ArgumentNullException("sources");
     }
     return(NavMeshBuilder.UpdateNavMeshDataAsyncListInternal(data, buildSettings, sources, localBounds));
 }
コード例 #10
0
        public static NavMeshData BuildNavMeshData(NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds, Vector3 position, Quaternion rotation)
        {
            if (sources == null)
            {
                throw new ArgumentNullException("sources");
            }
            NavMeshData navMeshData = new NavMeshData(buildSettings.agentTypeID);

            navMeshData.position = position;
            navMeshData.rotation = rotation;
            NavMeshBuilder.UpdateNavMeshDataListInternal(navMeshData, buildSettings, sources, localBounds);
            return(navMeshData);
        }
コード例 #11
0
 public static void CollectSources(Transform root, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, List <NavMeshBuildMarkup> markups, List <NavMeshBuildSource> results)
 {
     if (markups == null)
     {
         throw new ArgumentNullException("markups");
     }
     if (results == null)
     {
         throw new ArgumentNullException("results");
     }
     NavMeshBuildSource[] collection = NavMeshBuilder.CollectSourcesInternal(includedLayerMask, default(Bounds), root, false, geometry, defaultArea, markups.ToArray());
     results.Clear();
     results.AddRange(collection);
 }
コード例 #12
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);
    }
コード例 #13
0
        public AsyncOperation UpdateNavMesh(NavMeshData data)
        {
            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);
            }

            return(NavMeshBuilder.UpdateNavMeshDataAsync(data, GetBuildSettings(), sources, sourcesBounds));
        }
コード例 #14
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTagImproved.Collect(ref m_Sources, agentTypeID);
        var buildSettings = NavMesh.GetSettingsByID(agentTypeID);
        var bounds        = QuantizedBounds();

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, buildSettings, m_Sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, buildSettings, m_Sources, bounds);
        }
    }
コード例 #15
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTag1.Collect(ref m_Sources);
        var defaultBuildSettings = NavMesh.GetSettingsByID(0);
        var bounds = QuantizedBounds();

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #16
0
 public static void CollectSources(Bounds includedWorldBounds, int includedLayerMask, NavMeshCollectGeometry geometry, int defaultArea, List <NavMeshBuildMarkup> markups, List <NavMeshBuildSource> results)
 {
     if (markups == null)
     {
         throw new ArgumentNullException("markups");
     }
     if (results == null)
     {
         throw new ArgumentNullException("results");
     }
     includedWorldBounds.extents = Vector3.Max(includedWorldBounds.extents, 0.001f * Vector3.one);
     NavMeshBuildSource[] collection = NavMeshBuilder.CollectSourcesInternal(includedLayerMask, includedWorldBounds, null, true, geometry, defaultArea, markups.ToArray());
     results.Clear();
     results.AddRange(collection);
 }
コード例 #17
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTag.Collect(ref m_Sources); //←NavMeshSourceTagタグをセットしたオブジェクトをすべて集めてListに格納
        var defaultBuildSettings = NavMesh.GetSettingsByID(0);
        var bounds = QuantizedBounds();          //←メッシュ生成の範囲をセット

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);    //←実際のメッシュ生成を行っている部分。
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #18
0
        public static bool UpdateNavMeshData(NavMeshData data, NavMeshBuildSettings buildSettings, List <NavMeshBuildSource> sources, Bounds localBounds)
        {
            bool flag = data == null;

            if (flag)
            {
                throw new ArgumentNullException("data");
            }
            bool flag2 = sources == null;

            if (flag2)
            {
                throw new ArgumentNullException("sources");
            }
            return(NavMeshBuilder.UpdateNavMeshDataListInternal(data, buildSettings, sources, localBounds));
        }
コード例 #19
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTag.CollectMeshes(ref m_Sources);
        NavMeshSourceTag.CollectModifierVolumes(LayerMask.GetMask("Default"), ref m_Sources);

        var defaultBuildSettings = NavMesh.GetSettingsByID(AgentID);
        var bounds = QuantizedBounds();

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #20
0
        void UpdateNavMesh(bool asyncUpdate = false)
        {
            CollectMeshSources();


            //NavMeshSourceTag.Collect(ref m_Sources);
            var defaultBuildSettings = NavMesh.GetSettingsByID(0);

            if (asyncUpdate)
            {
                /*m_Operation = */ NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, meshSources, dungeonBounds);
            }
            else
            {
                NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, meshSources, dungeonBounds);
            }
        }
コード例 #21
0
    private void UpdateNavMesh(bool isAsync = false)
    {
        NavMeshSourceTag.Collect(ref sources);
        NavMeshBuildSettings settings;

        settings = NavMesh.GetSettingsByID(0);
        Bounds bounds = QuantizeBounds();

        if (isAsync)
        {
            operation = NavMeshBuilder.UpdateNavMeshDataAsync(navMesh, settings, sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(navMesh, settings, sources, bounds);
        }
    }
コード例 #22
0
        void Build(bool asyncUpdate)
        {
            Bounds bounds = QuantizedBounds();
            //Use agent settings
            NavMeshBuildSettings agentBuildSettings = NavMesh.GetSettingsByID(AgentID);

            agentBuildSettings.minRegionArea = MinRegionArea;

            //Bake updated nav mesh
            if (asyncUpdate)
            {
                Operation = NavMeshBuilder.UpdateNavMeshDataAsync(TheNavMeshData, agentBuildSettings, NavMeshRegionTag.Terrains, bounds);
            }
            else
            {
                NavMeshBuilder.UpdateNavMeshData(TheNavMeshData, agentBuildSettings, NavMeshRegionTag.Terrains, bounds);
            }
        }
コード例 #23
0
 void UpdateNavMesh()
 {
     if (navMeshIsUpdating)
     {
         if (navMeshUpdateOperation.isDone)
         {
             if (navMeshInstance.valid)
             {
                 NavMesh.RemoveNavMeshData(navMeshInstance);
             }
             navMeshInstance   = NavMesh.AddNavMeshData(navMeshData);
             navMeshIsUpdating = false;
         }
     }
     else if (navMeshHasNewData)
     {
         navMeshUpdateOperation = NavMeshBuilder.UpdateNavMeshDataAsync(navMeshData, navMeshBuildSettings, navMeshSources, worldBounds);
         navMeshIsUpdating      = true;
         navMeshHasNewData      = false;
     }
 }
コード例 #24
0
ファイル: BoxNavMeshArea.cs プロジェクト: whisperlin/TA
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        m_Sources.Clear();

        BoxCollider[] bcs = GetComponentsInChildren <BoxCollider>();



        Matrix4x4 worldToLocal = transform.worldToLocalMatrix;

        foreach (BoxCollider b in bcs)
        {
            var s = new NavMeshBuildSource();
            s.shape     = NavMeshBuildSourceShape.Box;
            s.transform = b.transform.localToWorldMatrix;
            s.size      = b.size;
            s.area      = areaId;

            var m = b.transform.localToWorldMatrix;


            m_Sources.Add(s);
        }
        var defaultBuildSettings = NavMesh.GetSettingsByID(0);

        defaultBuildSettings.agentRadius   = 0.08f;
        defaultBuildSettings.minRegionArea = 0.5f;

        bounds = CalculateWorldBounds(m_Sources);

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #25
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();
                }
            }
        }
コード例 #26
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTag.Collect(ref m_Sources);
        var defaultBuildSettings = NavMesh.GetSettingsByID(0);

        defaultBuildSettings.agentClimb    = 0.5f;
        defaultBuildSettings.minRegionArea = 50000.0f;
        defaultBuildSettings.agentSlope    = 30;
        defaultBuildSettings.agentRadius   = 0.5f;
        defaultBuildSettings.voxelSize     = 0.75f;

        var bounds = QuantizedBounds();

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
        else
        {
            //m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #27
0
    void UpdateNavMesh(bool asyncUpdate = false)
    {
        NavMeshSourceTag.Collect(ref m_Sources);
        var defaultBuildSettings = NavMesh.GetSettingsByID(0);

        defaultBuildSettings.voxelSize   = voxelSize;
        defaultBuildSettings.tileSize    = tileSize;
        defaultBuildSettings.agentClimb  = agentClimb;
        defaultBuildSettings.agentRadius = agentRadius;
        defaultBuildSettings.agentHeight = agentHeight;



        var bounds = QuantizedBounds();

        if (asyncUpdate)
        {
            m_Operation = NavMeshBuilder.UpdateNavMeshDataAsync(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
        else
        {
            NavMeshBuilder.UpdateNavMeshData(m_NavMesh, defaultBuildSettings, m_Sources, bounds);
        }
    }
コード例 #28
0
        List <NavMeshBuildSource> CollectSources()
        {
            var sources = new List <NavMeshBuildSource>();
            var markups = new List <NavMeshBuildMarkup>();

            List <NavMeshModifier> modifiers;

            if (m_CollectObjects == CollectObjects.Children)
            {
                modifiers = new List <NavMeshModifier>(GetComponentsInChildren <NavMeshModifier>());
                modifiers.RemoveAll(x => !x.isActiveAndEnabled);
            }
            else
            {
                modifiers = NavMeshModifier.activeModifiers;
            }

            foreach (var m in modifiers)
            {
                if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
                {
                    continue;
                }
                if (!m.AffectsAgentType(m_AgentTypeID))
                {
                    continue;
                }
                var markup = new NavMeshBuildMarkup();
                markup.root            = m.transform;
                markup.overrideArea    = m.overrideArea;
                markup.area            = m.area;
                markup.ignoreFromBuild = m.ignoreFromBuild;
                markups.Add(markup);
            }

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                if (m_CollectObjects == CollectObjects.All)
                {
                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
                else if (m_CollectObjects == CollectObjects.Children)
                {
                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
                else if (m_CollectObjects == CollectObjects.Volume)
                {
                    Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
                    var       worldBounds  = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));

                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
            }
            else
#endif
            {
                if (m_CollectObjects == CollectObjects.All)
                {
                    NavMeshBuilder.CollectSources(null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
                else if (m_CollectObjects == CollectObjects.Children)
                {
                    NavMeshBuilder.CollectSources(transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
                else if (m_CollectObjects == CollectObjects.Volume)
                {
                    Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
                    var       worldBounds  = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));
                    NavMeshBuilder.CollectSources(worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
            }

            foreach (NavMeshBuildSource a in sources)
            {
                if (a.component && a.component.transform.localPosition.sqrMagnitude > 10000 * 10000)
                {
                    Debug.LogError("too far away " + a.component.name, a.component);
                }
            }
            #if UNITY_EDITOR
            sources.RemoveAll((x) => (x.component != null && (GameObjectUtility.GetStaticEditorFlags(x.component.gameObject) & StaticEditorFlags.NavigationStatic) == 0));
            #endif

            if (m_IgnoreNavMeshAgent)
            {
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent <NavMeshAgent>() != null));
            }

            if (m_IgnoreNavMeshObstacle)
            {
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent <NavMeshObstacle>() != null));
            }

            AppendModifierVolumes(ref sources);
#if UNITY_EDITOR
            for (var index = 0; index < sources.Count; index++)
            {
                var a = sources[index];
                a.area         = GameObjectUtility.GetNavMeshArea(a.component.gameObject);
                sources[index] = a;
            }
#endif

            return(sources);
        }
コード例 #29
0
 private static bool UpdateNavMeshDataListInternal(NavMeshData data, NavMeshBuildSettings buildSettings, object sources, Bounds localBounds)
 {
     return(NavMeshBuilder.INTERNAL_CALL_UpdateNavMeshDataListInternal(data, ref buildSettings, sources, ref localBounds));
 }
コード例 #30
0
ファイル: NavMeshSurface.cs プロジェクト: frank731/topdown
        List <NavMeshBuildSource> CollectSources()
        {
            var sources = new List <NavMeshBuildSource>();
            var markups = new List <NavMeshBuildMarkup>();

            List <NavMeshModifier> modifiers;

            if (m_CollectObjects == CollectObjects.Children)
            {
                modifiers = new List <NavMeshModifier>(GetComponentsInChildren <NavMeshModifier>());
                modifiers.RemoveAll(x => !x.isActiveAndEnabled);
            }
            else
            {
                modifiers = NavMeshModifier.activeModifiers;
            }

            foreach (var m in modifiers)
            {
                if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
                {
                    continue;
                }
                if (!m.AffectsAgentType(m_AgentTypeID))
                {
                    continue;
                }
                var markup = new NavMeshBuildMarkup();
                markup.root            = m.transform;
                markup.overrideArea    = m.overrideArea;
                markup.area            = m.area;
                markup.ignoreFromBuild = m.ignoreFromBuild;
                markups.Add(markup);
            }

#if UNITY_EDITOR
            if (!EditorApplication.isPlaying)
            {
                if (m_CollectObjects == CollectObjects.All)
                {
                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
                else if (m_CollectObjects == CollectObjects.Children)
                {
                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
                else if (m_CollectObjects == CollectObjects.Volume)
                {
                    Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
                    var       worldBounds  = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));

                    UnityEditor.AI.NavMeshBuilder.CollectSourcesInStage(
                        worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, gameObject.scene, sources);
                }
            }
            else
#endif
            {
                if (m_CollectObjects == CollectObjects.All)
                {
                    NavMeshBuilder.CollectSources(null, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
                else if (m_CollectObjects == CollectObjects.Children)
                {
                    NavMeshBuilder.CollectSources(transform, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
                else if (m_CollectObjects == CollectObjects.Volume)
                {
                    Matrix4x4 localToWorld = Matrix4x4.TRS(transform.position, transform.rotation, Vector3.one);
                    var       worldBounds  = GetWorldBounds(localToWorld, new Bounds(m_Center, m_Size));
                    NavMeshBuilder.CollectSources(worldBounds, m_LayerMask, m_UseGeometry, m_DefaultArea, markups, sources);
                }
            }

            if (m_IgnoreNavMeshAgent)
            {
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent <NavMeshAgent>() != null));
            }

            if (m_IgnoreNavMeshObstacle)
            {
                sources.RemoveAll((x) => (x.component != null && x.component.gameObject.GetComponent <NavMeshObstacle>() != null));
            }

            AppendModifierVolumes(ref sources);

            return(sources);
        }