unity flashplayer settingss 没反应

11956人阅读
删除文件夹(1)
Unity3D的项目,这周吃亏在宏上了。大背景是项目需要在Unity中用Hudson自动生成不同平台的版本。
程序设计语言的预处理的概念:在编译之前进行的处理。
#if UNITY_WEBPLAYER
& & & & & & BuildTarget target = BuildTarget.WebP
#elif UNITY_STANDALONE_WIN && UNITY_EDITOR
& & & & & & BuildTarget target = BuildTarget.StandaloneW
#elif UNITY_ANDROID
& & & & & & BuildTarget target = BuildTarget.A
& & & & & & BuildTarget target = BuildTarget.iP
#if UNITY_WEBPLAYER
& & public const string AssetRootPath = AutomaticBuild.WebPlatFormDataPath + &/&;
#elif UNITY_STANDALONE_WIN && UNITY_EDITOR
& & public const string AssetRootPath = AutomaticBuild.WinPlatFormDataPath + &/&;
#elif UNITY_ANDROID
& & public const string AssetRootPath = AutomaticBuild.AndRoidPlatFormDataPath + &/&;
& & public const string AssetRootPath = AutomaticBuild.IOSPlatFormDataPath + &/&;
如上面两段代码,打开Unity项目(例如PC & Mac Standalone保存的)之后,再打开项目的Script(这里用VS2008+VA),会发现上述加粗行高亮。即Target和AssetRootPath在编译前已然确定,且之后不能对其做出变更。
当采用Unity支持的命令编译时C:\program files\Unity\Editor&Unity.exe -quit -batchmode -executeMethod MyEditorScript.MyMethod
此时MyMethod可能用了如下代码,
( levels, &WebPlayerBuild&,
但Target和AssetRootPath并没有赋予应有的Web相应值,会造成生成的Unity3D文件能生成但不对,执行BuildPlayer时会报Runtime
不禁让我想起Effective C++里的第2个条款:尽量以const,
enum, inline替换 #define。果然金科玉律……
我的解决方式如下:
1.在MyMethod中先调用
SwitchActiveBuildTarget (target :&)函数。
& & private static string AssetRootPath =
& & public static string GetAssetRootPath()
& & & & if (AssetRootPath != null)
& & & & & & return AssetRootP
& & & & if (EditorUserBuildSettings.activeBuildTarget==BuildTarget.WebPlayer)
& & & & & & AssetRootPath = &WebData/LatestData/&;
& & & & else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
& & & & & & AssetRootPath = &AndroidData/LatestData/&;
& & & & else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows)
& & & & & & AssetRootPath = &WinData/LatestData/&;
& & & & else
& & & & & & AssetRootPath = &IOSData/LatestData/&;
& & & & return AssetRootP
& & public static BuildTarget GetBuildTarget()
& & & & return EditorUserBuildSettings.activeBuildT
由于需求的小变更,小小地重构了上次的代码:
& & & & ClearISingleFileSeries();
& & & & ClearDirectorySeries();
& & /// &summary&
& & /// 删除单个文件的数组
& & /// &/summary&
& & static void ClearISingleFileSeries()
& & & & string[] SingleFileSeries = { Application.dataPath + &/Plugins/I18N.dll&, Application.dataPath + &/Plugins/I18N.CJK.dll&, Application.dataPath + &/Plugins/I18N.West.dll& };
& & & & ClearFiles(SingleFileSeries);
& & /// &summary&
& & /// 删除filesPath数组内指向的文件
& & /// &/summary&
& & /// &&param name=&filesPath&&&/param&
& & static void ClearFiles(string[] filesPath)
& & & & foreach (string singleFilePath in filesPath)
& & & & & & if (File.Exists(singleFilePath))
& & & & & & {
& & & & & & & & try
& & & & & & & & {
& & & & & & & & & & File.Delete(singleFilePath);
& & & & & & & & }
& & & & & & & & catch (System.Exception ex)
& & & & & & & & {
& & & & & & & & & & //catch ex
& & & & & & & & }
& & & & & & }
& & /// &summary&
& & /// 删除目前做Web版本会出现内存问题的Audio资源
& & /// &/summary&
& & static void ClearDirectorySeries()
& & & & string[] audioPath = { Application.dataPath + &/Game/Audio/Resources&, Application.dataPath + &/Game/Audio/SFX&, Application.dataPath + &/Game/MyGUI& };
& & & & foreach (string audioDirectory in audioPath)
& & & & & & if (Directory.Exists(audioDirectory)) &//保护,避免文件目录不存在跳异常
& & & & & & & & ClearFilesAndDirectory(audioDirectory);
& & /// &summary&
& & /// 删除dataPath文件目录下的所有子文件及子文件夹
& & /// &/summary&
& & /// &&param name=&DirectoryPath&&&/param&
& & static void ClearFilesAndDirectory(string DirectoryPath)
& & & & DirectoryInfo dir = new DirectoryInfo(DirectoryPath);
& & & & //文件
& & & & foreach (FileInfo fChild in dir.GetFiles(&*&))
& & & & & & if (fChild.Attributes != FileAttributes.Normal)
& & & & & & & & fChild.Attributes = FileAttributes.N
& & & & & & fChild.Delete();
& & & & //文件夹
& & & & foreach (DirectoryInfo dChild in dir.GetDirectories(&*&))
& & & & & & if (dChild.Attributes != FileAttributes.Normal)
& & & & & & & & dChild.Attributes = FileAttributes.N
& & & & & & ClearFilesAndDirectory(dChild.FullName);
& & & & & & dChild.Delete();
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:73071次
积分:1122
积分:1122
排名:千里之外
原创:48篇
(1)(8)(4)(1)(1)(2)(5)(4)(12)(13) 上传我的文档
 下载
 收藏
该文档贡献者很忙,什么也没留下。
 下载此文档
正在努力加载中...
unity3d技术之playersettingsdefaultisfullscreen 默认是否全屏
下载积分:400
内容提示:unity3d技术之playersettingsdefaultisfullscreen 默认是否全屏
文档格式:DOCX|
浏览次数:57|
上传日期: 13:15:45|
文档星级:
该用户还上传了这些文档
unity3d技术之playersettingsdefaultisfullscreen 默
官方公共微信在 Unity 中使用 Android SDK(二)_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
在 Unity 中使用 Android SDK(二)
上传于||文档简介
&&很​好​的​学​习​资​料​~​希​望​对​大​家​有​帮​助
阅读已结束,如果下载本文需要使用0下载券
想免费下载更多文档?
下载文档到电脑,查找使用更方便
还剩6页未读,继续阅读
你可能喜欢

我要回帖

更多关于 unity rendersettings 的文章

 

随机推荐