Beispiel #1
0
        public BGRectangularSelection(BGCurveEditorPoints editor, BGCurveEditorPointsSelection selection)
        {
            this.editor    = editor;
            this.selection = selection;
            curve          = editor.Curve;

            borderHorizontal = CreateBorder(false);
            borderVertical   = CreateBorder(true);
        }
        public BGCurveEditorPoint(BGCurveEditorPoints editor, BGCurveEditorPointsSelection editorSelection)
        {
            this.editor          = editor;
            this.editorSelection = editorSelection;

            //textures
            deleteTexture    = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123);
            addBeforeTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123);
            moveUpTexture    = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGMoveUp123);
            moveDownTexture  = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGMoveDown123);
            maskTexture      = BGEditorUtility.Texture1X1(new Color(1, 0, 0, .15f));
        }
        public BGSceneViewOverlay(BGCurveEditorPoints editor, BGCurveEditorPointsSelection editorSelection)
        {
            Editor = editor;

            actions = new SceneAction[]
            {
                new BGSceneViewOverlayMenuSelection(this, editorSelection),
                new BGSceneViewOverlayMenuPoint(this, editorSelection),
                new BGSceneViewOverlayPointAddAtDistance(this),
                new BGSceneViewOverlayPointAddSnap3D(this),
                new BGSceneViewOverlayPointAddSnap2D(this)
            };
        }
        public BGCurveEditorPointsSelection(BGCurve curve, BGCurveEditorPoints editor)
        {
            this.curve  = curve;
            this.editor = editor;

            tickNoTexture      = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickNo123);
            tickYesTexture     = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGTickYes123);
            deleteTexture      = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDelete123);
            selectAllTexture   = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGSelectAll123);
            deselectAllTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGDeSelectAll123);
            convertAll2D       = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123);

            selectionRectangle = new BGRectangularSelection(editor, this);
        }
        public void OnSceneGUI(BGCurvePointI point, int index, BGCurveSettings settings, Quaternion rotation, Plane[] frustum)
        {
            var math          = mathProvider();
            var positionWorld = math == null ? point.Curve[index].PositionWorld : math.GetPosition(index);

            //adjust rotation
            if (point.PointTransform != null)
            {
                rotation = BGCurveEditorPoints.GetRotation(point.PointTransform);
            }
            else if (point.Curve.PointsMode == BGCurve.PointsModeEnum.GameObjectsTransform)
            {
                rotation = BGCurveEditorPoints.GetRotation(((BGCurvePointGO)point).transform);
            }

            var isShowingGizmoz = settings.RestrictGizmozSettings.IsShowing(index);

            if (settings.ShowControlHandles && settings.ShowCurve && (editorSelection == null || !editorSelection.HasSelected() || editorSelection.SingleSelected(point)))
            {
                // ============================================== Controls Handles
                if (point.ControlType != BGCurvePoint.ControlTypeEnum.Absent)
                {
                    if (isShowingGizmoz)
                    {
                        var controlFirstWorld  = math == null ? point.Curve[index].ControlFirstWorld : math.GetControlFirst(index);
                        var controlSecondWorld = math == null ? point.Curve[index].ControlSecondWorld : math.GetControlSecond(index);

                        BGEditorUtility.SwapHandlesColor(settings.ControlHandlesColor, () =>
                        {
                            Handles.DrawLine(positionWorld, controlFirstWorld);
                            Handles.DrawLine(positionWorld, controlSecondWorld);

                            if (ShowingHandles)
                            {
                                // control handles different types
                                var newPositionFirst  = BGEditorUtility.Handle(GetUniqueNumber(index) - 1, settings.ControlHandlesType, controlFirstWorld, rotation, settings.ControlHandlesSettings);
                                var newPositionSecond = BGEditorUtility.Handle(GetUniqueNumber(index) - 2, settings.ControlHandlesType, controlSecondWorld, rotation, settings.ControlHandlesSettings);

                                if (BGEditorUtility.AnyChange(controlFirstWorld, newPositionFirst))
                                {
                                    point.ControlFirstWorld = newPositionFirst;
                                }
                                if (BGEditorUtility.AnyChange(controlSecondWorld, newPositionSecond))
                                {
                                    point.ControlSecondWorld = newPositionSecond;
                                }
                            }
                        });

                        if (settings.ShowControlLabels)
                        {
                            ShowControlLabel(settings, frustum, controlFirstWorld, point.ControlFirstLocal, "1");
                            ShowControlLabel(settings, frustum, controlSecondWorld, point.ControlSecondLocal, "2");
                        }
                    }
                }
            }

            //if only one point is selected and this is the selected point- do not print anything further
            if (editorSelection != null && editorSelection.HasSelected() && editorSelection.SingleSelected(point))
            {
                return;
            }

            // ============================================== Move Handles
            if ((editorSelection == null || !editorSelection.HasSelected()) && settings.ShowCurve && settings.ShowHandles && ShowingHandles && isShowingGizmoz)
            {
                var newPos = BGEditorUtility.Handle(GetUniqueNumber(index), settings.HandlesType, positionWorld, rotation, settings.HandlesSettings);

                if (BGEditorUtility.AnyChange(positionWorld, newPos))
                {
                    point.PositionWorld = newPos;
                }
            }
        }
        public override void OnInspectorGUI()
        {
            var curve = point.Curve;

            BGCurveEditorPoints.SwapVector2Labels(curve.Mode2D, () => pointEditor.OnInspectorGui(point, curve.IndexOf(point), BGPrivateField.GetSettings(curve)));
        }