Skip to content

Commit

Permalink
fix(NetworkTransform): Awake now also configures syncInterval and syn…
Browse files Browse the repository at this point in the history
…cScale, in case OnValidate wasn't called
  • Loading branch information
miwarnec committed Apr 29, 2024
1 parent 63e9191 commit 0d36c30
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Assets/Mirror/Components/NetworkTransform/NetworkTransformBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,9 @@ public abstract class NetworkTransformBase : NetworkBehaviour
public Color overlayColor = new Color(0, 0, 0, 0.5f);

// initialization //////////////////////////////////////////////////////
// make sure to call this when inheriting too!
protected virtual void Awake()
{
// set target to self if none yet.
// OnValidate() already does this, but sometimes OnValidate() doesn't run before launching a project.
if (target == null) target = transform;
}

protected override void OnValidate()
// forcec configuration of some settings
protected virtual void Configure()
{
base.OnValidate();

// set target to self if none yet
if (target == null) target = transform;

Expand All @@ -126,6 +117,22 @@ protected override void OnValidate()
if (coordinateSpace == CoordinateSpace.World) syncScale = false;
}

// make sure to call this when inheriting too!
protected virtual void Awake()
{
// sometimes OnValidate() doesn't run before launching a project.
// need to guarantee configuration runs.
Configure();
}

protected override void OnValidate()
{
base.OnValidate();

// configure in awake
Configure();
}

// snapshot functions //////////////////////////////////////////////////
// get local/world position
protected virtual Vector3 GetPosition() =>
Expand Down

0 comments on commit 0d36c30

Please sign in to comment.