Unity Editor Plugin for RecastNavigation - Generate navmesh from OBJ files and visualize in Unity Scene.
This Unity package provides a wrapper for RecastNavigation library, allowing you to:
- Generate navigation meshes from OBJ files
- Export navmesh data to binary files
- Visualize navmesh in Unity Scene with gizmos
- Configure navmesh generation parameters through Unity Editor
- OBJ File Loading: Load 3D mesh files in OBJ format
- NavMesh Generation: Generate navigation meshes using RecastNavigation algorithm
- Binary Export: Save generated navmesh to binary files for runtime use
- Scene Visualization: Visualize navmesh polygons in Unity Scene view
- Parameter Configuration: Adjust navmesh generation parameters through UI
- Real-time Preview: See navmesh generation results immediately in the scene
- Copy the
UnityWrapperfolder to your Unity project'sAssetsfolder - Build the native plugin (see Building section below)
- Open Unity and navigate to
Tools > RecastNavigation > Open NavMesh Generator
- Ensure you have Visual Studio 2019 or later installed
- Open Command Prompt in the UnityWrapper directory
- Run
build.bat - The plugin will be built to
Runtime/Plugins/x86_64/
- Create a build directory:
mkdir build && cd build - Configure with CMake:
cmake .. -G "Visual Studio 16 2019" -A x64 - Build:
cmake --build . --config Release
- Open the NavMesh Generator window:
Tools > RecastNavigation > Open NavMesh Generator - Select an OBJ file using the "Browse" button
- Choose an output directory for the generated navmesh
- Adjust generation parameters if needed (see Advanced Settings)
- Click "Generate NavMesh"
- The generated navmesh will be saved as a binary file and visualized in the scene
- Cell Size: Size of voxel cells (default: 0.3)
- Cell Height: Height of voxel cells (default: 0.2)
- Walkable Slope Angle: Maximum slope angle in degrees (default: 45.0)
- Walkable Height: Minimum height for walkable areas (default: 2.0)
- Walkable Radius: Agent radius for pathfinding (default: 0.6)
- Walkable Climb: Maximum height agent can climb (default: 0.9)
- Min Region Area: Minimum area for regions (default: 8.0)
- Merge Region Area: Area threshold for merging regions (default: 20.0)
- Max Simplification Error: Maximum error for polygon simplification (default: 1.3)
- Max Sample Error: Maximum error for height sampling (default: 6)
- Detail Sample Distance: Distance for detail mesh sampling (default: 6.0)
- Detail Sample Max Error: Maximum error for detail sampling (default: 1.0)
The generated navmesh can be visualized in the Unity Scene with:
- NavMesh Outlines: Green lines showing polygon boundaries
- Walkable Areas: Blue filled polygons for walkable regions
- Unwalkable Areas: Red filled polygons for unwalkable regions
- Debug Information: Real-time display of navmesh statistics
UnityWrapper/
├── Editor/
│ ├── RecastNavigationEditor.cs # Main editor window
│ └── NavMeshVisualizerEditor.cs # Visualizer custom editor
├── Runtime/
│ ├── Scripts/
│ │ ├── RecastNavigationWrapper.cs # Native plugin wrapper
│ │ └── NavMeshVisualizer.cs # Scene visualization component
│ └── Plugins/
│ └── x86_64/ # Native plugin binaries
├── Source/
│ ├── UnityPlugin.cpp # Main plugin implementation
│ └── [Other source files] # RecastNavigation source files
├── CMakeLists.txt # Build configuration
├── build.bat # Windows build script
├── package.json # Unity Package Manager manifest
└── README.md # This file
Main wrapper class for interacting with the native RecastNavigation library.
GenerateNavMesh(string objFilePath, string outputPath, ...): Generate navmesh from OBJ fileLoadNavMesh(string filePath): Load navmesh from binary fileUnloadNavMesh(NavMeshData data): Free navmesh dataIsNavMeshValid(NavMeshData data): Check if navmesh data is validLogNavMeshInfo(NavMeshData data): Log navmesh information
Component for visualizing navmesh data in Unity Scene.
SetNavMeshData(NavMeshData data): Set navmesh data for visualizationSetVisualizationSettings(...): Configure visualization appearanceRefreshVisualization(): Refresh the visualizationClearVisualization(): Clear all visualization objects
- Plugin not found: Ensure the native plugin is built and placed in
Runtime/Plugins/x86_64/ - OBJ file loading failed: Check that the OBJ file is valid and accessible
- Build errors: Ensure all dependencies (RecastNavigation libraries) are properly linked
- Visualization not showing: Check that the NavMeshVisualizer component is attached to a GameObject
Enable debug logging in the NavMeshVisualizer component to see detailed information about:
- Navmesh generation progress
- Polygon counts and statistics
- Memory usage
- Error messages
- RecastNavigation library (included)
- Unity 2021.3 or later
- Visual Studio 2019 or later (for building)
This project uses the RecastNavigation library under its original license. See the main project's LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review the Unity console for error messages
- Ensure all dependencies are properly installed
- Create an issue with detailed information about your problem