for use with Vis2k Mirror 2018 Branch, Facepunch.Steamworks and Unity 2018.
Requires using .NET 4.x in Unity
A transport for Mirror using SteamworksP2P Networking with Facepunch.Steamworks.
-
Place the prefab
Prefabs/SteamworksNetworkManager
into the scene. -
Set the target network address to the host user's steamid64
-
Set your App ID.
That's it.
-
Create a new gameobject with
SteamworksNetworkManager.cs
andSteamworksTransport.cs
attached. -
If your NetworkManager is marked as DontDestroyOnLoad, attach
Steam.cs
as well. -
If not, create a new gameobject and attach
Steam.cs
and set your App ID if not using the testing app (480)
You could use Client.Instance, then check if null, and IsValid.
There is also Steam.Instance.GetClient(our var client)
which can be used like so
if (Steam.Instance.GetClient(out var client))
{
// do something with client
}
use
// Get ConnectionID from SteamID
if (Steam.Instance.ServerConnectionMap.TryGetByFirst(steamID, out var connectionID)
{
// do something with connectionID
}
// Get SteamID from ConnectionID
if (Steam.Instance.ServerConnectionMap.TryGetBySecond(connectionID, out var steamID))
{
// do something with steamID
}
You can use Unreliable, Reliable, or UnreliableNoDelay channels via
[Command(channel = (int) SteamPacketChannel.Unreliable)]
not specifying a channel is the same as
[Command(channel = (int) SteamPacketChannel.Reliable)]
note that SteamPacketChannel.Internal
is for the transport to communicate connections / disconnects. Anything sent on this channel will be discarded.