728x90
public class MultiPlayerBuildAndRun
{
[MenuItem("Tools/Run Multiplayer/2 Players")]
static void PerformWin64Build2()
{
PerformWin64Build(2);
}
[MenuItem("Tools/Run Multiplayer/3 Players")]
static void PerformWin64Build3()
{
PerformWin64Build(3);
}
[MenuItem("Tools/Run Multiplayer/4 Players")]
static void PerformWin64Build4()
{
PerformWin64Build(4);
}
static void PerformWin64Build(int playerCount)
{
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, BuildTarget.StandaloneWindows);
for (int i = 1; i <= playerCount; i++)
{
BuildPipeline.BuildPlayer(GetScenePaths(),
"Builds/Win64/" + GetProjectName() + i.ToString() + "/" + GetProjectName() + i.ToString() + ".exe",
BuildTarget.StandaloneWindows64, BuildOptions.AutoRunPlayer);
}
}
static string GetProjectName()
{
string[] s = Application.dataPath.Split('/');
return s[s.Length - 2];
}
static string[] GetScenePaths()
{
string[] scenes = new string[EditorBuildSettings.scenes.Length];
for (int i = 0; i < scenes.Length; i++)
{
scenes[i] = EditorBuildSettings.scenes[i].path;
}
return scenes;
}
}
728x90
'Unity' 카테고리의 다른 글
[Unity] Build 여러개 실행할 때 멈추는 현상 해결방법 (0) | 2023.01.02 |
---|---|
[Unity] 클라이언트 기본구조 작성 순서 (0) | 2022.11.29 |
[Unity] 카메라이동(줌인, 줌아웃, 마우스회전, 마우스이동, 방향이동) (0) | 2022.11.17 |
[Unity2D] 캐릭터 픽셀단위로 이동하는 방법 (0) | 2022.11.14 |
[Unity2D] 맵 존관리 방법 (0) | 2022.11.14 |