void Reset()
 {
     GUIUtility.hotControl = 0;
     measuring             = false;
     readyToMeasure        = false;
     measureToolActive     = false;
     utils.RepaintSceneView();
     utils.RepaintEditorWindow();
 }
        void CompleteGuideCreation()
        {
            if (creatingHGuide)
            {
                if (state.snapGuideToInt)
                {
                    int contextY = Mathf.RoundToInt(utils.GetWorldToContextY(liveGuide.y));
                    liveGuide.y = utils.GetContextToWorldY(contextY);
                }

                // pure zero is reserved for logical testing
                if (liveGuide.y == 0)
                {
                    liveGuide.y = Globals.FALSE_ZERO;
                }

                state.hGuides.Add(liveGuide.y.ToString());
            }
            else
            {
                if (state.snapGuideToInt)
                {
                    int contextX = Mathf.RoundToInt(utils.GetWorldToContextX(liveGuide.x));
                    liveGuide.x = utils.GetContextToWorldX(contextX);
                }

                // pure zero is reserved for logical testing
                if (liveGuide.x == 0)
                {
                    liveGuide.x = Globals.FALSE_ZERO;
                }

                state.vGuides.Add(liveGuide.x.ToString());
            }

            liveGuide           = Vector2.zero;
            creatingHGuide      = false;
            creatingVGuide      = false;
            state.displayGuides = true;
            utils.RepaintEditorWindow();
        }
        public void SelectionUpdated()
        {
            guideSnapEnabled = (selection.GetSelection().Count > 0) ? true : false;
            alignEnabled     = (selection.GetSelection().Count > 1) ? true : false;
            distroEnabled    = (selection.GetSelection().Count > 2) ? true : false;
            spaceEnabled     = (selection.GetSelection().Count > 1) ? true : false;

            if (R2DE_EditorWindow.Instance != null)
            {
                utils.RepaintEditorWindow();
            }
        }
        public void DrawGUI()
        {
            // grab data
            R2DC_Settings controller   = R2DC_Settings.Instance;
            List <string> contextNames = controller.contextNames;

            // title
            drawing.BeginEditorHorizontal();
            drawing.DrawPanelTitle(R2DD_Lang.titleRulerSettings, resources.panelSettings);
            drawing.FlexibleSpace();

            if (drawing.DrawImageButton(resources.help))
            {
                Help.BrowseURL(R2DD_Resources.urlSettingsHelp);
            }
            ;

            drawing.EndEditorHorizontal();

            // Not in 2d error
            if (!utils.IsSceneViewIn2D())
            {
                drawing.DrawErrorBox(R2DD_Lang.sceneModeError);

                drawing.DrawSpace(9f);

                if (drawing.DrawButton(R2DD_Lang.set2DSceneMode))
                {
                    utils.Set2DMode();
                    utils.RepaintSceneView();
                }

                utils.RepaintEditorWindow();
                return;
            }

            // context
            drawing.DrawPanelLabel(R2DD_Lang.context);

            int oldContextInstanceId = state.context.instanceId;
            int contextIndex         = drawing.DrawPopup(controller.contextIndex, contextNames.ToArray());
            int newContextInstanceId = controller.availableContexts[contextIndex].instanceId;

            if (oldContextInstanceId != newContextInstanceId)
            {
                controller.SetContext(contextIndex);
                utils.RepaintSceneView();
            }

            drawing.DrawSpace(9f);

            // show coordinates
            bool oldDisplayCoords = state.displayCoords;

            state.displayCoords = drawing.DrawToggleWithWidth(R2DD_Lang.displaySelectedCoords, state.displayCoords, toggleWidth);

            if (oldDisplayCoords != state.displayCoords)
            {
                utils.RepaintSceneView();
            }

            // prefer colliders
            state.preferColliders = drawing.DrawToggleWithWidth(R2DD_Lang.preferColliders, state.preferColliders, toggleWidth);

            // show/hide guides
            bool oldDisplayGuides = state.displayGuides;

            state.displayGuides = drawing.DrawToggleWithWidth(R2DD_Lang.displayGuides, state.displayGuides, toggleWidth);

            if (oldDisplayGuides != state.displayGuides)
            {
                utils.RepaintSceneView();
            }

            // lock guides
            bool oldLockGuides = state.lockGuides;

            state.lockGuides = drawing.DrawToggleWithWidth(R2DD_Lang.lockGuides, state.lockGuides, toggleWidth);

            if (oldLockGuides != state.lockGuides)
            {
                utils.RepaintSceneView();
            }

            // snap guide to int
            state.snapGuideToInt = drawing.DrawToggleWithWidth(R2DD_Lang.snapGuideToInt, state.snapGuideToInt, toggleWidth);

            // use edges for snapping
            state.snapEdges = drawing.DrawToggleWithWidth(R2DD_Lang.lblUseEdgesForSnap, state.snapEdges, toggleWidth);
        }
Пример #5
0
        public void DrawGUI()
        {
            bool alignEnabled = movement.alignEnabled;

            // title
            drawing.BeginEditorHorizontal();
            drawing.DrawPanelTitle(R2DD_Lang.titleToolbox, resources.panelToolbox);
            drawing.FlexibleSpace();

            if (drawing.DrawImageButton(resources.help))
            {
                Help.BrowseURL(resources.urlToolboxHelp);
            }
            ;
            drawing.EndEditorHorizontal();

            // Not in 2d error
            if (!utils.IsSceneViewIn2D())
            {
                drawing.DrawErrorBox(R2DD_Lang.sceneModeError);

                drawing.DrawSpace(9f);
                if (drawing.DrawButton(R2DD_Lang.set2DSceneMode))
                {
                    utils.Set2DMode();
                    utils.RepaintSceneView();
                }

                utils.RepaintEditorWindow();
                return;
            }

            // align tools
            drawing.DrawCenteredLabel(R2DD_Lang.lblAlign);

            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            drawing.DrawSpace(4f);
            if (drawing.DrawToolButton(resources.alignTop, alignEnabled, R2DD_Lang.tipAlignTop))
            {
                movement.AlignTop();
            }
            if (drawing.DrawToolButton(resources.alignYMid, alignEnabled, R2DD_Lang.tipAlignHMid))
            {
                movement.AlignYMid();
            }
            if (drawing.DrawToolButton(resources.alignBot, alignEnabled, R2DD_Lang.tipAlignBot))
            {
                movement.AlignBot();
            }
            if (drawing.DrawToolButton(resources.alignLeft, alignEnabled, R2DD_Lang.tipAlignLeft))
            {
                movement.AlignLeft();
            }
            if (drawing.DrawToolButton(resources.alignXMid, alignEnabled, R2DD_Lang.tipAlignVMid))
            {
                movement.AlignXMid();
            }
            if (drawing.DrawToolButton(resources.alignRight, alignEnabled, R2DD_Lang.tipAlignRight))
            {
                movement.AlignRight();
            }
            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();

            // Distribute tools
            bool distroEnabled = movement.distroEnabled;

            drawing.DrawSpace(6f);
            drawing.DrawCenteredLabel(R2DD_Lang.lblDistribute);

            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            drawing.DrawSpace(4f);
            if (drawing.DrawToolButton(resources.distroTop, distroEnabled, R2DD_Lang.tipDistTop))
            {
                movement.DistroTop();
            }

            if (drawing.DrawToolButton(resources.distroYMid, distroEnabled, R2DD_Lang.tipDistYMid))
            {
                movement.DistroYMid();
            }

            if (drawing.DrawToolButton(resources.distroBot, distroEnabled, R2DD_Lang.tipDistBot))
            {
                movement.DistroBot();
            }

            if (drawing.DrawToolButton(resources.distroLeft, distroEnabled, R2DD_Lang.tipDistLeft))
            {
                movement.DistroLeft();
            }

            if (drawing.DrawToolButton(resources.distroXMid, distroEnabled, R2DD_Lang.tipDistXMid))
            {
                movement.DistroXMid();
            }

            if (drawing.DrawToolButton(resources.distroRight, distroEnabled, R2DD_Lang.tipDistRight))
            {
                movement.DistroRight();
            }
            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();

            // Spacing tools
            bool spaceEnabled = movement.spaceEnabled;

            drawing.DrawSpace(6f);
            drawing.DrawCenteredLabel(R2DD_Lang.lblSpace);

            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            bool spaceXPressed = drawing.DrawToolButton(resources.spaceX, spaceEnabled, R2DD_Lang.tipSpaceX);

            drawing.BeginEditorVertical();
            drawing.DrawSpace(9f);
            state.spaceX = drawing.DrawFloatFieldWithWidth("", state.spaceX);
            drawing.EndEditorVertical();

            if (spaceXPressed)
            {
                movement.SpaceX(state.spaceX);
            }

            bool spaceYPressed = drawing.DrawToolButton(resources.spaceY, spaceEnabled, R2DD_Lang.tipSpaceY);

            drawing.BeginEditorVertical();
            drawing.DrawSpace(9f);
            state.spaceY = drawing.DrawFloatFieldWithWidth("", state.spaceY);
            drawing.EndEditorVertical();

            if (spaceYPressed)
            {
                movement.SpaceY(state.spaceY);
            }

            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();

            // Guide Snap Tool
            bool guideSnapEnabled = movement.guideSnapEnabled;

            drawing.DrawSpace(6f);
            drawing.DrawCenteredLabel(R2DD_Lang.lblSnapToGuide);

            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            drawing.DrawSpace(4f);

            bool leftRightEnabled = state.vGuides.Count > 0 && guideSnapEnabled && state.displayGuides ? true : false;
            bool topDownEnabled   = state.hGuides.Count > 0 && guideSnapEnabled && state.displayGuides ? true : false;

            if (drawing.DrawToolButton(resources.snapLeft, leftRightEnabled, R2DD_Lang.tipSnapLeft))
            {
                movement.SnapLeft();
            }

            if (drawing.DrawToolButton(resources.snapRight, leftRightEnabled, R2DD_Lang.tipSnapRight))
            {
                movement.SnapRight();
            }

            if (drawing.DrawToolButton(resources.snapTop, topDownEnabled, R2DD_Lang.tipSnapTop))
            {
                movement.SnapTop();
            }

            if (drawing.DrawToolButton(resources.snapBot, topDownEnabled, R2DD_Lang.tipSnapBot))
            {
                movement.SnapBot();
            }

            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();


            // Measure
            drawing.DrawSpace(6f);
            drawing.DrawCenteredLabel(R2DD_Lang.lblMeasure);

            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            drawing.DrawSpace(4f);

            Texture measureButton = measure.IsMeasureToolActive() ? resources.measureActive : resources.measureInactive;

            if (drawing.DrawToolButton(measureButton, true, R2DD_Lang.tipMeasure))
            {
                measure.ToggleMeasureTool();
            }

            if (drawing.DrawToolButton(resources.measureObj, measure.IsMeasureObjEnabled(), R2DD_Lang.tipMeasureObj))
            {
                measure.MeasureObj();
            }

            if (drawing.DrawToolButton(resources.clearMeasure, true, R2DD_Lang.tipClearMeasure))
            {
                measure.ClearMeasureTool();
            }

            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();

            // clear guides
            drawing.DrawSpace(9f);
            if (drawing.DrawButton(R2DD_Lang.clearGuides))
            {
                state.hGuides.Clear();
                state.vGuides.Clear();
                utils.RepaintSceneView();
            }

            // tip
            drawing.DrawSpace(4f);
            if (movement.error == R2DC_Movement.ADError.NGUIContext)
            {
                drawing.DrawErrorBox(R2DD_Lang.nguiInvalidContext);
            }
            else if (movement.error == R2DC_Movement.ADError.NGUIReflection)
            {
                drawing.DrawErrorBox(R2DD_Lang.nguiError);
            }
            else if (movement.error == R2DC_Movement.ADError.CanvasContext)
            {
                drawing.DrawErrorBox(R2DD_Lang.canvasInvalidContext);
            }
            else
            {
                drawing.DrawHelpBox(R2DD_Lang.guideHelp);
            }

            // logo
            drawing.FlexibleSpace();
            drawing.BeginEditorHorizontal();
            drawing.FlexibleSpace();
            drawing.DrawPanelTexture(resources.logo);
            drawing.FlexibleSpace();
            drawing.EndEditorHorizontal();
            drawing.DrawSpace(5f);
        }
        public void DrawGUI()
        {
            // title
            drawing.BeginEditorHorizontal();
            drawing.DrawPanelTitle(R2DD_Lang.titleGrid, resources.panelGrid);
            drawing.FlexibleSpace();

            if (drawing.DrawImageButton(resources.help))
            {
                Help.BrowseURL(R2DD_Resources.urlGridHelp);
            }
            ;

            drawing.EndEditorHorizontal();

            // Not in 2d error
            if (!utils.IsSceneViewIn2D())
            {
                drawing.DrawErrorBox(R2DD_Lang.sceneModeError);

                drawing.DrawSpace(9f);

                if (drawing.DrawButton(R2DD_Lang.set2DSceneMode))
                {
                    utils.Set2DMode();
                    utils.RepaintSceneView();
                }

                utils.RepaintEditorWindow();
                return;
            }


            // enable grid
            bool oldGridEnabled = state.gridEnabled;

            state.gridEnabled = drawing.DrawToggle(R2DD_Lang.gridEnabled, state.gridEnabled);

            if (oldGridEnabled != state.gridEnabled)
            {
                utils.RepaintSceneView();
            }

            // grid columns
            int oldGridCols = state.gridCols;

            state.gridCols = drawing.DrawIntField(R2DD_Lang.gridCols, state.gridCols);

            if (state.gridCols < 2)
            {
                state.gridCols = 2;
            }

            if (oldGridCols != state.gridCols)
            {
                utils.RepaintSceneView();
            }

            // grid rows
            int oldGridRows = state.gridRows;

            state.gridRows = drawing.DrawIntField(R2DD_Lang.gridRows, state.gridRows);

            if (state.gridRows < 2)
            {
                state.gridRows = 2;
            }

            if (oldGridRows != state.gridRows)
            {
                utils.RepaintSceneView();
            }

            // grid x
            float oldGridX = state.gridX;

            state.gridX = drawing.DrawFloatField(R2DD_Lang.gridX, state.gridX);

            if (state.gridX < 0.1f)
            {
                state.gridX = 0.1f;
            }

            if (oldGridX != state.gridX)
            {
                utils.RepaintSceneView();
            }

            // grid y
            float oldGridY = state.gridY;

            state.gridY = drawing.DrawFloatField(R2DD_Lang.gridY, state.gridY);

            if (state.gridY < 0.1f)
            {
                state.gridY = 0.1f;
            }

            if (oldGridY != state.gridY)
            {
                utils.RepaintSceneView();
            }

            // grid origin x
            float oldGridOriginX = state.gridOriginX;

            state.gridOriginX = drawing.DrawFloatField(R2DD_Lang.gridOriginX, state.gridOriginX);

            if (oldGridOriginX != state.gridOriginX)
            {
                utils.RepaintSceneView();
            }

            // grid origin y
            float oldGridOriginY = state.gridOriginY;

            state.gridOriginY = drawing.DrawFloatField(R2DD_Lang.gridOriginY, state.gridOriginY);

            if (oldGridOriginY != state.gridOriginY)
            {
                utils.RepaintSceneView();
            }

            // snap to grid
            state.snapToGrid = drawing.DrawToggle(R2DD_Lang.snapToGrid, state.snapToGrid);

            // toggle unity grid
            // clear guides
            drawing.DrawSpace(9f);

            if (drawing.DrawButton(R2DD_Lang.toggleUnityGrid))
            {
                grid.ToggleUnityGrid();
                utils.RepaintSceneView();
            }

            // NGUI snap issue guide
            drawing.DrawSpace(4f);

            if (state.context.type == ContextType.NGUI && state.snapToGrid)
            {
                drawing.DrawHelpBox(R2DD_Lang.nguiGridHelp);
            }
        }