- Home /
Finding navmesh layer dynamically during runtime on Android
I need to find the navmesh layer of objects during runtime for various reasons.
The way to do this normally is using the GameObjectUtility method GetNavMeshLayer. The problem here is that GameObjectutility is a part of the UnityEditor namespace, which is not available on Android builds.
Does anyone have an idea of how I could grab the layers dynamically without the UnityEditor namespace available? I really don't want to add a public field with "my navmesh layer" to every object that needs to modify the walkability of it's own layer.
Answer by Baste · Sep 26, 2014 at 09:04 PM
Aaaand if anyone finds this and cries "I need an answer too!", fear not:
I looped through all possible layers with NavMesh.FindClosestEdge, and grabbed the one that matched:
NavMeshHit hit;
for (int i = 0; i < 32; i++)
{
if (NavMesh.FindClosestEdge(object.transform.position, out hit, (1 << i)))
{
objectLayer = i;
}
}
Worst hack in my life.
Your answer
Follow this Question
Related Questions
Unable to complete SSL connection 0 Answers
Project scripts stop working after building it in Android 1 Answer
Significant frame drop when switching to Android platform 1 Answer
Need to Include a file in the build and use it in the runtime 0 Answers
Automatic conversion packagename(Android) in Project setting. 0 Answers