private static Color ToColor(TileBuildState state)
        {
            switch (state)
            {
            case TileBuildState.Baked:

                return(new Color(0.07f, 0.43f, 0.09f));     // Green

            case TileBuildState.Built:

                return(new Color(0.08f, 0.34f, 0.63f));    // Dark blue

            case TileBuildState.Empty:

                return(new Color(0.3f, 0.3f, 0.3f));     // Dark grey

            case TileBuildState.Error:

                return(new Color(0.63f, 0.03f, 0));     // Red

            case TileBuildState.InProgress:

                return(new Color(0.12f, 0.5f, 0.92f));    // Medium blue

            case TileBuildState.NotBuilt:

                return(new Color(0.6f, 0.6f, 0.6f));     // Light grey

            case TileBuildState.Queued:

                return(new Color(0.4f, 0.65f, 0.93f));    // Light blue
            }

            return(Color.white);  // Should never get here.
        }
Exemple #2
0
        internal int GetActive()
        {
            int result = 0;

            foreach (BuildDataItem item in unsafeItems)
            {
                TileBuildState ts = item.TileState;
                result += (ts == TileBuildState.InProgress ||
                           ts == TileBuildState.Queued) ? 1 : 0;
            }

            return(result);
        }
Exemple #3
0
        // This method indicates only that there are tiles that are
        // no longer in their base state.  It doesn't mean that there is
        // anything that can be baked.  (All tiles may be empty.)
        internal int NeedsBakingCount()
        {
            int result = 0;

            foreach (BuildDataItem item in unsafeItems)
            {
                TileBuildState ts = item.TileState;
                result += (ts == TileBuildState.Built || ts == TileBuildState.Empty)
                    ? 1 : 0;
            }

            return(result);
        }
Exemple #4
0
        internal int GetStateCount(TileBuildState state)
        {
            int result = 0;

            foreach (BuildDataItem item in unsafeItems)
            {
                if (item.TileState == state)
                {
                    result++;
                }
            }
            return(result);
        }
Exemple #5
0
        /// <summary>
        /// The number of tiles that contain data that can be baked.
        /// </summary>
        /// <returns>The number of tiles that contain data that can be baked.</returns>
        internal int BakeableCount()
        {
            int result = 0;

            foreach (BuildDataItem item in unsafeItems)
            {
                TileBuildState bstate = item.TileState;
                if (bstate == TileBuildState.Built || bstate == TileBuildState.Baked)
                {
                    result++;
                }
            }

            return(result);
        }
        protected override void OnGUIMain()
        {
            if (mBoxStyle == null)
            {
                mBoxStyle           = new GUIStyle(EditorUtil.HelpStyle);
                mBoxStyle.alignment = TextAnchor.MiddleCenter;
            }

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

            switch (bstate)
            {
            case TileBuildState.NotBuilt:

                ShowStatus("Ready to build.");
                break;

            case TileBuildState.Empty:

                ShowStatus("Build did not produce any results.");
                break;

            case TileBuildState.Queued:

                ShowStatus("Build is queued for background processing.");
                break;

            case TileBuildState.Error:

                ShowStatus("Build failed on error!");
                break;

            case TileBuildState.Baked:

                ShowStatus("Bake completed.");
                break;

            case TileBuildState.Built:

                ShowStatus("Ready to bake.");
                break;

            case TileBuildState.InProgress:

                ShowStatus("Build in progress...");

                Rect area = Context.MainArea;

                area = new Rect(area.x + area.width * 0.25f
                                , area.y + area.height * 0.66f
                                , area.width * 0.50f
                                , 20);

                double now = EditorApplication.timeSinceStartup;

                // Progress will fill up once every 10 seconds.
                // Just something for the user to look at.
                mProgress += (float)(now - mLastTime) * 0.05f;
                mProgress  = (mProgress > 1 ? 0 : mProgress);

                mLastTime = now;

                EditorGUI.ProgressBar(area, mProgress, "");

                break;
            }

            GUILayout.Space(ControlUtil.MarginSize);
            OnGUIMainStandard();
        }
        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();
        }
 internal int GetStateCount(TileBuildState state)
 {
     int result = 0;
     foreach (BuildDataItem item in unsafeItems)
     {
         if (item.TileState == state)
             result++;
     }
     return result;
 }
        private static Color ToColor(TileBuildState state)
        {
            switch (state)
            {
                case TileBuildState.Baked:

                    return new Color(0.07f, 0.43f, 0.09f);  // Green

                case TileBuildState.Built:

                    return new Color(0.08f, 0.34f, 0.63f); // Dark blue

                case TileBuildState.Empty:

                    return new Color(0.3f, 0.3f, 0.3f);  // Dark grey
                    
                case TileBuildState.Error:

                    return new Color(0.63f, 0.03f, 0);  // Red

                case TileBuildState.InProgress:

                    return new Color(0.12f, 0.5f, 0.92f); // Medium blue

                case TileBuildState.NotBuilt:

                    return new Color(0.6f, 0.6f, 0.6f);  // Light grey

                case TileBuildState.Queued:

                    return new Color(0.4f, 0.65f, 0.93f); // Light blue
            }

            return Color.white;  // Should never get here.
        }