Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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 @@ -11,7 +11,7 @@ namespace Unity.Netcode.Editor
[CanEditMultipleObjects]
public partial class NetcodeEditorBase<TT> : UnityEditor.Editor where TT : MonoBehaviour
{
/// <inheritdoc/>
/// <inheritdoc cref="UnityEditor.Editor.OnEnable"/>
public virtual void OnEnable()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ namespace Unity.Netcode.Components
///
/// <list type="bullet">
///
/// <item><b>Snap:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <item><description><b>Snap:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <see cref="StaleDataHandling.Ignore"/> and no <see cref="NetworkBehaviour.OnReanticipate"/> callback),
/// the moment a more up-to-date value is received from the authority, it will simply replace the anticipated value,
/// resulting in a "snap" to the new value if it is different from the anticipated value.</item>
/// resulting in a "snap" to the new value if it is different from the anticipated value.</description></item>
///
/// <item><b>Smooth:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <item><description><b>Smooth:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <see cref="Netcode.StaleDataHandling.Ignore"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> callback that calls
/// <see cref="Smooth"/> from the anticipated value to the authority value with an appropriate
/// <see cref="Mathf.Lerp"/>-style smooth function), when a more up-to-date value is received from the authority,
/// it will interpolate over time from an incorrect anticipated value to the correct authoritative value.</item>
/// it will interpolate over time from an incorrect anticipated value to the correct authoritative value.</description></item>
///
/// <item><b>Constant Reanticipation:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <item><description><b>Constant Reanticipation:</b> In this mode (with <see cref="StaleDataHandling"/> set to
/// <see cref="Netcode.StaleDataHandling.Reanticipate"/> and an <see cref="NetworkBehaviour.OnReanticipate"/> that calculates a
/// new anticipated value based on the current authoritative value), when a more up-to-date value is received from
/// the authority, user code calculates a new anticipated value, possibly calling <see cref="Smooth"/> to interpolate
/// between the previous anticipation and the new anticipation. This is useful for values that change frequently and
/// need to constantly be re-evaluated, as opposed to values that change only in response to user action and simply
/// need a one-time anticipation when the user performs that action.</item>
/// need a one-time anticipation when the user performs that action.</description></item>
///
/// </list>
///
Expand Down Expand Up @@ -138,7 +138,7 @@ public bool ShouldReanticipate
/// Anticipate that, at the end of one round trip to the server, this transform will be in the given
/// <see cref="newPosition"/>
/// </summary>
/// <param name="newPosition"></param>
/// <param name="newPosition">The anticipated position</param>
public void AnticipateMove(Vector3 newPosition)
{
if (NetworkManager.ShutdownInProgress || !NetworkManager.IsListening)
Expand All @@ -164,7 +164,7 @@ public void AnticipateMove(Vector3 newPosition)
/// Anticipate that, at the end of one round trip to the server, this transform will have the given
/// <see cref="newRotation"/>
/// </summary>
/// <param name="newRotation"></param>
/// <param name="newRotation">The anticipated rotation</param>
public void AnticipateRotate(Quaternion newRotation)
{
if (NetworkManager.ShutdownInProgress || !NetworkManager.IsListening)
Expand All @@ -190,7 +190,7 @@ public void AnticipateRotate(Quaternion newRotation)
/// Anticipate that, at the end of one round trip to the server, this transform will have the given
/// <see cref="newScale"/>
/// </summary>
/// <param name="newScale"></param>
/// <param name="newScale">The anticipated scale</param>
public void AnticipateScale(Vector3 newScale)
{
if (NetworkManager.ShutdownInProgress || !NetworkManager.IsListening)
Expand All @@ -216,7 +216,7 @@ public void AnticipateScale(Vector3 newScale)
/// Anticipate that, at the end of one round trip to the server, the transform will have the given
/// <see cref="newState"/>
/// </summary>
/// <param name="newState"></param>
/// <param name="newState">The anticipated transform state</param>
public void AnticipateState(TransformState newState)
{
if (NetworkManager.ShutdownInProgress || !NetworkManager.IsListening)
Expand Down Expand Up @@ -463,9 +463,9 @@ public override void OnDestroy()
/// <see cref="to"/> over <see cref="durationSeconds"/> of real time. The duration uses
/// <see cref="Time.deltaTime"/>, so it is affected by <see cref="Time.timeScale"/>.
/// </summary>
/// <param name="from"></param>
/// <param name="to"></param>
/// <param name="durationSeconds"></param>
/// <param name="from">Starting transform state</param>
/// <param name="to">Target transform state</param>
/// <param name="durationSeconds">Interpolation time in seconds</param>
public void Smooth(TransformState from, TransformState to, float durationSeconds)
{
var transform_ = transform;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void UpdateFrom(ref Vector3 vector3)
/// Constructor
/// </summary>
/// <param name="vector3">The initial axial values (converted to half floats) when instantiated.</param>
/// <param name="vector3AxisToSynchronize">The axis to synchronize.</param>
/// <param name="axisToSynchronize">The axis to synchronize.</param>
public HalfVector3(Vector3 vector3, bool3 axisToSynchronize)
{
Axis = half3.zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ protected internal override void OnConvertTransformSpace(Transform transform, bo
}

/// <summary>
/// A <see cref="BufferedLinearInterpolator<T>"/> <see cref="Vector3"/> implementation.
/// A <see cref="BufferedLinearInterpolator{T}"/> <see cref="Vector3"/> implementation.
/// </summary>
public class BufferedLinearInterpolatorVector3 : BufferedLinearInterpolator<Vector3>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,9 +1482,8 @@ private bool ShouldSynchronizeHalfFloat(ulong targetClientId)
/// <remarks>
/// If a derived class overrides this, then make sure to invoke this base method!
/// </remarks>
/// <typeparam name="T"></typeparam>
/// <param name="serializer"></param>
/// <param name="targetClientId">the clientId being synchronized (both reading and writing)</param>
/// <typeparam name="T">The serializer type for buffer operations</typeparam>
/// <param name="serializer">The buffer serializer used for network state synchronization</param>
protected override void OnSynchronize<T>(ref BufferSerializer<T> serializer)
{
var targetClientId = m_TargetIdBeingSynchronized;
Expand Down Expand Up @@ -3171,7 +3170,7 @@ protected virtual void OnInitialize(ref NetworkTransformState replicatedState)
/// This method is only invoked by the owner
/// Use: OnInitialize(ref NetworkTransformState replicatedState) to be notified on all instances
/// </summary>
/// <param name="replicatedState"></param>
/// <param name="replicatedState">The NetworkVariable containing the <see cref="NetworkTransformState"/></param>
protected virtual void OnInitialize(ref NetworkVariable<NetworkTransformState> replicatedState)
{

Expand Down Expand Up @@ -3498,11 +3497,11 @@ internal override void InternalOnNetworkObjectParentChanged(NetworkObject parent
/// The parameters are broken up into pos / rot / scale on purpose so that the caller can perturb
/// just the desired one(s)
/// </summary>
/// <param name="posIn"></param> new position to move to. Can be null
/// <param name="rotIn"></param> new rotation to rotate to. Can be null
/// <param name="posIn">new position to move to. Can be null</param>
/// <param name="rotIn">new rotation to rotate to. Can be null</param>
/// <param name="scaleIn">new scale to scale to. Can be null</param>
/// <param name="teleportDisabled">When true (the default) the <see cref="NetworkObject"/> will not be teleported and, if enabled, will interpolate. When false the <see cref="NetworkObject"/> will teleport/apply the parameters provided immediately.</param>
/// <exception cref="Exception"></exception>
/// <exception cref="Exception">Thrown when the function is called on non-spawned object or, when it's called without proper authority</exception>
public void SetState(Vector3? posIn = null, Quaternion? rotIn = null, Vector3? scaleIn = null, bool teleportDisabled = true)
{
if (!IsSpawned)
Expand Down Expand Up @@ -3638,10 +3637,10 @@ private void SetStateServerRpc(Vector3 pos, Quaternion rot, Vector3 scale, bool
/// This is intended to be used on already spawned objects, for setting the position of a dynamically spawned object just apply the transform values prior to spawning. <br />
/// With player objects, override the <see cref="OnNetworkSpawn"/> method and have the authority make adjustments to the transform prior to invoking base.OnNetworkSpawn.
/// </remarks>
/// <param name="newPosition"></param> new position to move to.
/// <param name="newRotation"></param> new rotation to rotate to.
/// <param name="newPosition">new position to move to.</param>
/// <param name="newRotation">new rotation to rotate to.</param>
/// <param name="newScale">new scale to scale to.</param>
/// <exception cref="Exception"></exception>
/// <exception cref="Exception">Thrown when called from a non-authoritative context (client without ownership)</exception>
public void Teleport(Vector3 newPosition, Quaternion newRotation, Vector3 newScale)
{
if (!CanCommitToTransform)
Expand Down Expand Up @@ -3703,7 +3702,7 @@ private void UpdateInterpolation()
}
}

/// <inheritdoc/>
/// <inheritdoc cref="INetworkUpdateSystem.OnUpdate"/>
/// <remarks>
/// If you override this method, be sure that:
/// - Non-authority always invokes this base class method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ internal void OnValidate()
/// <summary>
/// Returns a base64 encoded version of the configuration
/// </summary>
/// <returns></returns>
/// <returns>base64 encoded string containing the serialized network configuration</returns>
public string ToBase64()
{
NetworkConfig config = this;
Expand Down Expand Up @@ -271,8 +271,8 @@ internal void ClearConfigHash()
/// <summary>
/// Gets a SHA256 hash of parts of the NetworkConfig instance
/// </summary>
/// <param name="cache"></param>
/// <returns></returns>
/// <param name="cache">When true, caches the computed hash value for future retrievals, when false, always recomputes the hash</param>
/// <returns>A 64-bit hash value representing the configuration state</returns>
public ulong GetConfig(bool cache = true)
{
if (m_ConfigHash != null && cache)
Expand Down Expand Up @@ -316,8 +316,11 @@ public ulong GetConfig(bool cache = true)
/// <summary>
/// Compares a SHA256 hash with the current NetworkConfig instances hash
/// </summary>
/// <param name="hash"></param>
/// <returns></returns>
/// <param name="hash">The 64-bit hash value to compare against this configuration's hash</param>
/// <returns>
/// True if the hashes match, indicating compatible configurations.
/// False if the hashes differ, indicating potentially incompatible configurations.
/// </returns>
public bool CompareConfig(ulong hash)
{
return hash == GetConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class NetworkPrefabsList : ScriptableObject
/// Adds a prefab to the prefab list. Performing this here will apply the operation to all
/// <see cref="NetworkManager"/>s that reference this list.
/// </summary>
/// <param name="prefab"></param>
/// <param name="prefab">The NetworkPrefab to add to the shared list</param>
public void Add(NetworkPrefab prefab)
{
List.Add(prefab);
Expand All @@ -49,7 +49,7 @@ public void Add(NetworkPrefab prefab)
/// Removes a prefab from the prefab list. Performing this here will apply the operation to all
/// <see cref="NetworkManager"/>s that reference this list.
/// </summary>
/// <param name="prefab"></param>
/// <param name="prefab">The NetworkPrefab to remove from the shared list</param>
public void Remove(NetworkPrefab prefab)
{
List.Remove(prefab);
Expand Down
21 changes: 10 additions & 11 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ internal bool IsBehaviourEditable()
m_NetworkObject.NetworkManager.IsServer;
}

/// TODO: this needs an overhaul. It's expensive, it's ja little naive in how it looks for networkObject in
/// its parent and worst, it creates a puzzle if you are a NetworkBehaviour wanting to see if you're live or not
/// (e.g. editor code). All you want to do is find out if NetworkManager is null, but to do that you
/// need NetworkObject, but if you try and grab NetworkObject and NetworkManager isn't up you'll get
/// the warning below. This is why IsBehaviourEditable had to be created. Matt was going to re-do
/// how NetworkObject works but it was close to the release and too risky to change
// TODO: this needs an overhaul. It's expensive, it's ja little naive in how it looks for networkObject in
// its parent and worst, it creates a puzzle if you are a NetworkBehaviour wanting to see if you're live or not
// (e.g. editor code). All you want to do is find out if NetworkManager is null, but to do that you
// need NetworkObject, but if you try and grab NetworkObject and NetworkManager isn't up you'll get
// the warning below. This is why IsBehaviourEditable had to be created. Matt was going to re-do
// how NetworkObject works but it was close to the release and too risky to change
/// <summary>
/// Gets the NetworkObject that owns this NetworkBehaviour instance.
/// </summary>
Expand Down Expand Up @@ -826,7 +826,7 @@ internal void InternalOnNetworkDespawn()

/// <summary>
/// In client-server contexts, this method is invoked on both the server and the local client of the owner when <see cref="Netcode.NetworkObject"/> ownership is assigned.
/// <para>In distributed authority contexts, this method is only invoked on the local client that has been assigned ownership of the associated <see cref="Netcode.NetworkObject"/>.</para>
/// In distributed authority contexts, this method is only invoked on the local client that has been assigned ownership of the associated <see cref="Netcode.NetworkObject"/>.
/// </summary>
public virtual void OnGainedOwnership() { }

Expand Down Expand Up @@ -863,7 +863,7 @@ internal void InternalOnOwnershipChanged(ulong previous, ulong current)
/// <summary>
/// In client-server contexts, this method is invoked on the local client when it loses ownership of the associated <see cref="Netcode.NetworkObject"/>
/// and on the server when any client loses ownership.
/// <para>In distributed authority contexts, this method is only invoked on the local client that has lost ownership of the associated <see cref="Netcode.NetworkObject"/>.</para>
/// In distributed authority contexts, this method is only invoked on the local client that has lost ownership of the associated <see cref="Netcode.NetworkObject"/>.
/// </summary>
public virtual void OnLostOwnership() { }

Expand Down Expand Up @@ -1348,8 +1348,8 @@ internal void SetNetworkVariableData(FastBufferReader reader, ulong clientId)
/// <summary>
/// Gets the local instance of a NetworkObject with a given NetworkId.
/// </summary>
/// <param name="networkId"></param>
/// <returns></returns>
/// <param name="networkId">The unique network identifier of the NetworkObject to retrieve</param>
/// <returns>The NetworkObject instance if found, null if no object exists with the specified networkId</returns>
protected NetworkObject GetNetworkObject(ulong networkId)
{
return NetworkManager.SpawnManager.SpawnedObjects.TryGetValue(networkId, out NetworkObject networkObject) ? networkObject : null;
Expand All @@ -1372,7 +1372,6 @@ protected NetworkObject GetNetworkObject(ulong networkId)
/// Either BufferSerializerReader or BufferSerializerWriter, depending whether the serializer
/// is in read mode or write mode.
/// </typeparam>
/// <param name="targetClientId">the relative client identifier being synchronized</param>
protected virtual void OnSynchronize<T>(ref BufferSerializer<T> serializer) where T : IReaderWriter
{

Expand Down
Loading