[C#] 일부 방법을 사용하여 디버그 코드 추가(부록)
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
public class BuildPlayer : ScriptableObject
{
static string rootPath = Application.dataPath + Path.DirectorySeparatorChar;
static string rootParent = new DirectoryInfo(rootPath).Parent.FullName + Path.DirectorySeparatorChar;
static string projectName = new DirectoryInfo(rootPath).Parent.Name;
static string scenePath = Application.dataPath + Path.DirectorySeparatorChar + "Scenes" + Path.DirectorySeparatorChar;
static string apkNameDebug = rootParent + projectName + "_Debug_[Date].apk";
static string apkNameRelease = rootParent + projectName + "_Release_[Date].apk";
[MenuItem("Build Player/Build Android Debug", false, 101)]
static void BuildAndroidDebug()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AllowDebugging | BuildOptions.ShowBuiltPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Debug(Auto Deploy)", false, 102)]
static void BuildAndroidDebugAutoDeploy()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.AllowDebugging;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Debug(Auto Deploy And Connect Profiler)", false, 103)]
static void BuildAndroidDebugAutoDeployAndConnectProfiler()
{
AssetDatabase.Refresh();
// set build options and build player
BuildOptions options = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameDebug), BuildTarget.Android, options);
}
[MenuItem("Build Player/Build Android Release", false, 201)]
static void BuildAndroidRelease()
{
// rename all debug scripts to *.rem
RenameDebugScripts();
// set build options and build player
BuildOptions options = BuildOptions.ShowBuiltPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameRelease), BuildTarget.Android, options);
// restore all debug scripts' file names
RestoreDebugScripts();
}
[MenuItem("Build Player/Build Android Release(Auto Deploy)", false, 202)]
static void BuildAndroidReleaseAutoDeploy()
{
// rename all debug scripts to *.rem
RenameDebugScripts();
// set build options and build player
BuildOptions options = BuildOptions.AutoRunPlayer;
string[] allScenes = GetAllScenes();
BuildPipeline.BuildPlayer(allScenes, InsertDateString(apkNameRelease), BuildTarget.Android, options);
// restore all debug scripts' file names
RestoreDebugScripts();
}
static void RenameDebugScripts()
{
string[] allDebugDirectories = Directory.GetDirectories(rootPath, "_Debug", SearchOption.AllDirectories);
foreach (string directory in allDebugDirectories)
{
string[] scripts = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories);
foreach (string script in scripts)
{
string newScriptName = script + ".rem";
File.Move(script, newScriptName);
File.Delete(script + ".meta");
}
}
AssetDatabase.Refresh();
}
static void RestoreDebugScripts()
{
string[] allDebugDirectories = Directory.GetDirectories(rootPath, "_Debug", SearchOption.AllDirectories);
foreach (string directory in allDebugDirectories)
{
string[] renamedScripts = Directory.GetFiles(directory, "*.rem", SearchOption.AllDirectories);
foreach (string renamedScript in renamedScripts)
{
string scriptName = renamedScript.Substring(0, renamedScript.Length - 3);
File.Move(renamedScript, scriptName);
File.Delete(renamedScript + ".meta");
}
}
AssetDatabase.Refresh();
}
static string[] GetAllScenes()
{
string[] allScenes = null;
DirectoryInfo dirInfo = new DirectoryInfo(scenePath);
FileInfo[] fileInfos = dirInfo.GetFiles("*.unity", SearchOption.AllDirectories);
allScenes = new string[fileInfos.Length];
int index = 0;
foreach (FileInfo fileInfo in fileInfos)
{
string scene = fileInfo.FullName.Replace(rootParent, "");
allScenes[index++] = scene;
}
return allScenes;
}
static string InsertDateString(string apkName)
{
DateTime now = DateTime.Now;
return apkName.Replace("[Date]", string.Format("[{0:d4}{1:d2}{2:d2}][{3:d2}{4:d2}{5:d2}]", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second));
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
photonnetwork.instantiate에서 gamepobject 유형을 생성 한 다음 상태 및 값을 참조하는 방법주로 마지막 기사에서 일어난 일의 수정입니다. 지난번↓ 그럼 주제입니다. (타이틀이 정리되어 없어서 죄송합니다) 우선 전회의 Illegal view ID:0입니다만 photonnetwork.instantiate를 사...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.