How to do it...

We will create an editor window for easily handling the automation process without weighing down the graph's Start function, thereby delaying the scene loading:

  1. Create the CustomNavMeshWindow class and place it in a directory called Editor:
using UnityEngine; 
using UnityEditor; 
using System.Collections; 
using System.Collections.Generic; 
 
public class CustomNavMeshWindow : EditorWindow 
{ 
    // next steps here 
} 
  1. Add the attributes to the editor window:
static bool isEnabled = false; 
static GameObject graphObj; 
static CustomNavMesh graph; 
static CustomNavMeshWindow window; 
static GameObject graphVertex; 
  1. Implement the function for initializing and showing the window:
[MenuItem("UAIPC/Ch02/CustomNavMeshWindow")] static void ...

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.