1. 程式人生 > >Unity打包Pc(Windows)後,複製一個exe到打包後的Plugins資料夾

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

#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