Skip to content

Rain1950/FishyTransportSwitcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

FishyTransportSwitcher

FishyTransportSwitcher is a tool for switching FishNet transport from within Unity Editor GUI, while also providing easy transport checking within scripts. It's handy tool for testing purposes or multi transport scenarios. Originally developed for Rain's Golf https://store.steampowered.com/app/3864990/Rains_Golf/.

Installation

This is a FishNet plugin, make sure it's installed before continuing. FishNet is available here: https://github.com/FirstGearGames/FishNet

After installing FishNet download latest release unitypackage and proceed with installation. https://github.com/Rain1950/FishyTransportSwitcher/releases/latest

Usage/Examples

One of the most helpful usage examples of FishyTransportSwitcher is switching to Unity transport to test multiplayer functionality on one device with multiple game instances running (thus avoiding Steam limitations)

FishyTransportSwitcher consists of 3 main parts: Editor transport switching GUI, Configuration settings page in Project settings window and TransportSwitcher Class exposed to scripts.

Transport Switching GUI:

This dropdown makes it easy to switch transport in Editor. It's saved in EditorPrefs so each project user can have their own transport configuration.

obraz

Configuration menu:

To access configuration menu open Project Settings -> FishNet -> FishyTransportSwitcher

It has two options: Build Transport and Editor transport switch offset (on X axis). ⚠️ Build transport is important⚠️ - this is the transport that will be used in game build. It's saved in resources folder in a file "FishyTransportSwitcher.Config.xml" and it's separate from what you set in Editor GUI switch.

Button positions option does not need any explanation - just move it and see what happens. obraz

Checking current transport

To check currently used transport use CurrentTransport member of TransportSwitcher class.

To use multiple transports it's recommended to use MultiPass transport (https://fish-networking.gitbook.io/docs/fishnet-building-blocks/transports/multipass).

Attach any transports you will be using to NetworkManager and optionally add TransportInitializer component. It's an example/starting point for using FishyTransportSwitcher. It's written to only use default transports - Tugboat or Yak but feel free to expand it or completly rewrite it for your liking.

Example 1:

 if (TransportSwitcher.CurrentTransport == TransportSwitcher.Transport.FishyUnityTransport) {
        LobbiesQuery = new UnityLobbiesQuery();
  }

Example 2:

  async private void Start()
    {
        if (TransportSwitcher.CurrentTransport == TransportSwitcher.Transport.FishyUnityTransport)
        {
            await IntializeUnityServices();
            await SignInAnonymousAsnyc();
        }
    }

Example 3:

if(TransportSwitcher.CurrentTransport != TransportSwitcher.Transport.FishySteamworks) return;

  if (SteamManager.Initialized)
    {
        SteamFriends.ActivateGameOverlayInviteDialog(LobbyManager.Instance.currentLobby.Id.ToSteamID());
    }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages