How to use Unity NavMeshes with LoadLevelAdditive (aka “A Dirty NavMesh Hack”)

Unity Pro has a nice feature for baking and navigating via NavMeshes. In Unity Pro (4.x), a baked NavMesh is associated with a saved “Scene”. Most of the time, this is all well and good, but as others have discovered, sometimes this simplification / limitation poses a problem when you want to use LoadLevelAdditive or LoadLevelAdditiveAsync. The current NavMesh is always the one from the last scene that was loaded via LoadLevel or LoadLevelAsync. This poses a problem if you say, have a fast loading title screen (scene A) which then uses LoadLevelAdditiveAsync to load the main level (scene B) containing the guts of the game, including the baked NavMesh you want to use. The NavMesh in scene B won’t be loaded. cialis tv commercial 2013

To solve this, I discovered a (hackish) workaround that involves associating a single baked NavMesh with two scenes, via editing the Scene file in text mode (TLDR; the NavMeshSettings section in .unity Scene files defines the NavMesh for that scene. It appears two scenes can point to the same NavMesh. Gentlemen, start your Vim’s & Emacsen !). viagra advice uk

SceneA.unity will be the one without a baked navmesh that gets loaded via LoadLevel. SceneB.unity will be the one with a baked navmesh that gets loaded by LoadLevelAdditive. vardenafil and sildenafil

  • Bake your NavMesh as usual and save your scene (“SceneB”). best place to buy cialis online
  • Make a backup copy of SceneA.unity and SceneB.unity (just in case).
  • In Edit -> Project Settings -> Editor, change Asset Serialization to Force Text.
  • Using a good text editor (ie NOT Windows Notepad), open the SceneB.unity file. Find the section that looks like this (eg search for NavMeshSettings): viagra model 2015
NavMeshSettings:
 m_ObjectHideFlags: 0
 m_BuildSettings:
 agentRadius: .5
 agentHeight: 2
 agentSlope: 45
 agentClimb: .400000006
 ledgeDropHeight: 0
 maxJumpAcrossDistance: 0
 accuratePlacement: 0
 minRegionArea: 2
 widthInaccuracy: 16.666666
 heightInaccuracy: 10
 m_NavMesh: {fileID: 19400000, guid: 86b949ed892434e22ab739dd2c9ad685, type: 2}
  • Copy this text (everything between the — and —).
  • Open SceneA.unity in the text editor. Find the equivalent NavMeshSettings section – it will looks something like this, assuming no NavMesh have been baked on that scene.
NavMeshSettings:
 m_ObjectHideFlags: 0
 m_BuildSettings:
 agentRadius: .5
 agentHeight: 2
 agentSlope: 45
 agentClimb: .400000006
 ledgeDropHeight: 0
 maxJumpAcrossDistance: 0
 accuratePlacement: 0
 minRegionArea: 2
 widthInaccuracy: 16.666666
 heightInaccuracy: 10
 m_NavMesh: {fileID: 0}
  • Replace this section with the section you copied from SceneB.unity and save the file. (You’ll notice that this only difference is in the m_NavMesh: { fileID: 19400000, guid: 86b949ed892434e22ab739dd2c9ad685, type: 2 } line that points to the actual baked NavMesh. I suggest copy/pasting the whole section though, just in case you changed some default NavMesh baking settings). can cialis make you blind
  • Done ! You should now be able to load SceneB with LoadLevelAdditive, and as long as SceneA was loaded via LoadLevel (or the async equivalent), the current NavMesh will be the correct NavMesh.

I’ve also found that the manually edited changes to SceneA.unity stick, even when you edit and re-save the scene normally from within Unity. Presumably if you clear or rebake the NavMesh when SceneA is loaded, then it will touch the NavMeshSettings section, but it seems to leave it alone otherwise. originalverpackung viagra

And remember – this is a bit of a hack. Unity Technologies probably doesn’t intend the engine to be used this way, so associated bugs are your problem. If you can find a way to make things work acceptably by loading the NavMesh-containing scene using LoadLevel and LoadLevelAsync, do that instead.

One Response to “How to use Unity NavMeshes with LoadLevelAdditive (aka “A Dirty NavMesh Hack”)”

Leave a Reply

best viagra dose

tadalafil troche 20mg

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

cialis original kaufen ohne rezept

comprimido viagra azul

donde venden viagra femenino en chile
buy cialis online without