55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
#if UNITY_IOS || UNITY_IPHONE
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEditor.Callbacks;
|
|
using UnityEngine;
|
|
|
|
public static class XCodeAutoSet
|
|
{
|
|
private const string _sdkRoot = "Sdk/iOS/";
|
|
private const string _yuCheng = "YuCheng";
|
|
private const string _traceless = "Traceless";
|
|
private static void CopyCommonAssets(string channel, string buildPath)
|
|
{
|
|
// 复制Channel文件
|
|
const string channelName = "Channel" + AssetConst.textExtension;
|
|
var rawPath = buildPath.Open("Data/Raw");
|
|
File.Copy(Application.dataPath.MoveUp().Open(_sdkRoot).Open(channel).Open(channelName),
|
|
rawPath.Open(channelName), true);
|
|
var textures = Directory.GetFiles(Application.dataPath.MoveUp().Open("Sdk/Common").Open(channel));
|
|
foreach (var texture in textures)
|
|
{
|
|
var fileName = Path.GetFileName(texture);
|
|
File.Copy(texture, rawPath.Open("ExTextures/PacketRes").Open(fileName), true);
|
|
}
|
|
}
|
|
|
|
[PostProcessBuild(9999)]
|
|
public static void OnPostprocessBuild(BuildTarget target, string buildPath)
|
|
{
|
|
var platform = PlayerPrefs.GetString(XCodeSetWindow.platformKey, string.Empty);
|
|
PbxProjectSet action;
|
|
if (platform.Contains(_yuCheng))
|
|
{
|
|
var sdkPath = Application.dataPath.MoveUp().Open(_sdkRoot).Open(_yuCheng);
|
|
action = new PbxProjectSetYuCheng(sdkPath, buildPath);
|
|
CopyCommonAssets(_yuCheng, buildPath);
|
|
}
|
|
else if (platform.Contains(_traceless))
|
|
{
|
|
var sdkPath = Application.dataPath.MoveUp().Open(_sdkRoot).Open(_traceless);
|
|
action = new PbxProjectSetTraceless(sdkPath, buildPath);
|
|
CopyCommonAssets(_traceless, buildPath);
|
|
}
|
|
else
|
|
{
|
|
action = null;
|
|
EditorUtility.DisplayDialog("无法配置iOS",
|
|
string.Format("渠道{0}不能找到配置流程!", !string.IsNullOrEmpty(platform) ? platform : "_"), "确定");
|
|
}
|
|
|
|
if (action != null)
|
|
action.Action();
|
|
}
|
|
}
|
|
#endif |