Skip to content

Commit

Permalink
🐛 fix: Fix frequency desync caused by initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
esnya committed Jul 25, 2022
1 parent 44771a2 commit da5e852
Show file tree
Hide file tree
Showing 10 changed files with 4,347 additions and 1,363 deletions.
4,498 changes: 3,947 additions & 551 deletions Packages/com.nekometer.esnya.udon-radio-communications/Demo.unity

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void Start()
public void _Initialize(UdonRadioCommunication urc)
{
this.urc = urc;
Frequency = urc.defaultFrequency;
if (Networking.IsOwner(gameObject)) Frequency = urc.defaultFrequency;
}

public void _TakeOwnership()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ public float Frequency
{
set
{
var isOwner = Networking.IsOwner(gameObject);
if (!receiver.sync || isOwner) receiver.Frequency = value;
if (isOwner) transmitter._SetFrequency(value);
if (Networking.IsOwner(gameObject))
{
receiver.Frequency = value;
transmitter._SetFrequency(value);
}

_frequency = value;
_UpdateFrequencyText();
}
get => _frequency;
}

[UdonSynced][FieldChangeCallback(nameof(Receive))] private bool _receive;
[UdonSynced]
[FieldChangeCallback(nameof(Receive))]
private bool _receive;
private bool Receive
{
set
Expand Down Expand Up @@ -100,7 +104,7 @@ public void _Initialize(UdonRadioCommunication urc)
frequencyStep = urc.frequencyStep;
fastFrequencyStep = urc.fastFrequencyStep;

Frequency = urc.defaultFrequency;
if (Networking.IsOwner(gameObject)) Frequency = urc.defaultFrequency;
}

public void _TakeOwnership()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void Start()
public void _Initialize(UdonRadioCommunication urc)
{
this.urc = urc;
Frequency = urc.defaultFrequency;
if (Networking.IsOwner(gameObject)) Frequency = urc.defaultFrequency;
}

public void _TakeOwnership()
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit da5e852

Please sign in to comment.