게임개발/팁
유니티 Unity CloudProjectId 변경하기(파일변경)
쑥갓
2019. 8. 23. 09:59
실행후에 유니티 재시작필요.
Jenkins에서 호출하는경우 빌드전에 따로 실행
유니티 Bind를 사용하는 경우 batch mode에서 제대로 안되서 파일 직접변경이 필요.
public static void SetCloudProjectIdFile(string name, string id, string company)
{
const string filepath = "ProjectSettings/ProjectSettings.asset";
string[] lines = File.ReadAllLines(filepath);
var new_lines = new List<string>();
id = " " + id;
name = " " + name;
company = " " + company;
foreach (string line in lines)
{
string[] command = line.Split(':');
if (command.Length < 2)
{
new_lines.Add(line);
continue;
}
switch (command[0])
{
case " cloudProjectId":
if (command[1] != id)
{
Debug.Log($"Replace {command[0]}");
new_lines.Add(string.Join(":", command[0], id));
}
break;
case " projectName":
if (command[1] != name)
{
Debug.Log($"Replace {command[0]}");
new_lines.Add(string.Join(":", command[0], name));
}
break;
case " organizationId":
if (command[1] != company)
{
Debug.Log($"Replace {command[0]}");
new_lines.Add(string.Join(":", command[0], company));
}
break;
default:
new_lines.Add(line);
break;
}
}
File.WriteAllLines(filepath, new_lines.ToArray());
AssetDatabase.Refresh();
}