Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#130 added option to call non-async versions of rebuild #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NavMeshComponents/Editor/NavMeshAssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void StartBakingSurfaces(UnityEngine.Object[] surfaces)
var oper = new AsyncBakeOperation();

oper.bakeData = InitializeBakeData(surf);
oper.bakeOperation = surf.UpdateNavMesh(oper.bakeData);
oper.bakeOperation = surf.UpdateNavMeshAsync(oper.bakeData);
oper.surface = surf;

m_BakeOperations.Add(oper);
Expand Down
30 changes: 28 additions & 2 deletions NavMeshComponents/Scripts/NavMeshSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,36 @@ public AsyncOperation BuildNavMeshAsync()
AddData();
}

return UpdateNavMesh(m_NavMeshData);
return UpdateNavMeshAsync(m_NavMeshData);
}

public AsyncOperation UpdateNavMesh(NavMeshData data)
public void UpdateNavMesh()
{
UpdateNavMesh(navMeshData);
}

public void UpdateNavMesh(NavMeshData data)
{
using var builderState = new NavMeshBuilderState() { };

var sources = CollectSources(builderState);

// 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);
}
builderState.worldBounds = sourcesBounds;
for (int i = 0; i < NevMeshExtensions.Count; ++i)
{
NevMeshExtensions[i].PostCollectSources(this, sources, builderState);
}
NavMeshBuilder.UpdateNavMeshData(data, GetBuildSettings(), sources, sourcesBounds);
}

public AsyncOperation UpdateNavMeshAsync(NavMeshData data)
{
using var builderState = new NavMeshBuilderState() { };

Expand Down