Пример #1
0
    private static void OnGUIState(NavmeshBuild build)
    {
        INavmeshData     btarget = build.BuildTarget;
        NavmeshBuildInfo binfo   = (btarget == null ? null : btarget.BuildInfo);

        EditorGUILayout.Separator();

        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        if (build.BuildState == NavmeshBuildState.Invalid)
        {
            if (!(ScriptableObject)btarget)
            {
                sb.AppendLine("No build target.");
            }

            if (build.inputProcessors.Count == 0)
            {
                sb.AppendLine("No input processors.");
            }

            GUILayout.Label(sb.ToString().Trim()
                            , EditorUtil.ErrorStyle, GUILayout.ExpandWidth(true));

            return;
        }

        sb.AppendLine("Input Scene: " + NavEditorUtil.SceneDisplayName(binfo));

        if (build.SceneQuery == null)
        {
            sb.AppendLine("Search scope: Entire scene");
        }

        if (build.TargetHasNavmesh)
        {
            sb.AppendLine("Target has existing navmesh.");
        }
        else
        {
            sb.AppendLine("Target does not have a navmesh.");
        }

        if (build.BuildType == NavmeshBuildType.Advanced)
        {
            TileBuildData tdata = build.BuildData;
            sb.AppendLine("Build state: " + build.BuildState);
            sb.AppendLine("Active builds: "
                          + (tdata == null ? 0 : build.BuildData.GetActive()));
        }

        GUILayout.Label(sb.ToString().Trim()
                        , EditorUtil.HelpStyle
                        , GUILayout.ExpandWidth(true));


        if (NavEditorUtil.SceneMismatch(binfo))
        {
            GUILayout.Box("Current scene does not match last input scene."
                          , EditorUtil.WarningStyle
                          , GUILayout.ExpandWidth(true));
        }

        EditorGUILayout.Separator();

        GUI.enabled = (btarget != null);

        NavmeshSceneDraw.Instance.OnGUI(build.BuildTarget, "Show Mesh", true, true);

        GUI.enabled = true;

        return;
    }
Пример #2
0
        protected override void OnGUIMain()
        {
            NavmeshBuild build = Context.Build;

            if (!build)
            {
                return;
            }

            Rect statusArea = Context.MainArea;

            if (build.BuildState == NavmeshBuildState.Invalid)
            {
                return;
            }

            InputBuildInfo info;
            InputGeometry  geometry       = null;
            ConnectionSet  connections    = null;
            int            triCount       = 0;
            int            processorCount = 0;

            ViewOption viewFlags = 0;
            bool       hasData   = false;

            string topLabel;

            if (mCompiler != null)
            {
                if (mCompiler.IsFinished)
                {
                    if (mCompiler.HasData)
                    {
                        topLabel = "Input successfully compiled. (Needs to be accepted.)";
                    }
                    else
                    {
                        topLabel = "No input data produced.";
                    }
                }
                else
                {
                    topLabel = "Compiling";
                }

                info           = mCompiler.Info;
                geometry       = mCompiler.Geometry;
                connections    = mCompiler.Connections;
                triCount       = mCompiler.TriCount;
                processorCount = (mCompiler.Processors == null ? 0 : mCompiler.Processors.Length);

                if (geometry != null)
                {
                    hasData = true;
                }
            }
            else if (build.HasInputData)
            {
                topLabel = "Current Input";

                viewFlags = (ViewOption.Input | ViewOption.Grid);

                info           = build.InputInfo;
                geometry       = build.InputGeom;
                connections    = build.Connections;
                triCount       = geometry.TriCount;
                processorCount = build.NMGenProcessors.Count;

                hasData = true;
            }
            else
            {
                topLabel = "Input needs to be compiled.";
                info     = new InputBuildInfo();
            }

            DebugContext.SetViews(viewFlags);

            if (!hasData && triCount > 0)
            {
                GUI.Box(Context.MainArea
                        , string.Format("{0} {1:N0} triangles", topLabel, triCount)
                        , EditorUtil.HelpStyle);

                OnGUICompiler(statusArea);

                return;
            }

            GUILayout.BeginArea(statusArea, GUI.skin.box);

            string currScene = System.IO.Path.GetFileName(SceneManager.GetActiveScene().path);

            int idx = currScene.LastIndexOf(".");

            if (idx >= 0)
            {
                currScene = currScene.Substring(0, idx);
            }

            if (currScene.Length == 0)
            {
                currScene = "None";
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label("Input scene:");

            GUILayout.Label(" Current: " + currScene);

            GUILayout.Label(" Last: "
                            + NavEditorUtil.SceneDisplayName(build.BuildTarget.BuildInfo));

            GUILayout.EndHorizontal();

            if (NavEditorUtil.SceneMismatch(build.BuildTarget.BuildInfo))
            {
                GUILayout.Box("Current scene does not match last input scene."
                              , EditorUtil.WarningStyle);
            }

            GUILayout.Space(MarginSize);

            GUILayout.Label(topLabel);

            if (hasData)
            {
                GUILayout.Space(ControlUtil.MarginSize * 3);

                GUILayout.BeginHorizontal();

                GUILayout.BeginVertical();

                GUILayout.Label("Geometry");

                GUILayout.Space(ControlUtil.MarginSize);

                GUILayout.Label(string.Format("Triangles: {0:N0}", triCount));

                GUILayout.Space(ControlUtil.MarginSize);

                GUILayout.Label("Min Bounds: " + Vector3Util.ToString(geometry.BoundsMin));

                GUILayout.Label("Max Bounds: " + Vector3Util.ToString(geometry.BoundsMax));

                GUILayout.Space(ControlUtil.MarginSize);

                UnityEngine.Vector3 diff = (geometry.BoundsMax - geometry.BoundsMin).ToUnityVector3();
                GUILayout.Label(string.Format("WxHxD: {0:f3} x {1:f3} x {2:f3}"
                                              , diff.x, diff.y, diff.z));

                GUILayout.Space(ControlUtil.MarginSize * 2);

                // Note: The build press interprets zero root objects as a global search.

                GUILayout.Space(ControlUtil.MarginSize);
                GUILayout.Label("Components");
                GUILayout.Space(ControlUtil.MarginSize);

                GUILayout.Label("Pre-filter: " + info.compCountPre);
                GUILayout.Label("Post-filter: " + info.compCountPost);

                GUILayout.EndVertical();

                GUILayout.BeginVertical();

                GUILayout.Label("Modifiers");

                GUILayout.Space(ControlUtil.MarginSize);

                GUILayout.Label("Component loaders: " + info.loaderCount);
                GUILayout.Label("Component filters: " + info.filterCount);
                GUILayout.Label("Area assignment: " + info.areaModifierCount);
                GUILayout.Label("Component compilers: " + info.compilerCount);
                GUILayout.Label("Input post-processors: " + info.postCount);
                GUILayout.Label("NMGen processors: " + processorCount);
                GUILayout.Label("Off-Mesh connections: " + connections.Count);

                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            }

            GUILayout.EndArea();

            OnGUICompiler(statusArea);
        }
Пример #3
0
    /// <summary>
    /// Controls behavior of the inspector.
    /// </summary>
    public override void OnInspectorGUI()
    {
        CAIBakedNavmesh targ = (CAIBakedNavmesh)target;

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Status", (targ.HasNavmesh ? "Has mesh" : "Empty"));
        EditorGUILayout.LabelField("Version", targ.Version.ToString());
        EditorGUILayout.LabelField("Input Scene", NavEditorUtil.SceneDisplayName(targ.BuildInfo));

        EditorGUILayout.Separator();

        NavmeshSceneDraw.Instance.OnGUI(targ, "Show Mesh", true, true);

        EditorGUILayout.Separator();

        EditorGUILayout.BeginHorizontal();

        GUI.enabled = targ.HasNavmesh;
        if (GUILayout.Button("Save"))
        {
            string filePath = EditorUtility.SaveFilePanel(
                "Save Navigation Mesh"
                , ""
                , targ.name
                , "navmesh");
            SaveMesh(targ, filePath);
        }
        GUI.enabled = true;

        if (GUILayout.Button("Load"))
        {
            string filePath = EditorUtility.OpenFilePanel(
                "Select Serialized Navmesh"
                , ""
                , "navmesh");
            if (LoadMesh(targ, filePath))
            {
                GUI.changed = true;
            }
        }

        EditorGUILayout.EndHorizontal();

        if (targ.HasNavmesh)
        {
            EditorGUILayout.Separator();

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

        EditorGUILayout.Separator();

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