internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message) { if (menu.Active) { menu.OnGui(currentEvent); DrawActiveAnimatedTexture(menu.Point2DPosition); var okMessage = menu.ActiveItem != null && menu.ActiveItem.Description != null ? "Release Ctrl to " + menu.ActiveItem.Description : "Hover over an option and release Ctrl."; //out params position = menu.Point3DPosition; message = BGSceneViewOverlay.ToOk(okMessage) + "\r\n" + menu.Details; //============== Ok return(true); } if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control)) { return(false); } if (Process(currentEvent, overlay.Editor.Editor.Math, BGEditorUtility.GetSceneViewHeight(), ref position, ref message)) { return(true); } pointIndicatorTransition = null; //============== No luck return(false); }
protected AbstractMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection, string title) : base(title) { EditorSelection = editorSelection; Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlAbsent123), "Convert point control to Absent", () => { SetControl(BGCurvePoint.ControlTypeEnum.Absent); })); Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierSymmetrical123), "Convert point control to Bezier Symmetrical", () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierSymmetrical); })); Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGControlBezierIndependent123), "Convert point control to Bezier Independent", () => { SetControl(BGCurvePoint.ControlTypeEnum.BezierIndependant); })); AdditionalMenuItems(); Add(new LockMenuItem(() => { BGCurveSettingsForEditor.LockView = !BGCurveSettingsForEditor.LockView; EditorUtility.SetDirty(overlay.Editor.Curve); })); Add(new MenuSeparator()); Add(new MenuItemButton(BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointDelete123), "Delete a point", Delete)); }
public virtual void OnSceneGUI() { BGEditorUtility.Assign(ref pointIndicatorTransition, () => new BGTransition.SwayTransition(30, 30, 1)); BGSceneViewOverlay.DrawHandlesGuiTexture(BGEditorUtility.GetSceneViewPosition(point.PositionWorld), pointIndicatorTransition, pointSelectedTexture); curveEditor.OnSceneGUI(); // animation is off for now // SceneView.RepaintAll(); }
protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) { RaycastHit hit; if (Physics.Raycast(ray, out hit)) { position = hit.point; plane = new Plane(hit.normal, hit.point); error = null; } else { error = BGSceneViewOverlay.ToError("No mesh (or collider) to snap a point to!") + " \r\n Use Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; position = ray.GetPoint(10); plane = new Plane(); } }
public BGCurveEditorPoints(BGCurveEditor editor, SerializedObject serializedObject, BGCurveEditorPointsSelection editorSelection) : base(editor, serializedObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPoints123)) { this.serializedObject = serializedObject; this.editorSelection = editorSelection; //textures convertAll2D = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); addPointIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); //point editorPoint = new BGCurveEditorPoint(() => Editor.Math, editorSelection); //closed or not closedProperty = serializedObject.FindProperty("closed"); //how points are stored pointsModeProperty = serializedObject.FindProperty("pointsMode"); //2d mode mode2DProperty = serializedObject.FindProperty("mode2D"); //snapping snapTypeProperty = serializedObject.FindProperty("snapType"); snapAxisProperty = serializedObject.FindProperty("snapAxis"); snapDistanceProperty = serializedObject.FindProperty("snapDistance"); snapTriggerInteractionProperty = serializedObject.FindProperty("snapTriggerInteraction"); snapToBackFacesProperty = serializedObject.FindProperty("snapToBackFaces"); snapMonitoringProperty = serializedObject.FindProperty("snapMonitoring"); //force update forceChangedEventModeProperty = serializedObject.FindProperty("forceChangedEventMode"); //event type eventModeProperty = serializedObject.FindProperty("eventMode"); //settings controlTypeProperty = serializedObject.FindProperty("settings").FindPropertyRelative("controlType"); //Context menu overlay = new BGSceneViewOverlay(this, editorSelection); //for GameObjects points which use transforms UpdatePointsTrackers(); }
protected override void Cast(Event @event, Ray ray, out Vector3 position, out string error, out Plane plane) { var curve = overlay.Editor.Curve; Get2DPlane(out plane, curve); float distance; if (!plane.Raycast(ray, out distance)) { error = BGSceneViewOverlay.ToError("Curve is in 2D mode! \r\n Curve's plane does not intersect with the current point.") + "\r\nUse Ctrl+Shift+Click to spawn a point at the distance,\r\n which is set in settings"; position = ray.GetPoint(10); } else { error = null; position = ray.GetPoint(distance); } }
public BGCurveEditorPoints(BGCurveEditor editor, SerializedObject curveObject) : base(editor, curveObject, BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPoints123)) { //textures convertAll2D = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGConvertAll123); addPointIcon = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGAdd123); //selection editorSelection = new BGCurveEditorPointsSelection(Curve, this); //point editorPoint = new BGCurveEditorPoint(this, editorSelection); //closed or not closedProperty = curveObject.FindProperty("closed"); //2d mode mode2DProperty = curveObject.FindProperty("mode2D"); //settings controlTypeProperty = curveObject.FindProperty("settings").FindPropertyRelative("controlType"); //Context menu overlay = new BGSceneViewOverlay(this, editorSelection); }
protected static string SuccessMessage(string message) { return(BGSceneViewOverlay.ToOk("Hover over an option and release Ctrl.\r\n") + message); }
protected BGSceneViewOverlayMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) : base(overlay) { this.editorSelection = editorSelection; pointSelectedTexture = BGEditorUtility.LoadTexture2D(BGEditorUtility.Image.BGPointSelected123); }
public PointMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) : base(overlay, editorSelection, "Point menu") { }
public BGSceneViewOverlayMenuPoint(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) : base(overlay, editorSelection) { menu = new PointMenu(overlay, editorSelection); }
protected SceneAction(BGSceneViewOverlay overlay) { this.overlay = overlay; }
public BGSceneViewOverlayPointAddSnap3D(BGSceneViewOverlay overlay) : base(overlay) { }
public BGSceneViewOverlayPointInsert(BGSceneViewOverlay overlay) : base(overlay) { }
protected BGSceneViewOverlayMenu(BGSceneViewOverlay overlay, BGCurveEditorPointsSelection editorSelection) : base(overlay) { this.editorSelection = editorSelection; }
public BGSceneViewOverlayPointAddAtDistance(BGSceneViewOverlay overlay) : base(overlay) { }
//see base class for description internal override bool Seize(Event currentEvent, ref Vector3 position, ref string message) { if (!Comply(currentEvent)) { return(false); } Vector3 intersectionPosition; Plane plane; if (currentEvent.type == EventType.mouseDown && currentEvent.control && currentEvent.button == 0) { //Mouse down for some action var curve = overlay.Editor.Curve; var settings = overlay.Editor.Settings; Cast(currentEvent, HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition), out intersectionPosition, out message, out plane); if (message != null) { BGCurveEditor.OverlayMessage.Display(message); } else { position = intersectionPosition; BGCurveEditor.AddPoint(curve, BGNewPointPositionManager.CreatePoint(intersectionPosition, curve, settings.ControlType, settings.Sections, true), curve.PointsCount); } overlay.EventCanceller = new BGEditorUtility.EventCanceller(); return(true); } if (!(currentEvent.type == EventType.Repaint && currentEvent.control || currentEvent.type == EventType.MouseMove && currentEvent.control)) { return(false); } var ray = HandleUtility.GUIPointToWorldRay(currentEvent.mousePosition); Cast(currentEvent, ray, out intersectionPosition, out message, out plane); position = intersectionPosition; if (message != null) { return(true); } Animation(plane, ray, swayTransition); //preview float toLast = -1, toFirst = -1; Preview(intersectionPosition, overlay.Editor.Curve, ref toLast, ref toFirst); //distance message = BGSceneViewOverlay.ToOk("MouseClick to add a point\r\n") + //to last (toLast < 0 ? "First point is ready to go!" : "Distance to last=" + toLast) + //to first (toFirst < 0 ? "" : ", to first=" + toFirst); return(true); }
protected BGSceneViewOverlayPointAdd(BGSceneViewOverlay overlay) : base(overlay) { }