Skip to content

Commit

Permalink
Fixed bug where prefab instances with a CustomNavMeshAgent attached w…
Browse files Browse the repository at this point in the history
…ould lose the hiddenAgentGameObject reference on script reload
  • Loading branch information
jadvrodrigues committed Dec 18, 2020
1 parent 3e94e77 commit c0faf1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Assets/CustomNavMesh/Scripts/CustomNavMeshAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,13 @@ void TryCreatingHiddenAgent()
var staticFlags = GameObjectUtility.GetStaticEditorFlags(gameObject);
GameObjectUtility.SetStaticEditorFlags(hiddenObject, staticFlags);
#else
hiddenObject.isStatic = gameObject.isStatic;
hiddenObject.isStatic = gameObject.isStatic;
#endif
HiddenAgent = hiddenObject.AddComponent<HiddenNavMeshAgent>();
// set dirty; otherwise, if it's part of a prefab instance and scripts are
// reloaded, the hiddenAgentGameObject reference will be lost
EditorUtility.SetDirty(this);

HiddenAgent.LinkWithCustomAgent(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.3"
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
},
Expand Down

0 comments on commit c0faf1b

Please sign in to comment.