Skip to content

Instantly share code, notes, and snippets.

View BrentFarris's full-sized avatar
✝️
Some Assembly required

Brent Farris BrentFarris

✝️
Some Assembly required
View GitHub Profile
@BrentFarris
BrentFarris / dynamic-gist-embed.html
Last active August 29, 2015 14:13
Gist iFrame With Working Links
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Dynamic Gist Embedding</title>
</head>
<body>
<div id="gistZone"></div>
@BrentFarris
BrentFarris / Forge-Networking-Host.cs
Last active August 29, 2015 14:13
Host a Server With Forge Networking
using UnityEngine;
using BeardedManStudios.Network;
public class StartServer : MonoBehaviour
{
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication method
public int playerCount = 31; // Maximum player count -- excluding this server
private void Start()
@BrentFarris
BrentFarris / Forge-Networking-Client.cs
Last active August 29, 2015 14:13
Connect to a Server With Forge Networking
using UnityEngine;
using BeardedManStudios.Network;
public class StartServer : MonoBehaviour
{
public string host = "127.0.0.1"; // IP address
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication method
private void Start()
@BrentFarris
BrentFarris / Forge-StartGame.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Autostart Scene
using UnityEngine;
using BeardedManStudios.Network;
public class StartGame : MonoBehaviour
{
public string host = "127.0.0.1"; // IP address
public ushort port = 15937; // Port number
public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP; // Communication protocol
public int playerCount = 31; // Maximum player count -- excluding this server
public string sceneName = "Game"; // Scene to load
@BrentFarris
BrentFarris / Forge-Starting-Server.cs
Last active October 2, 2015 04:55
Forge Networking Sample: Start a Server
// Arguments:
// ushort <PORT_NUMBER>
// Networking.TransportationProtocolType <PROTOCOL_TYPE>
// int <MAX_PLAYERS>
Networking.Host((ushort)15937, Networking.TransportationProtocolType.UDP, 31);
@BrentFarris
BrentFarris / Forge-Check-Connected.cs
Created January 10, 2015 23:54
Forge Networking Sample: Checking if Connected
if (Networking.Connected)
{
// TODO: Fancy stuff
}
@BrentFarris
BrentFarris / Forge-Register-Connected.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Registering Connected
// Note: 15937 is the port number of the socket you started the connection on
Networking.Sockets[15937].connected += MyMethod;
void MyMethod()
{
Debug.Log("Connection Established");
}
// Or you can in-line if you wish
@BrentFarris
BrentFarris / Forge-Register-Disconnected.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Registering Disconnected
// Note: 15937 is the port number of the socket you started the connection on
Networking.Sockets[15937].disconnected += MyMethod;
void MyMethod()
{
Debug.Log("Connection Closed or Lost");
}
// Or you can in-line if you wish
@BrentFarris
BrentFarris / Forge-Connecting-to-Server.cs
Last active August 29, 2015 14:13
Forge Networking Sample: Connecting to Server
// Arguments:
// string <IP_ADDRESS>
// ushort <PORT_NUMBER>
// Networking.TransportationProtocolType <PROTOCOL_TYPE>
// optional bool <IS_WIN_RT> [default false]
Networking.Connect("127.0.0.1", 15937, Networking.TransportationProtocolType.UDP, true);
@BrentFarris
BrentFarris / Forge-Register-Client-Disconnect.cs
Last active June 3, 2018 16:37
Forge Networking Sample: Registering Disconnected for Client
// Note: 15937 is the port number of the socket you started the connection on
Networking.Sockets[15937].serverDisconnected += ByeBye;
void ByeBye(string reason)
{
Debug.Log("The server has disconnected you because of: " + reason);
}
// Or you can in-line if you wish
Networking.Sockets[15937].serverDisconnected += delegate(string reason)