Skip to content

Commit

Permalink
[Fix] Moving an event setting its position to (0, 0) & Z dimension no…
Browse files Browse the repository at this point in the history
…t working at all
  • Loading branch information
RhenaudTheLukark committed Mar 22, 2024
1 parent 5dcc775 commit feac09d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Assets/Scripts/Lua/CLRBindings/LuaSpriteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ public string spritename {

// The x position of the sprite, relative to the arena position and its anchor.
public float x {
get { return img.GetComponent<RectTransform>().anchoredPosition.x + (GetTarget().gameObject != img ? img.transform.localPosition.x : 0); }
get { return img.GetComponent<RectTransform>().anchoredPosition.x + (GetTarget().gameObject != img ? GetTarget().transform.localPosition.x : 0); }
set { MoveTo(value, y); }
}

// The y position of the sprite, relative to the arena position and its anchor.
public float y {
get { return img.GetComponent<RectTransform>().anchoredPosition.y + (GetTarget().gameObject != img ? img.transform.localPosition.y : 0); }
get { return img.GetComponent<RectTransform>().anchoredPosition.y + (GetTarget().gameObject != img ? GetTarget().transform.localPosition.y : 0); }
set { MoveTo(x, value); }
}

// The z position of the sprite, relative to the arena position and its anchor. (Only useful in the overworld)
public float z {
get { return GetTarget().localPosition.z; }
get { return img.GetComponent<RectTransform>().localPosition.z + (GetTarget().gameObject != img ? GetTarget().transform.localPosition.z : 0); }
set { MoveTo(x, y, value); }
}

Expand Down Expand Up @@ -439,7 +439,7 @@ public void SetAnchor(float x, float y) {
public void MoveTo(float x, float y) { MoveTo(x, y, GetTarget().localPosition.z); }
public void MoveTo(float x, float y, float z) {
if (img.transform.parent != null && img.transform.parent.name == "SpritePivot")
GetTarget().localPosition = new Vector3(x, y, GetTarget().localPosition.z) - (Vector3)img.GetComponent<RectTransform>().anchoredPosition;
GetTarget().localPosition = new Vector3(x, y, z) - (Vector3)img.GetComponent<RectTransform>().anchoredPosition;
else
img.GetComponent<RectTransform>().anchoredPosition = new Vector2(x, y);
UnitaleUtil.TextObjectMoveChecker(GetTarget());
Expand Down

0 comments on commit feac09d

Please sign in to comment.