Skip to content

Commit

Permalink
fix: renameing identity.Reset so it doesn't override unity's reset fu…
Browse files Browse the repository at this point in the history
…nction

Unity uses the Reset method when doing right click reset. If we override it then we can't reset the ids manually if something goes wrong
  • Loading branch information
James-Frowen committed Nov 7, 2021
1 parent dd3e90e commit bc5da6a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Assets/Mirage/Runtime/ClientObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void UnSpawn(NetworkIdentity identity)
}
else
{
identity.Reset();
identity.NetworkReset();
identity.gameObject.SetActive(false);
spawnableObjects[identity.sceneId] = identity;
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Mirage/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public sealed class NetworkIdentity : MonoBehaviour
public NetworkWorld World { get; internal set; }

[Header("Runtime References")]

/// <summary>
/// The ServerObjectManager is present only for server/host instances.
/// </summary>
Expand Down Expand Up @@ -1144,7 +1144,8 @@ public void RemoveClientAuthority()
/// as people might want to be able to read the members inside OnDestroy(), and we have no way
/// of invoking reset after OnDestroy is called.
/// </summary>
internal void Reset()
// IMPORTANT: dont use `Reset` as function name because that is a unity callback
internal void NetworkReset()
{
ResetSyncObjects();

Expand Down
2 changes: 1 addition & 1 deletion Assets/Mirage/Runtime/ServerObjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void DestroyObject(NetworkIdentity identity, bool destroyServerObject)

identity.StopServer();

identity.Reset();
identity.NetworkReset();
// when unspawning, dont destroy the server's object
if (destroyServerObject)
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Editor/NetworkIdentityCallbackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public void Reset()
identity.observers.Add(player1);

// mark for reset and reset
identity.Reset();
identity.NetworkReset();
Assert.That(identity.NetId, Is.EqualTo(0));
Assert.That(identity.Owner, Is.Null);
}
Expand Down

0 comments on commit bc5da6a

Please sign in to comment.