Unity打包Pc(Windows)後,複製一個exe到打包後的Plugins資料夾

布魯克零三四四發表於2017-10-18
#if UNITY_STANDALONE_WIN
[UnityEditor.Callbacks.PostProcessBuild(999)]
public  static  void OnPostprocessBuild (UnityEditor.BuildTarget BuildTarget, string path)
{
	if (BuildTarget != UnityEditor.BuildTarget.StandaloneWindows)
		return;
			
	//PC(WINDOWS)打包後期指令碼:複製abc.exe到打包後的Plugins資料夾
	UnityEngine.Debug.Log (path);	
	var strPathFrom= UnityEngine.Application.dataPath +"/Plugins/x86/abc.exe";
	var nIdxSlash = path.LastIndexOf ('/');
	var nIdxDot = path.LastIndexOf ('.');
	var strRootTarget = path.Substring ( 0 , nIdxSlash ) ;
	var strPathTargetFile = strRootTarget + path.Substring( nIdxSlash , nIdxDot-nIdxSlash )+"_Data/Plugins/abc.exe";
	System.IO.File.Copy(strPathFrom,strPathTargetFile);
	UnityEngine.Debug.Log ( "複製" + strPathFrom  + "\t到\t"+strPathTargetFile);
}
#endif

相關文章