private void OnDisable( ) { _navInstance.Remove( ); FlockHandler.Instance.DestroyAgents( ); NavMeshReady = false; }
void OnDisable() { // Unload navmesh and clear handle m_Instance.Remove(); }
public void RemoveData() { m_NavMeshDataInstance.Remove(); m_NavMeshDataInstance = new NavMeshDataInstance(); }
private void OnDisable() { navMeshInstance.Remove(); }
protected void clear() { navMeshInstance.Remove(); }
void OnDisable() { m_Instance.Remove(); RemoveTracking(); }
private void OnDisable() { _instance.Remove(); }
private void OnDisable() { navMeshDataInstance.Remove(); StopAllCoroutines(); }
private void OnDisable() { buildOperation = null; dataInstance.Remove(); }
void OnDisable() { navInstance.Remove(); }
public void removeNavMesh() { navMeshDataInstance.Remove(); }
//List<NavMeshBuildSource> m_Sources = new List<NavMeshBuildSource>(); void OnEnable() { main = this; // Construct and add navmesh if (meshOrigin == null) { meshOrigin = transform; } //Bounds bounds = new Bounds(new Vector3(meshOrigin.position.x, meshOrigin.position.y, meshOrigin.position.y), new Vector3(buildSize.x, buildSize.y, buildSize.y)); // navmesh space bounds Bounds bounds = new Bounds(meshOrigin.position, new Vector3(buildSize.x, buildSize.y, buildSize.y)); NavMeshBuildSettings buildSettings = NavMesh.GetSettingsByID(0); float defaultAgentRadius = buildSettings.agentRadius; buildSettings.agentRadius = 0.01f; List <NavMeshBuildSource> navSources = PolygonNavmeshObstacle.Collect(); navSources.Add(generateWalkablePlane()); //rotation from XY plane to XZ plane for (int i = 0; i < navSources.Count; i++) { Matrix4x4 transformation = navSources[i].transform; Vector4 verticalDirection = transformation.GetRow(1); transformation.SetRow(1, transformation.GetRow(2)); transformation.SetRow(2, verticalDirection); //these structs are pass by value, apperently? NavMeshBuildSource buildSource = navSources[i]; buildSource.transform = transformation; navSources[i] = buildSource; } //triangulation breaks and returns vectors with only an x component if we create the navmesh in the XY plane, so we need to do it in the XZ plane then tranform the result. m_NavMesh = NavMeshBuilder.BuildNavMeshData(buildSettings, navSources, bounds, Vector3.zero, Quaternion.identity);//Quaternion.LookRotation(-Vector3.up, Vector3.forward)); m_Instance = NavMesh.AddNavMeshData(m_NavMesh); //calculate reachability navSources.Clear(); buildSettings.agentRadius = defaultAgentRadius - buildSettings.agentRadius; //bounds = new Bounds(meshOrigin.position, new Vector3(buildSize.x, buildSize.y, buildSize.y)); NavMeshTriangulation triangulation = NavMesh.CalculateTriangulation(); //do de-duping on vertices Dictionary <Vector3, int> positionToNewIndex = new Dictionary <Vector3, int>(); for (int i = 0; i < triangulation.vertices.Length; i++) { Vector3 vertexPosition = Quantize(triangulation.vertices[i], vectorPrecision); //round to one decimal place if (!positionToNewIndex.ContainsKey(vertexPosition)) { positionToNewIndex[vertexPosition] = positionToNewIndex.Count; } } Vector3[] deDupedVertices = new Vector3[positionToNewIndex.Count]; foreach (KeyValuePair <Vector3, int> vertexEntry in positionToNewIndex) { deDupedVertices[vertexEntry.Value] = vertexEntry.Key; } int[] triangleIndices = new int[triangulation.indices.Length]; for (int i = 0; i < triangulation.indices.Length; i++) { Vector3 vertexPosition = Quantize(triangulation.vertices[triangulation.indices[i]], vectorPrecision); triangleIndices[i] = positionToNewIndex[vertexPosition]; } HashSet <int> reachableVertices; navSources.Add(generateReachableArea(deDupedVertices, triangleIndices, out reachableVertices)); if (includeUnreachableAreas) { navSources.Add(generateUnreachableArea(deDupedVertices, triangleIndices, reachableVertices)); } //rotation from XZ plane to XY plane for (int i = 0; i < navSources.Count; i++) { Matrix4x4 transformation = navSources[i].transform; Vector4 verticalDirection = transformation.GetRow(1); transformation.SetRow(1, transformation.GetRow(2)); transformation.SetRow(2, verticalDirection); //these structs are pass by value, apperently? NavMeshBuildSource buildSource = navSources[i]; buildSource.transform = transformation; navSources[i] = buildSource; } m_Instance.Remove(); m_NavMesh = NavMeshBuilder.BuildNavMeshData(buildSettings, navSources, bounds, Vector3.zero, Quaternion.LookRotation(-Vector3.up, Vector3.forward)); //replace the old navmesh with the new one ///* m_Instance = NavMesh.AddNavMeshData(m_NavMesh); //*/ }
public void Reset() { navMeshTargets.Clear(); navMeshDataInstance.Remove(); }