mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix(NetworkTransform): Awake now also configures syncInterval and syncScale, in case OnValidate wasn't called
This commit is contained in:
parent
63e91919a4
commit
0d36c30206
@ -99,18 +99,9 @@ public abstract class NetworkTransformBase : NetworkBehaviour
|
|||||||
public Color overlayColor = new Color(0, 0, 0, 0.5f);
|
public Color overlayColor = new Color(0, 0, 0, 0.5f);
|
||||||
|
|
||||||
// initialization //////////////////////////////////////////////////////
|
// initialization //////////////////////////////////////////////////////
|
||||||
// make sure to call this when inheriting too!
|
// forcec configuration of some settings
|
||||||
protected virtual void Awake()
|
protected virtual void Configure()
|
||||||
{
|
{
|
||||||
// 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()
|
|
||||||
{
|
|
||||||
base.OnValidate();
|
|
||||||
|
|
||||||
// set target to self if none yet
|
// set target to self if none yet
|
||||||
if (target == null) target = transform;
|
if (target == null) target = transform;
|
||||||
|
|
||||||
@ -126,6 +117,22 @@ protected override void OnValidate()
|
|||||||
if (coordinateSpace == CoordinateSpace.World) syncScale = false;
|
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 //////////////////////////////////////////////////
|
// snapshot functions //////////////////////////////////////////////////
|
||||||
// get local/world position
|
// get local/world position
|
||||||
protected virtual Vector3 GetPosition() =>
|
protected virtual Vector3 GetPosition() =>
|
||||||
|
Loading…
Reference in New Issue
Block a user