The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [1.0.0-pre.7] - 2022-04-01 ### Added - Added editor only check prior to entering into play mode if the currently open and active scene is in the build list and if not displays a dialog box asking the user if they would like to automatically add it prior to entering into play mode. (#1828) - Added `UnityTransport` implementation and `com.unity.transport` package dependency (#1823) - Added `NetworkVariableWritePermission` to `NetworkVariableBase` and implemented `Owner` client writable netvars. (#1762) - `UnityTransport` settings can now be set programmatically. (#1845) - `FastBufferWriter` and Reader IsInitialized property. (#1859) ### Changed - Updated `UnityTransport` dependency on `com.unity.transport` to 1.0.0 (#1849) ### Removed - Removed `SnapshotSystem` (#1852) - Removed `com.unity.modules.animation`, `com.unity.modules.physics` and `com.unity.modules.physics2d` dependencies from the package (#1812) - Removed `com.unity.collections` dependency from the package (#1849) ### Fixed - Fixed in-scene placed NetworkObjects not being found/ignored after a client disconnects and then reconnects. (#1850) - Fixed issue where `UnityTransport` send queues were not flushed when calling `DisconnectLocalClient` or `DisconnectRemoteClient`. (#1847) - Fixed NetworkBehaviour dependency verification check for an existing NetworkObject not searching from root parent transform relative GameObject. (#1841) - Fixed issue where entries were not being removed from the NetworkSpawnManager.OwnershipToObjectsTable. (#1838) - Fixed ClientRpcs would always send to all connected clients by default as opposed to only sending to the NetworkObject's Observers list by default. (#1836) - Fixed clarity for NetworkSceneManager client side notification when it receives a scene hash value that does not exist in its local hash table. (#1828) - Fixed client throws a key not found exception when it times out using UNet or UTP. (#1821) - Fixed network variable updates are no longer limited to 32,768 bytes when NetworkConfig.EnsureNetworkVariableLengthSafety is enabled. The limits are now determined by what the transport can send in a message. (#1811) - Fixed in-scene NetworkObjects get destroyed if a client fails to connect and shuts down the NetworkManager. (#1809) - Fixed user never being notified in the editor that a NetworkBehaviour requires a NetworkObject to function properly. (#1808) - Fixed PlayerObjects and dynamically spawned NetworkObjects not being added to the NetworkClient's OwnedObjects (#1801) - Fixed issue where NetworkManager would continue starting even if the NetworkTransport selected failed. (#1780) - Fixed issue when spawning new player if an already existing player exists it does not remove IsPlayer from the previous player (#1779) - Fixed lack of notification that NetworkManager and NetworkObject cannot be added to the same GameObject with in-editor notifications (#1777) - Fixed parenting warning printing for false positives (#1855)
132 lines
5.8 KiB
C#
132 lines
5.8 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
namespace Unity.Netcode.Editor
|
|
{
|
|
[CustomEditor(typeof(NetworkObject), true)]
|
|
[CanEditMultipleObjects]
|
|
public class NetworkObjectEditor : UnityEditor.Editor
|
|
{
|
|
private bool m_Initialized;
|
|
private NetworkObject m_NetworkObject;
|
|
private bool m_ShowObservers;
|
|
|
|
private void Initialize()
|
|
{
|
|
if (m_Initialized)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_Initialized = true;
|
|
m_NetworkObject = (NetworkObject)target;
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
Initialize();
|
|
|
|
if (EditorApplication.isPlaying && !m_NetworkObject.IsSpawned && m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
|
|
{
|
|
EditorGUILayout.BeginHorizontal();
|
|
EditorGUILayout.LabelField(new GUIContent("Spawn", "Spawns the object across the network"));
|
|
if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft))
|
|
{
|
|
m_NetworkObject.Spawn();
|
|
EditorUtility.SetDirty(target);
|
|
}
|
|
|
|
EditorGUILayout.EndHorizontal();
|
|
}
|
|
else if (EditorApplication.isPlaying && m_NetworkObject.IsSpawned)
|
|
{
|
|
var guiEnabled = GUI.enabled;
|
|
GUI.enabled = false;
|
|
EditorGUILayout.TextField(nameof(NetworkObject.GlobalObjectIdHash), m_NetworkObject.GlobalObjectIdHash.ToString());
|
|
EditorGUILayout.TextField(nameof(NetworkObject.NetworkObjectId), m_NetworkObject.NetworkObjectId.ToString());
|
|
EditorGUILayout.TextField(nameof(NetworkObject.OwnerClientId), m_NetworkObject.OwnerClientId.ToString());
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsSpawned), m_NetworkObject.IsSpawned);
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsLocalPlayer), m_NetworkObject.IsLocalPlayer);
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsOwner), m_NetworkObject.IsOwner);
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsOwnedByServer), m_NetworkObject.IsOwnedByServer);
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsPlayerObject), m_NetworkObject.IsPlayerObject);
|
|
if (m_NetworkObject.IsSceneObject.HasValue)
|
|
{
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.IsSceneObject), m_NetworkObject.IsSceneObject.Value);
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.TextField(nameof(NetworkObject.IsSceneObject), "null");
|
|
}
|
|
EditorGUILayout.Toggle(nameof(NetworkObject.DestroyWithScene), m_NetworkObject.DestroyWithScene);
|
|
EditorGUILayout.TextField(nameof(NetworkObject.NetworkManager), m_NetworkObject.NetworkManager == null ? "null" : m_NetworkObject.NetworkManager.gameObject.name);
|
|
GUI.enabled = guiEnabled;
|
|
|
|
if (m_NetworkObject.NetworkManager != null && m_NetworkObject.NetworkManager.IsServer)
|
|
{
|
|
m_ShowObservers = EditorGUILayout.Foldout(m_ShowObservers, "Observers");
|
|
|
|
if (m_ShowObservers)
|
|
{
|
|
HashSet<ulong>.Enumerator observerClientIds = m_NetworkObject.GetObservers();
|
|
|
|
EditorGUI.indentLevel += 1;
|
|
|
|
while (observerClientIds.MoveNext())
|
|
{
|
|
if (m_NetworkObject.NetworkManager.ConnectedClients[observerClientIds.Current].PlayerObject != null)
|
|
{
|
|
EditorGUILayout.ObjectField($"ClientId: {observerClientIds.Current}", m_NetworkObject.NetworkManager.ConnectedClients[observerClientIds.Current].PlayerObject, typeof(GameObject), false);
|
|
}
|
|
else
|
|
{
|
|
EditorGUILayout.TextField($"ClientId: {observerClientIds.Current}", EditorStyles.label);
|
|
}
|
|
}
|
|
|
|
EditorGUI.indentLevel -= 1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
base.OnInspectorGUI();
|
|
|
|
var guiEnabled = GUI.enabled;
|
|
GUI.enabled = false;
|
|
EditorGUILayout.TextField(nameof(NetworkObject.GlobalObjectIdHash), m_NetworkObject.GlobalObjectIdHash.ToString());
|
|
EditorGUILayout.TextField(nameof(NetworkObject.NetworkManager), m_NetworkObject.NetworkManager == null ? "null" : m_NetworkObject.NetworkManager.gameObject.name);
|
|
GUI.enabled = guiEnabled;
|
|
}
|
|
}
|
|
|
|
// Saved for use in OnDestroy
|
|
private GameObject m_GameObject;
|
|
|
|
/// <summary>
|
|
/// Invoked once when a NetworkObject component is
|
|
/// displayed in the inspector view.
|
|
/// </summary>
|
|
private void OnEnable()
|
|
{
|
|
// We set the GameObject upon being enabled because when the
|
|
// NetworkObject component is removed (i.e. when OnDestroy is invoked)
|
|
// it is no longer valid/available.
|
|
m_GameObject = (target as NetworkObject).gameObject;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invoked once when a NetworkObject component is
|
|
/// no longer displayed in the inspector view.
|
|
/// </summary>
|
|
private void OnDestroy()
|
|
{
|
|
// Since this is also invoked when a NetworkObject component is removed
|
|
// from a GameObject, we go ahead and check for a NetworkObject when
|
|
// this custom editor is destroyed.
|
|
NetworkBehaviourEditor.CheckForNetworkObject(m_GameObject, true);
|
|
}
|
|
}
|
|
}
|