Ejemplo n.º 1
0
        protected override void OnGUIButtons()
        {
            ControlUtil.BeginButtonArea(Context.ButtonArea);

            if (Context.Build != null)
            {
                GUILayout.FlexibleSpace();
                ControlUtil.OnGUIResetButton(Context, DebugContext, ControlUtil.HighlightedButton);
            }

            ControlUtil.EndButtonArea();
        }
Ejemplo n.º 2
0
        protected override void OnGUIButtons()
        {
            NavmeshBuild build = Context.Build;

            if (!build)
            {
                return;
            }

            if (build.BuildState == NavmeshBuildState.Invalid)
            {
                GUI.Box(Context.ButtonArea, "");
                return;
            }

            bool hasLocalData = (mCompiler != null && mCompiler.HasData);
            bool dataExists   = (build.HasInputData || hasLocalData);
            bool isCompiling  = !(mCompiler == null || mCompiler.IsFinished);

            bool guiEnabled = GUI.enabled;

            GUI.enabled = !isCompiling;

            ControlUtil.BeginButtonArea(Context.ButtonArea);

            float origFVal = build.Config.WalkableSlope;

            GUILayout.Label(NMGenConfig.SlopeLabel);

            build.Config.WalkableSlope = EditorGUILayout.FloatField(build.Config.WalkableSlope);

            if (origFVal != build.Config.WalkableSlope)
            {
                build.IsDirty = true;
            }

            GUILayout.Space(MarginSize);

            string compileButtonText;

            GUIStyle style = (GUI.enabled && !dataExists)
                ? ControlUtil.HighlightedButton : GUI.skin.button;

            if (dataExists)
            {
                compileButtonText = "Recompile";
            }
            else
            {
                compileButtonText = "Compile";
            }

            if (GUILayout.Button(compileButtonText, style))
            {
                GC.Collect();
                Logger.ResetLog();
                mCompiler = new MiniInputCompile(Context);

                if (mCompiler.IsFinished)
                {
                    mCompiler = null;
                }
            }

            if (hasLocalData)
            {
                GUILayout.Space(MarginSize);

                style = (GUI.enabled ? ControlUtil.HighlightedButton : GUI.skin.button);

                if (GUILayout.Button("Accept", style))
                {
                    ApplyData();
                }
            }

            GUI.enabled = guiEnabled;

            if (isCompiling)
            {
                GUILayout.Space(MarginSize);

                if (GUILayout.Button("Cancel Compile"))
                {
                    mCompiler.Abort();
                    mCompiler = null;
                }
            }
            else
            {
                bool resetOK = (hasLocalData || build.HasInputData || build.HasBuildData);

                if (ControlUtil.OnGUIStandardButtons(Context, DebugContext, resetOK))
                {
                    // Reset button clicked.
                    mCompiler = null;
                }
            }

            ControlUtil.EndButtonArea();
        }
Ejemplo n.º 3
0
        protected override void OnGUIButtons()
        {
            DebugContext.SetViews(ViewOption.Mesh);

            NavmeshBuild build = Context.Build;

            if (!build)
            {
                // Build deleted.
                return;
            }

            TileBuildData  tdata  = Context.Build.BuildData;
            TileBuildState bstate = tdata.GetState(0, 0);

            bool canBake =
                (bstate == TileBuildState.Built || bstate == TileBuildState.Baked);

            bool isBuilding = (Context.TaskCount > 0);

            ControlUtil.BeginButtonArea(Context.ButtonArea);

            EditorGUIUtility.LookLikeControls(75);

            bool guiEnabled = GUI.enabled;

            GUI.enabled = !isBuilding;

            GUIStyle style = (canBake || isBuilding)
                ? GUI.skin.button : ControlUtil.HighlightedButton;

            if (GUILayout.Button("Build", style))
            {
                mProgress = 0;

                mLastTime = EditorApplication.timeSinceStartup;

                if (!Context.QueueTask(0, 0, BuildTaskProcessor.LowPriority, Logger))
                {
                    Logger.PostError("Build task failed.", Context.Build);
                }
            }

            GUI.enabled = !isBuilding && canBake;

            style = GUI.enabled
                ? ControlUtil.HighlightedButton : GUI.skin.button;

            if (GUILayout.Button("Bake", style))
            {
                HandleBake();
            }

            GUILayout.Space(ControlUtil.MarginSize);

            GUI.enabled = isBuilding;

            if (GUILayout.Button("Abort Build"))
            {
                Context.AbortAllReqests("User requested.");
            }

            GUI.enabled = guiEnabled;

            if (OnGUIStandardButtons())
            {
                // Special case.  Build was discarded.
                ControlUtil.EndButtonArea();
                return;
            }

            ControlUtil.OnGUIStandardButtons(Context, DebugContext, true);

            ControlUtil.EndButtonArea();
        }
Ejemplo n.º 4
0
 protected override void OnGUIButtons()
 {
     ControlUtil.BeginButtonArea(Context.ButtonArea);
     ControlUtil.EndButtonArea();
 }
Ejemplo n.º 5
0
        protected override void OnGUIButtons()
        {
            DebugContext.SetViews(ViewOption.Grid | ViewOption.Selection | ViewOption.Mesh);

            NavmeshBuild build = Context.Build;

            if (!build)
            {
                return;
            }

            TileBuildData tdata = build.BuildData;

            if (tdata == null)
            {
                return;
            }

            TileSelection selection = Context.Selection;

            bool hasSelection  = selection.Validate();
            bool needBaking    = (tdata.NeedsBakingCount() > 0);
            int  activeCount   = Context.TaskCount;
            int  bakeableCount = tdata.BakeableCount();

            bool origGUIEnabled = GUI.enabled;

            bool guiEnabled = !IsBaseBusy;

            GUI.enabled = guiEnabled;

            ControlUtil.BeginButtonArea(Context.ButtonArea);

            if (GUILayout.Button("Build All"))
            {
                HandleBuildRequest(true);
            }

            GUI.enabled = guiEnabled && hasSelection;

            if (GUILayout.Button("Build Zone"))
            {
                HandleBuildRequest(false);
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            // Only disable baking if there is nothing at all that can be baked.
            GUI.enabled = guiEnabled && activeCount == 0 && (bakeableCount > 0);

            GUIStyle style = (bakeableCount > 0 && activeCount == 0)
                ? ControlUtil.HighlightedButton : GUI.skin.button;

            if (GUILayout.Button("Bake All", style))
            {
                HandleBake();
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            // Note: Technically only the last condition is needed.  But checking the
            // other conditions first saves processing time.
            GUI.enabled = guiEnabled && activeCount == 0 &&
                          tdata.GetStateCount(TileBuildState.NotBuilt) < tdata.Width * tdata.Depth;

            if (GUILayout.Button((needBaking ? "Revert Unbaked" : "Clear All")))
            {
                HandleClear();
            }

            GUI.enabled = guiEnabled && (activeCount != 0);

            if (GUILayout.Button("Abort Builds"))
            {
                Context.AbortAllReqests("User requested.");
            }

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(ControlUtil.MarginSize);

            GUI.enabled = guiEnabled;
            if (OnGUIStandardButtons())
            {
                // Special case.  Build was discarded.
                ControlUtil.EndButtonArea();
                return;
            }

            ///////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            GUI.enabled = guiEnabled && hasSelection;

            EditorGUIUtility.LookLikeControls(100);
            selection.ZoneSize = EditorGUILayout.IntField("Zone Size", selection.ZoneSize);
            EditorGUIUtility.LookLikeControls();

            GUI.enabled = guiEnabled;

            ////////////////////////////////////////////////////////////////////
            GUILayout.Space(MarginSize);

            GUILayout.Label("Bakeable Tiles: " + bakeableCount);

            ControlUtil.OnGUIStandardButtons(Context, DebugContext, true);

            ControlUtil.EndButtonArea();

            GUI.enabled = origGUIEnabled;
        }
Ejemplo n.º 6
0
        protected override void OnGUIButtons()
        {
            NavmeshBuild build = Context.Build;

            if (!build)
            {
                return;
            }

            NMGenConfig config = build.Config;

            // Buttons area.

            ControlUtil.BeginButtonArea(Context.ButtonArea);

            // Standard config buttons.

            OnGUIButtons(build, config, false);

            // Build initialialization buttons.

            bool guiEnabled = GUI.enabled;

            bool targetOK = build.CanLoadFromTarget(null, false);

            GUILayout.Space(MarginSize * 2);

            if (build.BuildState == NavmeshBuildState.Buildable)
            {
                GUI.enabled = (Context.TaskCount == 0);

                if (GUILayout.Button("Reinitialize Builder"))
                {
                    build.DiscardBuildData();
                }
            }
            else if (build.HasInputData)
            {
                if (targetOK)
                {
                    if (GUILayout.Button("Load Target's Config"))
                    {
                        if (!build.SetConfigFromTarget(Logger))
                        {
                            Logger.PostError("Could not load target config.", Context.Build);
                        }
                        Logger.ResetLog();
                    }

                    GUILayout.Space(MarginSize);
                    GUILayout.Label("Initialize Build:");
                    GUILayout.Space(MarginSize);

                    if (GUILayout.Button("From Scratch", ControlUtil.HighlightedButton))
                    {
                        InitializeBuild(false);
                    }

                    if (GUILayout.Button("Based on Target"))
                    {
                        InitializeBuild(true);
                    }

                    GUILayout.Space(MarginSize);
                    GUILayout.Box("Basing your build on the target's navigation"
                                  + " mesh will automatically lock you in to the"
                                  + " target's configuration settings."
                                  , EditorUtil.HelpStyle
                                  , GUILayout.ExpandWidth(true));
                }
                else
                {
                    if (GUILayout.Button("Ready to Build", ControlUtil.HighlightedButton))
                    {
                        InitializeBuild(false);
                    }
                }
            }

            GUI.enabled = guiEnabled;

            ViewOption option = build.HasInputData
                ? (ViewOption.Grid | ViewOption.Input) : 0;

            DebugContext.SetViews(option);

            ControlUtil.OnGUIStandardButtons(Context, DebugContext, true);

            ControlUtil.EndButtonArea();

            if (GUI.changed)
            {
                build.IsDirty = true;
            }
        }