Пример #1
0
        public override void OnScene(bool selected)
        {
            #region ProgressBar
            if (CourseBase.BuildSplinesCount != 0)
            {
                float count          = CourseBase.BuildSplinesCount;
                float buildLineCount = CourseBase.BuildLineSplines.Count;
                float buildCount     = CourseBase.BuildSplines.Count;

                float  progress = buildLineCount / count * 0.5f + buildCount / count * 0.5f;
                string text     = "Done";
                if (buildLineCount != 0)
                {
                    text = "Updating " + CourseBase.BuildLineSplines[0].name;
                }
                else if (buildCount != 0)
                {
                    text = "Building " + CourseBase.BuildSplines[0].name;
                }

                if (EditorUtility.DisplayCancelableProgressBar("Build progress bar", text, 1.0f - progress))
                {
                    CourseBase.BuildLineSplines.Clear();
                    CourseBase.BuildSplines.Clear();
                    CourseBase.BuildSplinesCount = 0;
                }
                else
                {
                    SplineBase spline = null;
                    if (CourseBase.BuildLineSplines.Count != 0)
                    {
                        spline = CourseBase.BuildLineSplines[0];
                    }
                    else if (CourseBase.BuildSplines.Count != 0)
                    {
                        spline = CourseBase.BuildSplines[0];
                    }

                    Exception exception = CourseBase.DoSplineBakeStep();
                    if (exception != null)
                    {
                        string message = exception.Message;

                        if (exception.StackTrace.Contains("Poly2Tri.DTSweep.FinalizationPolygon (Poly2Tri.DTSweepContext tcx)"))
                        {
                            message = "Too big extra/shrink.";
                        }
                        if (exception.StackTrace.Contains("New points from triangulation."))
                        {
                            message = "Wrong spline shape or/and lines are crossed.";
                        }
                        if (exception.Message.Contains("stack overflow"))
                        {
                            message = "Too many vertices in one mesh.";
                        }

                        Debug.LogException(exception);
                        if (spline && !string.IsNullOrEmpty(message))
                        {
                            PopupToolUI.Add(message, "Focus", spline.name);
                        }
                    }
                }
                progressBar = true;
            }
            else if (GeoJSON.Exporting)
            {
                float  progress = GeoJSON.Progress;
                string text     = "Done";
                if (progress != 1)
                {
                    text = "Exporting " + (progress * 100).ToString("F2") + "%";
                }

                if (EditorUtility.DisplayCancelableProgressBar("Export progress bar", text, progress))
                {
                    GeoJSON.CancelExport();
                }
                else
                {
                    for (int i = 0; i < 10000; ++i)
                    {
                        GeoJSON.DoExportTerrainStep();
                    }
                }
                progressBar = true;
            }
            else
            {
                if (progressBar)
                {
                    EditorUtility.ClearProgressBar();
                    progressBar = false;
                }
            }
            #endregion

            if (selected)
            {
                OnAutoHide();
                OnAutoTerrain();
                Update();
                if (!HideLines)
                {
                    splineTool.OnScene(SelectedTool == Tool.SplineTool);
                }
                if (!HideLines)
                {
                    plantTool.OnScene(SelectedTool == Tool.PlantTool);
                }
            }

            OnUI(selected);

            if (selected)
            {
                if (!ToolLocked)
                {
                    if (LayerPanel)
                    {
                        layerTool.OnUI(true);
                    }
                    if (InfoPanel)
                    {
                        infoTool.OnUI(true);
                    }
                    if (WarningPanel)
                    {
                        popupTool.OnUI(true);
                    }
                    if (AndroidPanel)
                    {
                        androidTool.OnUI(true);
                    }
                    fileTool.OnUI(SelectedTool == Tool.FileTool);
                    plantTool.OnUI(SelectedTool == Tool.PlantTool);
                    splineTool.OnUI(SelectedTool == Tool.SplineTool);
                }
                HandleUtility.Repaint();
            }

            #region Touch
            BeginUI();
            if (!ToolLocked)
            {
                Touch(1, Screen.height / BoxSize);
            }
            if (SelectedTool != Tool.None)
            {
                Touch(Screen.width / BoxSize - 2, 1);
            }
            EndUI();
            #endregion

            #region Tooltip
            if (!string.IsNullOrEmpty(GUI.tooltip))
            {
                string text = GUI.tooltip;

                Rect rect = new Rect();
                rect.x      = Event.current.mousePosition.x;
                rect.y      = Event.current.mousePosition.y;
                rect.width  = GUI.skin.label.CalcSize(new GUIContent(text)).x;
                rect.height = GUI.skin.label.CalcSize(new GUIContent(text)).y;

                BeginUI();
                MoveToPixels((int)rect.x, (int)rect.y);
                SetBoxSize((int)rect.width, (int)rect.height);
                Background(1, 1, 0.9f);
                LabelNoOffset(text);
                EndUI();
            }
            #endregion
        }