Skip to content

Commit

Permalink
fix(NetworkTransform): assign target to self if not assigned yet in A…
Browse files Browse the repository at this point in the history
…wake. Fixes NetworkTransformBase.Construct NRE if OnValidate was never called
  • Loading branch information
miwarnec committed Apr 17, 2024
1 parent ddf2134 commit 553bb74
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ public abstract class NetworkTransformBase : NetworkBehaviour

// initialization //////////////////////////////////////////////////////
// make sure to call this when inheriting too!
protected virtual void Awake() { }
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()
{
Expand Down

0 comments on commit 553bb74

Please sign in to comment.