Skip to content

Commit

Permalink
Replaceed .hasChanged with .version
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsakharov committed Mar 22, 2024
1 parent 4a9ff8e commit 1e33510
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions Prowl.Runtime/Math/Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Vector3 position {
newPosition = p.InverseTransformPoint(newPosition);

localPosition = MakeSafe(newPosition);
_hasChanged = true;
_version++;
}
}

Expand All @@ -32,7 +32,7 @@ public Vector3 localPosition {
if (m_LocalPosition != value)
{
m_LocalPosition = MakeSafe(value);
_hasChanged = true;
_version++;
}
}
}
Expand All @@ -55,7 +55,7 @@ public Quaternion rotation {
localRotation = MakeSafe(Quaternion.NormalizeSafe(Quaternion.Inverse(parent.rotation) * value));
else
localRotation = MakeSafe(Quaternion.NormalizeSafe(value));
_hasChanged = true;
_version++;
}
}

Expand All @@ -66,7 +66,7 @@ public Quaternion localRotation {
if (m_LocalRotation != value)
{
m_LocalRotation = MakeSafe(value);
_hasChanged = true;
_version++;
}
}
}
Expand All @@ -75,15 +75,15 @@ public Vector3 eulerAngles {
get => MakeSafe(rotation.eulerAngles);
set {
rotation = MakeSafe(Quaternion.Euler(value));
_hasChanged = true;
_version++;
}
}

public Vector3 localEulerAngles {
get => MakeSafe(m_LocalRotation.eulerAngles);
set {
m_LocalRotation.eulerAngles = MakeSafe(value);
_hasChanged = true;
_version++;
}
}
#endregion
Expand All @@ -96,7 +96,7 @@ public Vector3 localScale {
if (m_LocalScale != value)
{
m_LocalScale = MakeSafe(value);
_hasChanged = true;
_version++;
}
}
}
Expand Down Expand Up @@ -129,9 +129,11 @@ public Transform parent {
set => gameObject.SetParent(value.gameObject, true);
}

public bool hasChanged {
get => _hasChanged;
set => _hasChanged = value;
// https://forum.unity.com/threads/transform-haschanged-would-be-better-if-replaced-by-a-version-number.700004/
// Replacement for hasChanged
public uint version {
get => _version;
set => _version = value;
}

public Transform root => parent == null ? this : parent.root;
Expand All @@ -146,7 +148,7 @@ public bool hasChanged {
[SerializeField] Quaternion m_LocalRotation = Quaternion.identity;

[NonSerialized]
bool _hasChanged = false;
uint _version = 0;

public GameObject gameObject { get; internal set; }
#endregion
Expand Down

0 comments on commit 1e33510

Please sign in to comment.