Skip to content

Instantly share code, notes, and snippets.

@cubed2d
Created February 22, 2014 16:33
Show Gist options
  • Select an option

  • Save cubed2d/9157573 to your computer and use it in GitHub Desktop.

Select an option

Save cubed2d/9157573 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Diagnostics;
public class NetworkBuilder
{
[MenuItem("Networking/Build and Run Server %#x")]
public static void BuildAndRunServer()
{
Build("SirServer");
Run("SirServer", "-Server -Port 3435");
}
[MenuItem("Networking/Build and Run Client")]
public static void BuildAndRunClient()
{
Build("SirClient");
Run("SirClient", "-Client -IP 127.0.0.1 -Port 3435");
}
// SHORTCUT Control+Shift+C
[MenuItem("Networking/Build Client %#c")]
public static void BuildClient()
{
Build("SirClient");
}
// SHORTCUT Control+Shift+V
[MenuItem("Networking/Run Client %#v")]
public static void RunClient()
{
Run("SirClient", "-Client -IP 127.0.0.1 -Port 3435");
}
private static Process Run(string buildName, string args = "")
{
return Process.Start
(
new ProcessStartInfo()
{
FileName = @"D:/UnityBuilds/" + buildName+"/" + buildName +".exe",
Arguments = args
}
);
}
private static void Build(string buildName)
{
// this is an array of allthe scenes you want in the bild // target platform....
BuildPipeline.BuildPlayer(new[] { "Assets/Scenes/GameScene.unity" }, @"D:/UnityBuilds/" + buildName + "/" + buildName + ".exe", BuildTarget.StandaloneWindows, BuildOptions.Development | BuildOptions.AllowDebugging);
// This is the path where you want it save // and make the build debugable!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment