diff --git a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
index e176f2b70..bb9da0936 100644
--- a/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
+++ b/Source/Editor/CustomEditors/Dedicated/UIControlEditor.cs
@@ -423,9 +423,9 @@ namespace FlaxEditor.CustomEditors.Dedicated
private void BuildLocationSizeOffsets(LayoutElementsContainer horUp, LayoutElementsContainer horDown, bool xEq, bool yEq, ScriptType[] valueTypes)
{
- ScriptMemberInfo xInfo = valueTypes[0].GetProperty("X");
+ ScriptMemberInfo xInfo = valueTypes[0].GetProperty("LocalX");
ItemInfo xItem = new ItemInfo(xInfo);
- ScriptMemberInfo yInfo = valueTypes[0].GetProperty("Y");
+ ScriptMemberInfo yInfo = valueTypes[0].GetProperty("LocalY");
ItemInfo yItem = new ItemInfo(yInfo);
ScriptMemberInfo widthInfo = valueTypes[0].GetProperty("Width");
ItemInfo widthItem = new ItemInfo(widthInfo);
diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs
index e4e2eafcc..05214b498 100644
--- a/Source/Engine/UI/GUI/Control.Bounds.cs
+++ b/Source/Engine/UI/GUI/Control.Bounds.cs
@@ -26,6 +26,26 @@ namespace FlaxEngine.GUI
set => Bounds = new Rectangle(X, value, _bounds.Size);
}
+ ///
+ /// Gets or sets the local X coordinate of the pivot of the control relative to the anchor in parent of its container.
+ ///
+ [HideInEditor, NoSerialize]
+ public float LocalX
+ {
+ get => LocalLocation.X;
+ set => LocalLocation = new Vector2(value, LocalLocation.Y);
+ }
+
+ ///
+ /// Gets or sets the local Y coordinate of the pivot of the control relative to the anchor in parent of its container.
+ ///
+ [HideInEditor, NoSerialize]
+ public float LocalY
+ {
+ get => LocalLocation.Y;
+ set => LocalLocation = new Vector2(LocalLocation.X, value);
+ }
+
///
/// Gets or sets the normalized position in the parent control that the upper left corner is anchored to (range 0-1).
///
@@ -137,6 +157,17 @@ namespace FlaxEngine.GUI
set => Bounds = new Rectangle(value, _bounds.Size);
}
+ ///
+ /// The local position of the pivot of the control relative to the anchor in parent of its container.
+ ///
+ [NoSerialize]
+ [HideInEditor, ExpandGroups, EditorDisplay("Transform"), EditorOrder(1000), Tooltip("The local position of the pivot of the control relative to the anchor in parent of its container.")]
+ public Vector2 LocalLocation
+ {
+ get => _bounds.Location - (Parent.Size * (AnchorMax + AnchorMin) / 2) + Size * Pivot;
+ set => Bounds = new Rectangle(value + (Parent.Size * (AnchorMax + AnchorMin) / 2) - Size * Pivot, _bounds.Size);
+ }
+
///
/// Gets or sets width of the control.
///