mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-21 01:36:03 +08:00
Add zoomToMouse setting in preferences
This commit is contained in:
parent
e6530d87d6
commit
3ced922ce6
@ -52,10 +52,10 @@ namespace XNodeEditor {
|
||||
case EventType.MouseMove:
|
||||
break;
|
||||
case EventType.ScrollWheel:
|
||||
var oldZoom = zoom;
|
||||
float oldZoom = zoom;
|
||||
if (e.delta.y > 0) zoom += 0.1f * zoom;
|
||||
else zoom -= 0.1f * zoom;
|
||||
panOffset += (1 - oldZoom / zoom) * (WindowToGridPosition(e.mousePosition) + panOffset);
|
||||
if (NodeEditorPreferences.GetSettings().zoomToMouse) panOffset += (1 - oldZoom / zoom) * (WindowToGridPosition(e.mousePosition) + panOffset);
|
||||
break;
|
||||
case EventType.MouseDrag:
|
||||
if (e.button == 0) {
|
||||
|
||||
@ -26,6 +26,7 @@ namespace XNodeEditor {
|
||||
public Color32 highlightColor = new Color32(255, 255, 255, 255);
|
||||
public bool gridSnap = true;
|
||||
public bool autoSave = true;
|
||||
public bool zoomToMouse = true;
|
||||
[SerializeField] private string typeColorsData = "";
|
||||
[NonSerialized] public Dictionary<string, Color> typeColors = new Dictionary<string, Color>();
|
||||
public NoodleType noodleType = NoodleType.Curve;
|
||||
@ -98,6 +99,7 @@ namespace XNodeEditor {
|
||||
//Label
|
||||
EditorGUILayout.LabelField("Grid", EditorStyles.boldLabel);
|
||||
settings.gridSnap = EditorGUILayout.Toggle(new GUIContent("Snap", "Hold CTRL in editor to invert"), settings.gridSnap);
|
||||
settings.zoomToMouse = EditorGUILayout.Toggle(new GUIContent("Zoom to Mouse", "Zooms towards mouse position"), settings.zoomToMouse);
|
||||
|
||||
settings.gridLineColor = EditorGUILayout.ColorField("Color", settings.gridLineColor);
|
||||
settings.gridBgColor = EditorGUILayout.ColorField(" ", settings.gridBgColor);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user