@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using FlaxEditor.GUI;
|
|
||||||
using FlaxEditor.GUI.ContextMenu;
|
using FlaxEditor.GUI.ContextMenu;
|
||||||
using FlaxEditor.GUI.Input;
|
using FlaxEditor.GUI.Input;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
@@ -86,7 +85,10 @@ namespace FlaxEditor.Surface
|
|||||||
// Read node data
|
// Read node data
|
||||||
Title = TitleValue;
|
Title = TitleValue;
|
||||||
Color = ColorValue;
|
Color = ColorValue;
|
||||||
Size = SizeValue;
|
var size = SizeValue;
|
||||||
|
if (Surface.GridSnappingEnabled)
|
||||||
|
size = Surface.SnapToGrid(size, true);
|
||||||
|
Size = size;
|
||||||
|
|
||||||
// Order
|
// Order
|
||||||
// Backwards compatibility - When opening with an older version send the old comments to the back
|
// Backwards compatibility - When opening with an older version send the old comments to the back
|
||||||
@@ -299,7 +301,10 @@ namespace FlaxEditor.Surface
|
|||||||
if (_isResizing)
|
if (_isResizing)
|
||||||
{
|
{
|
||||||
// Update size
|
// Update size
|
||||||
Size = Float2.Max(location, new Float2(140.0f, _headerRect.Bottom));
|
var size = Float2.Max(location, new Float2(140.0f, _headerRect.Bottom));
|
||||||
|
if (Surface.GridSnappingEnabled)
|
||||||
|
size = Surface.SnapToGrid(size, true);
|
||||||
|
Size = size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -131,6 +131,15 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnSurfaceLoaded(SurfaceNodeActions action)
|
public virtual void OnSurfaceLoaded(SurfaceNodeActions action)
|
||||||
{
|
{
|
||||||
|
// Snap bounds (with ceil) when using grid snapping
|
||||||
|
if (Surface.GridSnappingEnabled)
|
||||||
|
{
|
||||||
|
var bounds = Bounds;
|
||||||
|
bounds.Location = Surface.SnapToGrid(bounds.Location, false);
|
||||||
|
bounds.Size = Surface.SnapToGrid(bounds.Size, true);
|
||||||
|
Bounds = bounds;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateRectangles();
|
UpdateRectangles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,15 @@ namespace FlaxEditor.Surface
|
|||||||
if (Surface == null)
|
if (Surface == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Snap bounds (with ceil) when using grid snapping
|
||||||
|
if (Surface.GridSnappingEnabled)
|
||||||
|
{
|
||||||
|
var size = Surface.SnapToGrid(new Float2(width, height), true);
|
||||||
|
width = size.X;
|
||||||
|
height = size.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arrange output boxes on the right edge
|
||||||
for (int i = 0; i < Elements.Count; i++)
|
for (int i = 0; i < Elements.Count; i++)
|
||||||
{
|
{
|
||||||
if (Elements[i] is OutputBox box)
|
if (Elements[i] is OutputBox box)
|
||||||
@@ -175,6 +184,7 @@ namespace FlaxEditor.Surface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resize
|
||||||
Size = CalculateNodeSize(width, height);
|
Size = CalculateNodeSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user