Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using Unity.Netcode.Editor.Configuration;
using Unity.Netcode.Logging;
using UnityEditor;
using UnityEngine;
#if UNITY_6000_5_OR_NEWER
Expand Down Expand Up @@ -298,7 +299,7 @@ private void DisplayNetworkManagerProperties()
#else
string path = Path.Combine(directory, $"NetworkPrefabs-{m_NetworkManager.GetInstanceID()}.asset");
#endif
Debug.Log("Saving migrated Network Prefabs List to " + path);
m_NetworkManager.Log.Info(new Context(LogLevel.Normal, "Saving migrated Network Prefabs List").AddInfo("Path", path));
AssetDatabase.CreateAsset(networkPrefabs, path);
EditorUtility.SetDirty(m_NetworkManager);
}
Expand Down
13 changes: 6 additions & 7 deletions com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Unity.Netcode.Editor.Configuration;
using Unity.Netcode.Logging;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand Down Expand Up @@ -162,19 +163,17 @@ public void CheckAndNotifyUserNetworkObjectRemoved(NetworkManager networkManager

if (!EditorApplication.isPlaying && !editorTest)
{
EditorUtility.DisplayDialog($"Removing {nameof(NetworkObject)}", NetworkManagerAndNetworkObjectNotAllowedMessage(), "OK");
EditorUtility.DisplayDialog($"Removing {nameof(NetworkObject)}", k_NetworkManagerAndNetworkObjectNotAllowedMessage, "OK");
}
else
{
Debug.LogError(NetworkManagerAndNetworkObjectNotAllowedMessage());
networkManager.Log.Error(new Context(LogLevel.Error, k_NetworkManagerAndNetworkObjectNotAllowedMessage));
}
}
}

public string NetworkManagerAndNetworkObjectNotAllowedMessage()
{
return $"A {nameof(GameObject)} cannot have both a {nameof(NetworkManager)} and {nameof(NetworkObject)} assigned to it or any children under it.";
}
private static readonly string k_NetworkManagerAndNetworkObjectNotAllowedMessage = $"A {nameof(GameObject)} cannot have both a {nameof(NetworkManager)} and {nameof(NetworkObject)} assigned to it or any children under it.";
public string NetworkManagerAndNetworkObjectNotAllowedMessage() => k_NetworkManagerAndNetworkObjectNotAllowedMessage;

/// <summary>
/// Handles notifying the user, via display dialog window, that they have nested a NetworkManager.
Expand Down Expand Up @@ -215,7 +214,7 @@ public bool NotifyUserOfNestedNetworkManager(NetworkManager networkManager, bool
}
else
{
Debug.LogError(message);
networkManager.Log.Error(new Context(LogLevel.Error, message));
}

if (!s_LastKnownNetworkManagerParents.ContainsKey(networkManager) && isParented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,14 @@ internal void OnClientDisconnectFromServer(ulong clientId)
}
else if (!NetworkManager.ShutdownInProgress)
{
playerObject.RemoveOwnership();
if (NetworkManager.DistributedAuthorityMode)
{
NetworkManager.SpawnManager.ChangeOwnership(playerObject, NetworkManager.LocalClientId, true);
}
else
{
playerObject.RemoveOwnership();
}
}
}

Expand Down
Loading