新增FishNet文档

This commit is contained in:
2026-09-20 15:53:11 +08:00
parent c403145db9
commit 179c282405
431 changed files with 15476 additions and 0 deletions
@@ -0,0 +1,26 @@
---
description: Instructions for how to update FishNet to the latest or Pro version.
---
# Updating FishNet
Before making large changes to your project, it's always advised to back it up by using your version control software or a manual backup. We advise doing this step first before trying to update your FishNet version, even if the likelihood of it breaking anything is quite small.
{% hint style="success" %}
If you have a project using the free version of FishNet and want to update it to FishNet Pro, you can follow these exact same steps.
{% endhint %}
### Steps
1. Make a project backup/commit.
2. Uninstall FishNet. You can do this from the Package Manager or by deleting the FishNet folder in the Unity Editor.
3. Don't close Unity
4. Import the latest or Pro version of FishNet.
{% hint style="info" %}
You can find instructions for importing the free version of FishNet here: [installing-fish-networking.md](../../tutorials/getting-started/installing-fish-networking.md "mention")
And instructions for purchasing and importing the Pro version here: [upgrading-to-fishnet-pro.md](upgrading-to-fishnet-pro.md "mention")
{% endhint %}
Your project should now be correctly updated to the latest version, if you run into any issues along the way, please feel free to reach out for help in our discord server: [https://discord.gg/Ta9HgDh4Hj](https://discord.gg/Ta9HgDh4Hj)
@@ -0,0 +1,365 @@
---
description: >-
Sometimes logic has to be changed for the better, but it doesn't have to be a
rough experience. You may find planned breaks here, and how to resolve them.
---
# Changes in API
## 4.1.0
**NetworkManager**
> **CanLog, Log, LogWarning, LogError**
>
> Errors may show that these methods no longer exist, they however do but with different usage.
>
> These methods have been moved under the namespace FishNet.Managing and are now called using either a NetworkManager reference, valid or null, or by using NetworkManagerExtensions.MethodName.
> **GetPooledInstantiated(GameObject, ushort, bool) is missing**
>
> Changed to GetPooledInstantiated(GameObject, bool).
> **GetPooledInstantiated(int, bool) is missing**
>
> Changed to GetPooledInstantiated(int, ushort, bool).
> **GetPooledInstantiated(NetworkObject, ushort, bool) is missing**
>
> Changed to GetPooledInstantiated(NetworkObject, bool).
> **StorePooledInstantiated(NetworkObject, int, bool) is missing.**
>
> Changed to StorePooledInstantiated(NetworkObject, bool).
> **Authenticator is missing.**
>
> Use ServerManager.GetAuthenticator or ServerManager.SetAuthenticator instead.
> **GetInstance(bool warn = true) is missing.**
>
> Use GetInstance() or TryGetInstance(T).
**TimeManager**
> **LastPacketTick**
>
> Changed from uint to EstimatedTick.
>
> You may see errors such as: cannot convert type 'uint' to 'EstimatedTick'.
>
> Use LastPacketTick.LastRemoteTick. Reviewing the EstimatedTick API is recommended to leverage it's features better.
#### Misc
**PooledReader and PooledWriter**
> **Dispose and DisposeLength are missing.**
>
> Use Store and StoreLength.
**ReaderPool and WriterPool**
> **GetReader, GetWriter have been renamed to be consistent with other API.**
>
> Changed to Retrieve.
> **Recycle has been renamed to be consistent with other API.**
>
> Changed to Store.
**Observer Conditions**
> **DistanceCondition.UpdateFrequently is missing.**
>
> Method no longer used.
> **ObserverCondition.Timed is missing.**
>
> Changed to GetConditionType().
> **ObserverCondition.Clone is missing.**
>
> Method no longer used. Use Awake to initialize custom conditions.
> **MatchCondition had several fields replaced. The following fields were removed:**
>
> * **MatchConnections**
> * Changed to GetMatchConnections(NetworkManager)
> * **ConnectionMatch**
> * Changed to GetConnectionMatches(NetworkManager)
> * **MatchObject**
> * Changed to GetMatchObjects(NetworkManager)
> * **ObjectMatch**
> * Changed to GetObjectMatches(NetworkManager)
**SyncTypes**
> **SyncVar and SyncObject attribute are no longer used.**
>
> Remove SyncVar/SyncObject attribute. When setting or getting the SyncVar's value be sure to use the `.Value` of it instead of trying to set or get it directly.
> **ISyncType, SyncBase.Reset is missing.**
>
> Changed to ResetState.
> **SyncBase.Read(PooledReader) is missing.**
>
> Changed to Read(PooledReader, bool).
> **SyncVar fields must be declared as SyncVar.**
>
> Fields previously identified as SyncVars using the SyncVar attributes must now use SyncVar\<Type> as the field, and must be initialized like SyncObjects.
>
> ```csharp
> // Example.
> private readonly SyncVar<float> _health = new();
>
> private void MyMethod()
> {
> Debug.Log($"Current health is {_health.Value}");
> // Set health to a new value.
> _health.Value = 10f;
> }
> ```
**SceneUnloadEndEventArgs**
> **UnloadedSceneHandles, UnloadedSceneNames, UnloadedScenesV2 is missing.**
>
> Changed to UnloadedScenes.
**PredictedObject**
> **XYZMethod is missing.**
>
> A variety of methods within PredictedObject have been replaced by a simpler variant.
>
> The following methods were removed:
>
> * **GetSmoothTicks**
> * **GetInterpolation**
> * **SetInterpolation**
>
> The removed methods have been replaced with **SetSpectatorSmoothingType.**
**Misc**
> **Broadcast: cannot convert from 'method group'.**
>
> Broadcast handlers now require Channel as the last parameter.
>
> ```csharp
> // Example:
> // Before
> private void OnResponseBroadcast(ResponseBroadcast rb)
> // After
> private void OnResponseBroadcast(ResponseBroadcast rb, Channel channel)
> ```
> **IsClient, IsServer, IsHost, IsServerOnly, IsClientOnly are Obsolete.**
>
> These fields return if the socket is started and for many those intentions were not clear. In result all instances have been replaced with Started versions of each; eg: IsClientStarted.
>
> To check if an object is initialized for the server or client use Initialized varients, such as IsClientInitialized.
> **SceneLoad/UnloadData PreferredScene change.**
>
> PreferredScene has been changed to a structure to allow setting separate preferred scenes for server and client.
> **NetworkAnimator.ForceSend is missing.**
>
> Method no longer used. NetworkAnimator.SendAll may be of use.
> **NetworkConnection.Tick is missing.**
>
> Changed to NetworkConnection.LocalTick
> **ServerObjects RebuildObservers method is missing.**
>
> All IEnumerable RebuildObservers methods have been replaced with IList variants.
> **ServerManager.Authenticator is missing.**
>
> Changed to GetAuthenticator and SetAuthenticator.
> **NetworkBehaviour.DirtySyncTypes is missing.**
>
> Method no longer used.
> **NetworkObject.ResetForObjectPool is missing.**
>
> Changed to ResetState.
> **NetworkObject.ClientInitialized is missing.**
>
> Changed to NetworkObject.IsClientInitialized.
> **Replicate and Reconcile attribute Resends is missing.**
>
> Replaced with PredictionManager.RedundancyCount.
> **Rollback(PreciseTick, PhysicsType, bool asOwner)**
>
> Changed to Rollback(PreciseTick, RollbackPhysicsType, bool)
> **ReadDictionary\<TKey, TValue>()**
>
> Changed to ReadDictionaryAllocated\<TKey, TValue>()
> **ListCache\<T>, ListCaches is missing**
>
> Classes replaced with better versions under a different namespace.
>
> The following are their replacements:
>
> * CollectionCaches
> * ResettableCollectionCaches
> * ObjectCaches
> * ResettableObjectCaches
> **RetrieveObject(int, bool) is missing.**
>
> Changed to RetrieveObject(int, ushort, bool).
## 3.3.0
Unscheduled break.
> **ObserversRpc IncludeOwner is missing.**
>
> Changed to ExcludeOwner. **Remeber to flip the values.**
## 3.1.1
**Prediction Changes**
Replicate datas must now implement _IReplicateData_, and Reconcile datas must implement _IReconcileData_.
As of this release prediction methods can now have their Channels set, so you may ensure certain messages never drop. In result your replicate method signatures should now be as shown below.
```csharp
private void MyReplicate(ReplicateData rd, bool asServer, Channel channel = Channel.Unreliable, bool replaying = false)
```
Reconcile methods must also now include a Channel parameter as shown.
```csharp
private void MyReconcile(ReconcileData rd, bool asServer, Channel channel = Channel.Unreliable)
```
For more detailed instructions on these changes see the [prediction guide](../features/prediction/).
**TimeManager Fields and Events**
Many prediction related events and values were moved out of the _TimeManager_ and placed into the _PredictionManager_. Use PredictionManager.XYZ instead of TimeManager.XYZ.
The following events and fields were moved.
* LastReconcileTick.
* LastReplicateTIck.
* IsReplaying(), IsReplaying(Scene).
* OnPreReconcile.
* OnPostReconcile.
* OnPreReplicateReplay.
* OnPostReplicateReplay.
In addition two events had their signatures changed. OnPre/PostReplicateReplay now also includes the tick being replayed.
> **Changed Signature OnPre/PostReplicateReplay(PhysicsScene, PhysicsScene2D).**
>
> Replaced with OnPre/PostReplicateReplay(uint, uint).
**Misc**
> **Changed LoggingConfiguration is now a base class.**
>
> LoggingConfiguration can be used to create custom loggers. _LevelLoggingConfiguration_ is now the default logger. If you were previously using a LoggingConfiguration with custom settings create new as a LevelLoggingConfiguration.
> **Changed Signature NetworkConnection.LoadedStartScenes.**
>
> Replaced with NetworkConnection.LoadedStartScenes().
> **Removed RigidbodyPauser.SetTimeManager.**
>
> Replaced with RigidbodyPauser.SetPredictionManager; now takes PredictionManager argument.
> **Removed NetworkBehaviour/NetworkObject.Deinitializing.**
>
> Replaced with NetworkBehaviour/NetworkObject.IsDeinitializing.
> **Removed NetworkObject.SceneObject.**
>
> Replaced with NetworkObject.IsSceneObject.
> **Removed ServerOnlyCondition.**
>
> Replaced with with OwnerOnlyCondition.
> **Removed TimeManager.TickPercent.**
>
> Replaced with TimeManager.GetPreciseTick or TimeManager.GetTickPercent.
> **Removed TimeManager.TicksToTime(bool).**
>
> Replaced with TimeManager.TicksToTime(TickType).
> **Removed TimeManager.OnPhysicsSimulation.**
>
> Replaced with TimeManager.OnPrePhysicsSimulation.
> **Removed NetworkManager.Authenticator.**
>
> Replaced with ServerManager.Get/SetAuthenticator.
> **Removed ServerManager.Authenticator.**
>
> Replaced with ServerManager.Get/SetAuthenticator.
> **Changed Signature Transport.GetServerBindAddress.**
>
> Replaced with Transport.GetServerBindAddress(IPAddressType).
> **Changed Signature Transport.SetServerBindAddress(string).**
>
> Replaced with Transport.SetServerBindAddress(string, IPAddressType).
> **Removed ListCaches.XYZCache.**
>
> Replaced with ListCaches.GetXYZCache, ListCaches.SetXYZCache.
## 2.0.0
**Misc**
> **Removed NetworkBehaviour/NetworkObject.OwnerIsValid.**
>
> Replaced with NetworkBehaviour/NetworkObject.Owner.IsValid.
> **Removed NetworkBehaviour/NetworkObject.OwnerIsActive.**
>
> Replaced with NetworkBehaviour/NetworkObject.Owner.IsActive.
> **Changed Name LoadOptions.DisallowStacking.**
>
> Change references from DisallowStacking to AllowStacking and inverse value.
> **Changed Name Several enums are being changed from plural to singular. Those changed will be SceneScopeTypes, ServerUnloadModes, LocalConnectionStates, RemoteConnectionStates.**
>
> Remove plural (s) from each enum reference. EG: SceneScopeTypes will become SceneScopeType.
> **Removed TimeManager.TicksToTimeDouble.**
>
> Replaced with TimeManager.TicksToTime; now returns a double.
> **Changed Signature Transport.Initialize(networkManager).**
>
> Add int as a second parameter to your transport.Initialize method. Include Transport.Index within the following callback structures: ClientConnectionStateArgs, ServerConnectionStateArgs, RemoteConnectionStateArgs, ClientReceivedDataArgs, ServerReceivedDataArgs.
> **Removed Transport.GetChannelCount(), Transport.GetDefaultReliableChannel(), Transport.GetDefaultUnreliableChannel().**
>
> Delete call or overrides to methods. There will always only be two channel counts, 0 for reliable and 1 for unreliable.
> **Removed Transport.GetDefaultReliableChannel() and GetDefaultUnreliableChannel().**
>
> Delete calls or overrides to methods. Channel.Reliable should always be id 0, and Channel.Unreliable id 1.
@@ -0,0 +1,80 @@
---
description: >-
Instructions for how to purchase and then install FishNet Pro in your Unity
project.
---
# Upgrading to FishNet Pro
## Purchasing FishNet Pro
Fish-Networking Pro can be gotten by purchasing it from the Unity Asset Store or from sponsoring the project on GitHub or Patreon.
<table data-view="cards"><thead><tr><th></th><th></th><th><select><option value="BQHY5sKhAVWC" label="Package Manager" color="blue"></option><option value="EADlyuNGbN5Y" label="Best Deal" color="blue"></option><option value="dt25hDGUI3cb" label="Alternative" color="blue"></option></select></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Unity Asset Store</strong></td><td><mark style="color:$info;">Purchase directly on the Unity Asset store to get lifetime access to future updates and be able to import it through Unity's Package Manager.</mark></td><td><span data-option="BQHY5sKhAVWC">Package Manager</span></td><td><a href="../../.gitbook/assets/unity-asset-store-card.png">unity-asset-store-card.png</a></td><td><a href="upgrading-to-fishnet-pro.md#the-unity-asset-store">#the-unity-asset-store</a></td></tr><tr><td>GitHub Sponsors</td><td><mark style="color:$info;">Sponsor FishNet on GitHub to get access to FishNet Pro on a monthly or lifetime basis. This option also gives the most back to the developers.</mark></td><td><span data-option="EADlyuNGbN5Y">Best Deal</span></td><td><a href="../../.gitbook/assets/github-dark-card.png">github-dark-card.png</a></td><td><a href="upgrading-to-fishnet-pro.md#github-sponsors">#github-sponsors</a></td></tr><tr><td>Patreon</td><td><mark style="color:$info;">Get access to FishNet Pro on a monthly or lifetime basis by sponsoring the developer on Patreon.</mark></td><td><span data-option="dt25hDGUI3cb">Alternative</span></td><td><a href="../../.gitbook/assets/patreon-card.png">patreon-card.png</a></td><td><a href="upgrading-to-fishnet-pro.md#patreon">#patreon</a></td></tr></tbody></table>
***
### Unity Asset Store
Purchasing and installing via the Unity Asset Store should be very familiar to a regular Unity user. With this method you will have lifetime access to FishNet and be able to download the latest version available on the Asset Store through the Unity Package Manager.
1. Open your Unity project.
2. Go to **Window > Asset Store** or visit the [Unity Asset Store online](https://assetstore.unity.com/).
3. Search for **FishNet Pro** or navigate to this link: [https://assetstore.unity.com/packages/tools/network/fishnet-pro-networking-evolved-287711](https://assetstore.unity.com/packages/tools/network/fishnet-pro-networking-evolved-287711)
4. Click **Buy Now**, proceed with the payment, and then click **Open in Unity**.
5. In Unity, go to **Package Manager** (`Window > Package Manager`).
6. Select **My Assets**, find **FishNet Pro**, and click **Download** and then **Import**.
{% hint style="success" %}
You can also gain access to Priority Support with your asset store purchase! Your priority support months begin only after you claim your perks on our Discord; see [After Purchasing](https://fish-networking.gitbook.io/docs/overview/readme/pro-projects-and-support#after-purchasing) please.
The amount of months received are directly related to what goes back into the project after Unity's fees. If you purchase Fish-Networking Pro at $50 you will receive 4 months of Priority Support, and 2 months at $25.
{% endhint %}
***
### GitHub Sponsors
Through GitHub Sponsors you can get lifetime or monthly access to FishNet at various prices. When obtaining Fish-Networking Pro through GitHub you will have access to both Pro and the paid Projects.
1. Head over to the [FirstGearGames GitHub Sponsors](https://github.com/sponsors/FirstGearGames) page.
2. Select one of the monthly or one-time options and then proceed to the payment.
3. You can now go to the [Fish-Networking website](https://www.fish-networking.com/#downloads).
4. Login with the **GitHub Login** option and then download the FishNet `.unitypackage` file.
5. In Unity, go to **Assets > Import Package > Custom Package…**
6. Select the downloaded `.unitypackage` file.
7. Click **Import** to bring all the FishNet files into your project.
{% hint style="warning" %}
You **must** make a one-time payment of at least $10 for your initial downloads. Afterwards you're welcome to switch to $2/month for updates. You may leave the updates tier and join us again at any time.
{% endhint %}
When on any $10 tier or higher you will gain access to Priority Support, this includes your initial purchase; see [support tier options](https://fish-networking.gitbook.io/docs/overview/readme/pro-projects-and-support#support-tier-options) for more information on this.
{% hint style="success" %}
Find out more perks of using this method [here](../../overview/readme/pro-projects-and-support.md#github-and-patreon-perks).
{% endhint %}
***
### Patreon
When obtaining Fish-Networking Pro through Patreon you will have access to both Pro and the paid Projects. You **must** make a one-time payment of $10 for your initial downloads. Afterwards you're welcome to switch to $2/month for updates. You may leave the updates tier and join us again at any time.
1. Head over to the [FirstGearGames Patreon](https://www.patreon.com/firstgeargames) page.
2. Select a membership tier and then proceed to the payment.
3. You can now go to the [Fish-Networking website](https://www.fish-networking.com/#downloads).
4. Login with the **Patreon Login** option and then download the FishNet `.unitypackage` file.
5. In Unity, go to **Assets > Import Package > Custom Package…**
6. Select the downloaded `.unitypackage` file.
7. Click **Import** to bring all the FishNet files into your project.
{% hint style="warning" %}
You **must** make a one-time payment of at least $10 for your initial downloads. Afterwards you're welcome to switch to $2/month for updates. You may leave the updates tier and join us again at any time.
{% endhint %}
When on any $10 tier or higher you will gain access to Priority Support, this includes your initial purchase; see [support tier options](https://fish-networking.gitbook.io/docs/overview/readme/pro-projects-and-support#support-tier-options) for more information on this.
{% hint style="success" %}
Find out more perks of using this method [here](../../overview/readme/pro-projects-and-support.md#github-and-patreon-perks).
{% endhint %}