Example #1
0
    /// <summary>
    /// Controls behavior of the inspector.
    /// </summary>
    public override void OnInspectorGUI()
    {
        NavmeshBuild targ = (NavmeshBuild)target;

        EditorGUIUtility.LookLikeControls(100);

        OnGUIState(targ);

        GUI.enabled = !targ.HasBuildData;

        EditorGUILayout.Separator();

        targ.BuildTarget = NavEditorUtil.OnGUINavmeshDataField("Bake Target", targ.BuildTarget);

        EditorGUILayout.Separator();

        NavmeshBuildType buildType = (NavmeshBuildType)
                                     EditorGUILayout.EnumPopup("Build Type", targ.BuildType);

        if (buildType != targ.BuildType)
        {
            targ.BuildType = buildType;
            if (buildType == NavmeshBuildType.Advanced)
            {
                BuildSelector.Instance.Select(targ);
            }
        }

        EditorGUILayout.Separator();

        TileBuildData tdata = targ.BuildData;

        GUI.enabled = (tdata == null && targ.TargetHasNavmesh);

        if (GUILayout.Button("Log Mesh State"))
        {
            Debug.Log(targ.BuildTarget.GetMeshReport());
        }

        GUI.enabled = true;

        switch (targ.BuildType)
        {
        case NavmeshBuildType.Standard:
            OnGUIStandard(targ);
            break;

        case NavmeshBuildType.Advanced:
            OnGUIAdvanced(targ);
            break;
        }

        EditorGUILayout.Separator();

        bool orig = mShowInputConfig;

        mShowInputConfig = EditorGUILayout.Foldout(mShowInputConfig, "Input Configuration");
        if (orig != mShowInputConfig)
        {
            EditorPrefs.SetBool(ShowInputKey, mShowInputConfig);
        }

        EditorGUIUtility.LookLikeControls();

        if (mShowInputConfig)
        {
            GUI.enabled = !targ.HasBuildData;

            EditorGUILayout.Separator();

            targ.AutoCleanGeometry = EditorGUILayout.Toggle("Auto-Clean", targ.AutoCleanGeometry);

            EditorGUILayout.Separator();

            ScriptableObject so  = (ScriptableObject)targ.SceneQuery;
            ScriptableObject nso = (ScriptableObject)EditorGUILayout.ObjectField(
                "Scene Query"
                , so
                , typeof(ScriptableObject)
                , false);

            if (nso != so)
            {
                if (!nso || nso is ISceneQuery)
                {
                    targ.SceneQuery = (ISceneQuery)nso;
                }
                else
                {
                    Debug.LogError(string.Format("{0} does not implement {1}."
                                                 , nso.name, typeof(ISceneQuery).Name));
                }
            }

            EditorGUILayout.Separator();

            if (OnGUIManageProcessorList(targ.inputProcessors))
            {
                targ.IsDirty = true;
            }

            GUI.enabled = true;
        }

        EditorGUILayout.Separator();

        if (targ.IsDirty)
        {
            EditorUtility.SetDirty(target);
            targ.IsDirty = false;
        }
    }
    /// <summary>
    /// Controls behavior of the inspector.
    /// </summary>
    public override void OnInspectorGUI()
    {
        NavManagerProvider targ = (NavManagerProvider)target;

        INavmeshData navmeshData = targ.NavmeshData;

        string msg = "";

        if (navmeshData == null || !navmeshData.HasNavmesh)
        {
            msg = "No navigation mesh.\n";
        }

        if (!targ.AvoidanceSet)
        {
            msg += "No avoidance set.\n";
        }

        if (!targ.AgentGroups)
        {
            msg += "No agent groups.\n";
        }

        if (msg.Length > 0)
        {
            GUILayout.Box(msg.Trim(), EditorUtil.ErrorStyle, GUILayout.ExpandWidth(true));
        }

        EditorGUILayout.Separator();

        bool bv = EditorGUILayout.Toggle("Show Mesh", targ.DebugEnabled);

        if (bv != targ.DebugEnabled)
        {
            if (bv)
            {
                // Turn off asset draw.
                org.critterai.nav.u3d.editor.NavmeshSceneDraw.Instance.Hide();
            }

            targ.DebugEnabled = bv;
        }

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Navigation Settings");

        EditorGUILayout.Separator();

        targ.NavmeshData = NavEditorUtil.OnGUINavmeshDataField("Navmesh Data", targ.NavmeshData);

        targ.AgentGroups = (AgentGroupSettings)EditorGUILayout.ObjectField(
            "Agent Groups", targ.AgentGroups, typeof(AgentGroupSettings), false);

        EditorGUILayout.Separator();

        targ.MaxQueryNodes       = EditorGUILayout.IntField("Max Query Nodes", targ.MaxQueryNodes);
        targ.MaxPathSize         = EditorGUILayout.IntField("Max Path Size", targ.MaxPathSize);
        targ.MaxStraightPathSize =
            EditorGUILayout.IntField("Max Straight Path", targ.MaxStraightPathSize);

        targ.MaxAgents = EditorGUILayout.IntField("Max Nav Agents", targ.MaxAgents);

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Crowd Settings");

        EditorGUILayout.Separator();

        targ.MaxCrowdAgents = EditorGUILayout.IntField("Max Crowd Agents", targ.MaxCrowdAgents);
        targ.MaxAgentRadius = EditorGUILayout.FloatField("Max Agent Radius", targ.MaxAgentRadius);

        EditorGUILayout.Separator();

        targ.AvoidanceSet = (CrowdAvoidanceSet)EditorGUILayout.ObjectField(
            "Avoidance Set", targ.AvoidanceSet, typeof(CrowdAvoidanceSet), false);

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Accuracy Settings");

        EditorGUILayout.Separator();

        targ.Extents     = EditorGUILayout.Vector3Field("Extents", targ.Extents);
        targ.WideExtents = EditorGUILayout.Vector3Field("Wide Extents", targ.WideExtents);

        EditorGUILayout.Separator();

        targ.RadiusAt        = EditorGUILayout.FloatField("Radius At", targ.RadiusAt);
        targ.RadiusNear      = EditorGUILayout.FloatField("Radius Near", targ.RadiusNear);
        targ.HeightTolerance = EditorGUILayout.FloatField("Height Tolerance", targ.HeightTolerance);

        EditorGUILayout.Separator();

        targ.TurnThreshold = EditorGUILayout.FloatField("Turn Threshold", targ.TurnThreshold);
        targ.AngleAt       = EditorGUILayout.FloatField("Angle At", targ.AngleAt);

        EditorGUILayout.Separator();

        EditorGUILayout.Separator();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }