private void UpdatePoints(Rect rect) { var sceneViewHeight = BGEditorUtility.GetSceneViewHeight(); var math = editor.Math; curve.ForEach((point, index, count) => { //add or remove from selection if (rect.Contains(BGEditorUtility.GetSceneViewPosition(math.GetPosition(index), sceneViewHeight))) { selection.Add(point); } else { selection.Remove(point); } }); if (!selection.Changed) { return; } selection.Reset(); }
public virtual void On(Vector3 position) { if (Active) { return; } Active = true; onTransition = new BGTransition.SimpleTransition(.2, false); Point3DPosition = position; Point2DPosition = BGEditorUtility.GetSceneViewPosition(Point3DPosition); //target size (go first) height = width = 0; foreach (var size in items.Where(item => !item.Disabled).Select(item => item.Size)) { if (height < size.y * 2) { height = size.y * 2; } width += size.x; } targetRect.size = new Vector2(width, height + HeaderHeight); //target position (go second) targetRect.x = Point2DPosition.x - targetRect.size.x * .5f; targetRect.y = Point2DPosition.y - targetRect.size.y * .75f; }
protected override bool Process(Event @event, BGCurveBaseMath math, float sceneViewHeight, ref Vector3 position, ref string message) { if (BGCurveSettingsForEditor.DisableSceneViewSelectionMenu || !menu.EditorSelection.HasSelected()) { return(false); } var selectedPos = menu.EditorSelection.GetAveragePosition(); if (!(DistanceTolerance > (@event.mousePosition - BGEditorUtility.GetSceneViewPosition(selectedPos, sceneViewHeight)).sqrMagnitude)) { return(false); } //out params position = selectedPos; message = SuccessMessage("Selected " + menu.EditorSelection.CountSelected + " point(s)."); //turn on the menu menu.On(position); //check if all points share the same control type BGCurvePoint.ControlTypeEnum singleType = BGCurvePoint.ControlTypeEnum.Absent; bool first = true, single = true; menu.EditorSelection.ForEach(point => { if (first) { first = false; singleType = point.ControlType; } else if (singleType != point.ControlType) { single = false; return(true); } return(false); }); if (single) { menu.Get(0).Current = singleType == BGCurvePoint.ControlTypeEnum.Absent; menu.Get(1).Current = singleType == BGCurvePoint.ControlTypeEnum.BezierSymmetrical; menu.Get(2).Current = singleType == BGCurvePoint.ControlTypeEnum.BezierIndependant; } else { menu.Get(0).Current = menu.Get(1).Current = menu.Get(2).Current = false; } return(true); }
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 bool Process(Event @event, BGCurveBaseMath math, float sceneViewHeight, ref Vector3 position, ref string message) { if (BGCurveSettingsForEditor.DisableSceneViewPointMenu) { return(false); } var minDistanceToCamera = float.MaxValue; var mousePosition = @event.mousePosition; var cameraPos = SceneView.currentDrawingSceneView.camera.transform.position; var index = -1; var pointsCount = math.Curve.PointsCount; for (var i = 0; i < pointsCount; i++) { var pointPos = math.GetPosition(i); var sqrMagnitude = (mousePosition - BGEditorUtility.GetSceneViewPosition(pointPos, sceneViewHeight)).sqrMagnitude; if (sqrMagnitude > DistanceTolerance) { continue; } var sqrtMagnitude = Vector3.SqrMagnitude(cameraPos - pointPos); if (minDistanceToCamera < sqrtMagnitude) { continue; } //found a target minDistanceToCamera = sqrMagnitude; index = i; } if (index < 0) { return(false); } //menu active var point = math.Curve[index]; position = math.GetPosition(index); message = SuccessMessage("Point " + index); menu.On(point, index); //============== Ok return(true); }