コード例 #1
0
        public static void OpenTools()
        {
            //CLog.Log(AppSetting.DataPath);
            string path = Path.Combine(AppSetting.DataPath, "../ProtoConfig/工具/Tools.exe");

            ToolsHelper.OpenEXE(path);
        }
コード例 #2
0
        /// <summary>
        /// 添加UI预设上Text字体为空的字体-黑体SIMHEI
        /// </summary>
        public static void SetUIPrefabTextFont()
        {
            Font font = AssetDatabase.LoadAssetAtPath <Font>("Assets/Resources/Font/SIMHEI.TTF");

            List <string> FileName = FindUIPrefab();
            string        BasePath = "Assets/GameRes/BundleRes/UI/";

            ToolsHelper.Log("font:" + font, false);

            foreach (var file in FileName)
            {
                //ToolsHelper.Log("file:" + file, false);
                GameObject go    = AssetDatabase.LoadAssetAtPath(BasePath + file, typeof(GameObject)) as GameObject;
                Text[]     texts = go.GetComponentsInChildren <Text>(true);
                foreach (var item in texts)
                {
                    if (item.font == null)
                    {
                        item.font = font;
                        //ToolsHelper.Log("Text:" + item.name, false);
                    }
                }
                EditorUtility.SetDirty(go);
                AssetDatabase.SaveAssets();
            }
        }
コード例 #3
0
        /// <summary>
        /// </summary>
        public static void MakeArtResAssetBundleNames()
        {
            string baseBunldDir = AppSetting.BundleArtResDir;

            string[] folders = AppSetting.BundleArtResFolders;
            foreach (string fold in folders)
            {
                foreach (string filepath in Directory.GetFiles(baseBunldDir + fold, "*.*", SearchOption.AllDirectories))
                {
                    if (filepath.EndsWith(".meta"))
                    {
                        continue;
                    }
                    var importer = AssetImporter.GetAtPath(filepath);
                    if (importer == null)
                    {
                        ToolsHelper.Error(string.Format("Not found: {0}", filepath));
                        continue;
                    }
                    string bundleName = filepath.Substring(baseBunldDir.Length);
                    bundleName = bundleName.Replace("\\", "/").ToLower();
                    importer.assetBundleName = bundleName + AppSetting.ExtName;
                }
            }
        }
コード例 #4
0
        static void CreateTextLang(MenuCommand menuCommadn)
        {
            GameObject parent = menuCommadn.context as GameObject;

            if (parent != null && parent.GetComponentInParent <Canvas>() != null)
            {
                GameObject go = new GameObject("New Lang Text");
                GameObjectUtility.SetParentAndAlign(go, parent);
                go.AddComponent <UILangText>();
                Text          txt  = go.AddComponent <Text>();
                RectTransform rect = go.GetComponent <RectTransform>();
                rect.sizeDelta = new Vector2(200, 22);
                txt.alignment  = TextAnchor.MiddleLeft;
                txt.fontSize   = 22;
                Color outColor = Color.white;
                ColorUtility.TryParseHtmlString("#FFFFFF", out outColor);
                txt.color = outColor;
                txt.text  = "New Lang Text";
                txt.resizeTextForBestFit = true;
                txt.supportRichText      = true;
                Font font = AssetDatabase.LoadAssetAtPath <Font>("Assets/Resources/Font/SIMHEI.TTF");
                txt.font = font;
            }
            else
            {
                ToolsHelper.Log("只能在UI下创建LangText");
            }
        }
コード例 #5
0
        /// <summary>
        /// 生成AB资源文件列表
        /// </summary>
        public static void CreateAssetBundleFileInfo()
        {
            string abRootPath  = GetExportPath();
            string abFilesPath = abRootPath + AppSetting.ABFiles;

            if (File.Exists(abFilesPath))
            {
                File.Delete(abFilesPath);
            }

            var abFileList = new List <string>(Directory.GetFiles(abRootPath, "*" + AppSetting.ExtName, SearchOption.AllDirectories));

            abFileList.Add(abRootPath + AppSetting.MineGameName);
            FileStream   fs = new FileStream(abFilesPath, FileMode.CreateNew);
            StreamWriter sw = new StreamWriter(fs);

            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2018, 1, 1));
            int      ver       = ((int)((DateTime.Now - startTime).TotalMinutes));

            sw.WriteLine(ver + "|" + DateTime.Now.ToString("u"));
            for (int i = 0; i < abFileList.Count; i++)
            {
                string file  = abFileList[i];
                long   size  = 0;
                string md5   = MD5Utils.MD5File(file, out size);
                string value = file.Replace(abRootPath, string.Empty).Replace("\\", "/");
                sw.WriteLine(value + "|" + md5 + "|" + size);
            }
            sw.Close();
            fs.Close();
            ToolsHelper.Log("资源版本Version:" + ver + "  已复制到剪切板");
            ToolsHelper.Log("ABFiles文件生成完成");
            ToolsHelper.CopyString(ver.ToString());
        }
コード例 #6
0
        /// <summary>
        /// 保存UI预制
        /// 自动添加引用图集依赖
        /// </summary>
        /// <param name="instance"></param>
        static void SaveUIPrefab(GameObject instance)
        {
            string prefabPath = AssetDatabase.GetAssetPath(PrefabUtility.GetCorrespondingObjectFromSource(instance));

            if (!IsUIPrefab(prefabPath))
            {
                return;
            }
            GameObject go = UnityEditor.PrefabUtility.GetCorrespondingObjectFromSource(instance) as GameObject;

            Image[] imgs = go.GetComponentsInChildren <Image>(true);
            Dictionary <string, SpriteAtlas> saDict = new Dictionary <string, SpriteAtlas>();
            List <SpriteAtlas> saList = new List <SpriteAtlas>();
            string             imgPath;
            string             spriteAtlasPath;
            SpriteAtlas        sa;

            foreach (Image img in imgs)
            {
                imgPath = AssetDatabase.GetAssetPath(img.sprite);
                if (imgPath.IndexOf("/UIAtlas/") == -1)
                {
                    continue;
                }
                imgPath         = imgPath.Substring(0, imgPath.LastIndexOf("/"));
                spriteAtlasPath = imgPath.Replace("/ArtRes/UIAtlas/", "/BundleRes/UIAtlas/") + ".spriteatlas";
                if (!saDict.TryGetValue(spriteAtlasPath, out sa))
                {
                    sa = AssetDatabase.LoadAssetAtPath <SpriteAtlas>(spriteAtlasPath);
                    if (sa != null)
                    {
                        saDict.Add(spriteAtlasPath, sa);
                        saList.Add(sa);
                    }
                    else
                    {
                        ToolsHelper.Warning("SpriteAtlas未找到:" + spriteAtlasPath);
                    }
                }
            }
            SpriteAtlasList compAtlas = go.GetComponent <SpriteAtlasList>();

            if (saList.Count > 0)
            {
                if (compAtlas == null)
                {
                    compAtlas = go.AddComponent <SpriteAtlasList>();
                }
                compAtlas.AtlasList = saList.ToArray();
            }
            else
            {
                if (compAtlas != null)
                {
                    Component.DestroyImmediate(compAtlas, true);
                }
            }
            PrefabUtility.ResetToPrefabState(instance);
        }
コード例 #7
0
        static void CreateVideoButtonLang(MenuCommand menuCommadn)
        {
            GameObject parent = menuCommadn.context as GameObject;

            if (parent != null && parent.GetComponentInParent <Canvas>() != null)
            {
                GameObject goBtn = new GameObject("New Button");
                GameObjectUtility.SetParentAndAlign(goBtn, parent);
                Image image = goBtn.AddComponent <Image>();
                image.sprite =
                    AssetDatabase.LoadAssetAtPath <Sprite>("Assets/GameRes/ArtRes/UIAtlas/PublicButton/Btn1_BG.png");
                image.SetNativeSize();

                GameObject BtnIcon = new GameObject("Icon");
                BtnIcon.transform.SetParent(goBtn.transform, false);
                Image IconImg = BtnIcon.AddComponent <Image>();
                IconImg.sprite =
                    AssetDatabase.LoadAssetAtPath <Sprite>("Assets/GameRes/ArtRes/UIAtlas/PublicButton/Btn1_1.png");
                RectTransform IconImgrect = IconImg.GetComponent <RectTransform>();
                IconImgrect.anchorMin = Vector2.zero;
                IconImgrect.anchorMax = Vector2.one;
                IconImgrect.offsetMin = Vector2.zero;
                IconImgrect.offsetMax = Vector2.zero;
                IconImgrect.sizeDelta = new Vector2(-16, -16);


                DBTVideoBtn btn = goBtn.AddComponent <DBTVideoBtn>();
                btn.image = IconImg;

                GameObject goTxt = new GameObject("Text");
                GameObjectUtility.SetParentAndAlign(goTxt, goBtn);
                goTxt.AddComponent <UILangText>();
                Text  txt   = goTxt.AddComponent <Text>();
                Color color = Color.black;
                ColorUtility.TryParseHtmlString("#FFFFFF", out color);
                txt.color = color;
                RectTransform rect = goTxt.GetComponent <RectTransform>();

                rect.anchorMin = Vector2.zero;
                rect.anchorMax = Vector2.one;
                rect.offsetMin = Vector2.zero;
                rect.offsetMax = Vector2.zero;
                rect.sizeDelta = new Vector2(-40, -34);
                txt.fontSize   = 24;
                txt.alignment  = TextAnchor.MiddleCenter;
                txt.text       = "Lang Button";
                //txt.resizeTextForBestFit = true;
                //txt.supportRichText = true;
                Font font = AssetDatabase.LoadAssetAtPath <Font>("Assets/Resources/Font/SIMHEI.TTF");
                txt.font = font;
                Shadow shadow = goTxt.AddComponent <Shadow>();
                shadow.effectColor    = new Color(0, 0, 0, 1);
                shadow.effectDistance = new Vector2(1, -3);
            }
            else
            {
                ToolsHelper.Log("只能在UI下创建LangText");
            }
        }
コード例 #8
0
        public static void ShowInExplorerPersistentData()
        {
            string DataPath    = Application.dataPath;
            string userPathBas = DataPath.Substring(0, DataPath.LastIndexOf("/") + 1);

            userPathBas = Path.Combine(userPathBas, "LocalFile");
            ToolsHelper.ShowExplorer(userPathBas);
        }
コード例 #9
0
        /// <summary>
        /// 打包所有资源
        /// </summary>
        public static void BuildAllAssetBundles()
        {
            if (ToolsHelper.IsPlaying())
            {
                return;
            }
            ToolsHelper.ClearConsole();

            EditorCoroutineRunner.StartEditorCoroutine(_OnBuildAllAssetBundles());
        }
コード例 #10
0
 public static bool IsPlaying()
 {
     if (EditorApplication.isPlaying)
     {
         ToolsHelper.Error("请先停止运行");
         EditorUtility.DisplayDialog("提示", "请先停止运行","知道了...");
         return true;
     }
     return false;
 }
コード例 #11
0
 public static void IOS_ReleaseApp()
 {
     if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS)
     {
         ToolsHelper.Log($"平台选择错误,目前平台不是iOS,是{EditorUserBuildSettings.activeBuildTarget}");
         return;
     }
     BuildAPKTools.ModifyBuildSettingsScene();
     BuildAPKTools.BulidTarget(EPlatformType.SDK_ReleaseIOS);
     BuildAPKTools.ReductionBuildSettingsScene();
 }
コード例 #12
0
 public static void CreateVersionPackageApp()
 {
     if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
     {
         ToolsHelper.Log($"平台选择错误,目前平台不是Android,是{EditorUserBuildSettings.activeBuildTarget}");
         return;
     }
     BuildAPKTools.ModifyBuildSettingsScene();
     BuildAPKTools.BulidTarget(EPlatformType.VersionPackage);
     BuildAPKTools.ReductionBuildSettingsScene();
 }
コード例 #13
0
        private static void CreateUIView(string modName, string uiName, UIOutlet ui)
        {
            string saveFilePath = $"{ExportScriptDir}{modName}/UI/View/{uiName}View.cs";

            StringBuilder fieldStrs = new StringBuilder();
            StringBuilder getStrs   = new StringBuilder();

            UIOutlet.OutletInfo info;
            string objType;

            for (int i = ui.OutletInfos.Count; --i >= 0;)
            {
                info = ui.OutletInfos[i];
                if (info == null)
                {
                    continue;
                }
                objType = getTypeName(info.ComponentType);
                fieldStrs.AppendLine($"        private {objType} {info.Name};");
                if (objType == "GameObject")
                {
                    getStrs.AppendLine($@"            {info.Name} = Get(""{info.Name}"");");
                }
                else
                {
                    getStrs.AppendLine($@"            {info.Name} = Get<{objType}>(""{info.Name}"");");
                }
            }

            string fieldStr = $@"//工具生成不要修改

using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using GameFramework;

namespace {AppSetting.MineGameName}.UI.{modName}
{{
    public partial class {uiName} : BaseUI
    {{
{fieldStrs} 
        /// <summary>初始化UI控件</summary>
        override protected void InitializeComponent()
        {{
{getStrs}
        }}
    }}
}}
";

            ToolsHelper.SaveFile(saveFilePath, fieldStr, true);
        }
コード例 #14
0
        /// <summary>
        /// 重新打包资源
        /// </summary>
        /// <returns></returns>
        public static void ReBuildAllAssetBundles()
        {
            if (ToolsHelper.IsPlaying())
            {
                return;
            }
            ToolsHelper.ClearConsole();
            string outputPath = GetExportPath();

            Directory.Delete(outputPath, true);
            ToolsHelper.Log("删除目录: " + outputPath);
            BuildAllAssetBundles();
        }
コード例 #15
0
        public static void OpenLastScene()
        {
            var lastScene = EditorPrefs.GetString(LastScenePrefKey);

            if (!string.IsNullOrEmpty(lastScene))
            {
                ToolsHelper.OpenScene(lastScene);
            }
            else
            {
                ToolsHelper.Error("Not found last scene!");
            }
        }
コード例 #16
0
        /// <summary>
        /// 清理冗余,即无此资源,却有AssetBundle的
        /// </summary>
        public static void CleanAssetBundlesRedundancies()
        {
            var platformName = AppSetting.PlatformName;
            var outputPath   = GetExportPath();

            int count  = 0;
            var toList = new List <string>(Directory.GetFiles(outputPath, "*.*", SearchOption.AllDirectories));

            for (var i = toList.Count - 1; i >= 0; i--)
            {
                var filePath = toList[i];
                var abName   = toList[i].Replace(outputPath, "").Replace('\\', '/');
                var extName  = Path.GetExtension(filePath);
                if (abName != platformName && extName != ".manifest")
                {
                    //删除.meta文件
                    if (extName == ".meta")
                    {
                        File.Delete(filePath);
                    }
                    else
                    {
                        if (AssetDatabase.GetAssetPathsFromAssetBundle(abName).Length == 0)
                        {
                            var manifestPath = filePath + ".manifest";
                            File.Delete(filePath);
                            ToolsHelper.Log("Delete... " + filePath);
                            count += 1;
                            if (File.Exists(manifestPath))
                            {
                                File.Delete(manifestPath);
                                ToolsHelper.Log("Delete... " + manifestPath);
                                count += 1;
                            }
                        }
                    }
                }
                //删除空文件夹
                DirectoryInfo   dir     = new DirectoryInfo(outputPath);
                DirectoryInfo[] subdirs = dir.GetDirectories("*.*", SearchOption.AllDirectories);
                foreach (DirectoryInfo subdir in subdirs)
                {
                    FileInfo[] subFiles = subdir.GetFiles();
                    if (subFiles.Length == 0)
                    {
                        subdir.Delete();
                    }
                }
            }
            ToolsHelper.Log("清理冗余文件完成!! 共" + count + "个文件!");
        }
コード例 #17
0
        static IEnumerator _OnBuildAllAssetBundles()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            yield return(new WaitForSeconds(0.3f));

            //CopyHotFix();
            CreateLayerCollisionMatrix();
            yield return(null);

            RemoveAssetBundleNames();
            MakeAssetBundleNames();
            yield return(null);

            //RemoveUIPrefabTextFont();
            yield return(new WaitForSeconds(0.1f));

            ToolsHelper.Log("资源打包中...");
            yield return(null);

            var outputPath = GetExportPath();

            ToolsHelper.Log("打包路径..." + outputPath);
#if UNITY_ANDROID
            _SetAtlasIncludeInBuild(false);
#endif
            yield return(new WaitForSeconds(0.5f));//DessterministicAssetBundle

            ToolsHelper.Log("设置图集属性完成...");
            BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
            yield return(new WaitForSeconds(0.5f));

            //_SetAtlasIncludeInBuild(true);
#if UNITY_ANDROID
            CopyOnceAuido();
#endif
            yield return(null);

            CreateAssetBundleFileInfo();
            yield return(null);

            //SetUIPrefabTextFont();
            yield return(new WaitForSeconds(0.1f));

            watch.Stop();
            ToolsHelper.Log("资源打包完成!!用时:" + (watch.ElapsedMilliseconds / 1000.0f) + "秒");
            AssetDatabase.Refresh();
            yield break;
        }
コード例 #18
0
        public static void ClearPCPersistentData()
        {
            string DataPath    = Application.dataPath;
            string userPathBas = DataPath.Substring(0, DataPath.LastIndexOf("/") + 1);

            userPathBas = Path.Combine(userPathBas, "LocalFile");
            if (Directory.Exists(userPathBas))
            {
                foreach (string dir in Directory.GetDirectories(userPathBas))
                {
                    Directory.Delete(dir, true);
                }
                ToolsHelper.Log("删除PersistentData完成!");
            }
        }
コード例 #19
0
        /// <summary>
        /// 创建StreamingAssets链接
        /// </summary>
        public static void MkLinkStreamingAssets()
        {
            string linkPath = Application.streamingAssetsPath + "/" + AppSetting.PlatformName;

            if (IsLinkStreamingAssets)
            {
                ToolsHelper.CreateDir(Application.streamingAssetsPath);
                var exportPath = AppSetting.ExportResBaseDir + AppSetting.PlatformName;
                SymbolLinkFolder(exportPath, linkPath);
            }
            else
            {
                DeleteLink(linkPath);
            }
            AssetDatabase.Refresh();
        }
コード例 #20
0
        /// <summary>
        /// 删除硬链接目录
        /// </summary>
        /// <param name="linkPath"></param>
        public static void DeleteLink(string linkPath)
        {
            var os = Environment.OSVersion;

            if (os.ToString().Contains("Windows"))
            {
                ToolsHelper.ExecuteCommand(String.Format("rmdir \"{0}\"", linkPath));
            }
            else if (os.ToString().Contains("Unix"))
            {
                ToolsHelper.ExecuteCommand(String.Format("rm -Rf \"{0}\"", linkPath));
            }
            else
            {
                ToolsHelper.Error(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString()));
            }
        }
コード例 #21
0
        /// <summary>
        /// 获取IOS打包AB路径
        /// </summary>
        /// <returns></returns>
        public static string GetABExportPatIOS()
        {
            string projectName = AppSetting.MineGameName;
            string basePath    = Application.dataPath + "/";

            if (File.Exists(basePath))
            {
                ToolsHelper.ShowDialog("路径配置错误: " + basePath);
                throw new System.Exception("路径配置错误");
            }
            string path         = null;
            var    platformName = AppSetting.PlatformName;

            path = basePath + platformName + "/" + projectName + "/";
            ToolsHelper.CreateDir(path);
            return(path);
        }
コード例 #22
0
 /// <summary>
 /// 保存文件
 /// </summary>
 /// <param name="path">保存路径</param>
 /// <param name="content">文件内容</param>
 /// <param name="iscover">存在是否进行覆盖,默认true</param>
 public static void SaveFile(string path, string content, bool iscover = true, bool isLog = true)
 {
     FileInfo info = new FileInfo(path);            
     if (!iscover && info.Exists) //不覆盖
     {
         if (isLog)
             ToolsHelper.Warning($"文件已存在,不进行覆盖操作!! {path}");
         return;
     }
     CheckCreateDirectory(info.DirectoryName);
     FileStream fs = new FileStream(path, FileMode.Create);            
     StreamWriter sWriter = new StreamWriter(fs, Encoding.GetEncoding("UTF-8"));
     sWriter.WriteLine(content);
     sWriter.Flush();
     sWriter.Close();
     fs.Close();
     Log($"成功生成文件 {path}",false);
 }
コード例 #23
0
        /// <summary>
        /// 获取导出资源路径目录
        /// </summary>
        /// <returns></returns>
        public static string GetExportPath()
        {
            BuildTarget platfrom    = EditorUserBuildSettings.activeBuildTarget;
            string      projectName = AppSetting.MineGameName;
            string      basePath    = AppSetting.ExportResBaseDir;

            if (File.Exists(basePath))
            {
                ToolsHelper.ShowDialog("路径配置错误: " + basePath);
                throw new System.Exception("路径配置错误");
            }
            string path         = null;
            var    platformName = AppSetting.PlatformName;

            path = basePath + platformName + "/" + projectName + "/";
            ToolsHelper.CreateDir(path);
            return(path);
        }
コード例 #24
0
        //public static void BuildHotFixAssetBundles()
        //{
        //    if (ToolsHelper.IsPlaying()) return;
        //    ToolsHelper.ClearConsole();
        //    Stopwatch watch = new Stopwatch();
        //    watch.Start();
        //    CopyHotFix();
        //    Dictionary<string, List<string>> buildMap = new Dictionary<string, List<string>>();
        //    string baseBunldDir = "Assets/GameRes/BundleRes/Data";
        //    List<string> abNames;
        //    foreach (string filepath in Directory.GetFiles(baseBunldDir, "*.*", SearchOption.AllDirectories))
        //    {
        //        if (filepath.EndsWith(".meta")) continue;
        //        AssetImporter importer = AssetImporter.GetAtPath(filepath);
        //        if (importer == null)
        //            continue;
        //        if (importer.assetBundleName == string.Empty)
        //        {
        //            ToolsHelper.Warning("文件没设置AB名:" + filepath);
        //            continue;
        //        }
        //        if (!buildMap.TryGetValue(importer.assetBundleName, out abNames))
        //        {
        //            abNames = new List<string>();
        //            buildMap.Add(importer.assetBundleName, abNames);
        //        }
        //        abNames.Add(importer.assetPath);
        //    }
        //    // 设置新的资源名
        //    List<AssetBundleBuild> abList = new List<AssetBundleBuild>();
        //    foreach (KeyValuePair<string, List<string>> keyVal in buildMap)
        //    {
        //        AssetBundleBuild ab = new AssetBundleBuild();
        //        ab.assetBundleName = keyVal.Key;
        //        ab.assetNames = keyVal.Value.ToArray();
        //        abList.Add(ab);
        //    }
        //    var outputPath = GetExportPath();
        //    BuildPipeline.BuildAssetBundles(outputPath, abList.ToArray(), BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);
        //    CreateAssetBundleFileInfo();
        //    watch.Stop();
        //    ToolsHelper.Log("Data文件打包完成!!用时:" + (watch.ElapsedMilliseconds / 1000.0f) + "秒");
        //}
        /// <summary>
        /// 保存碰撞矩阵数据
        /// </summary>
        public static void CreateLayerCollisionMatrix()
        {
            string FilePath = Application.dataPath + "/GameRes/BundleRes/Data/LayerCollisionMatrix.bytes";
            string content  = "";

            for (int i = 0; i < 32; i++)
            {
                for (int j = 31; j >= i; j--)
                {
                    bool Ignore = Physics.GetIgnoreLayerCollision(i, j);
                    if (Ignore)
                    {
                        content += $"{i},{j}_";
                    }
                }
            }
            ToolsHelper.SaveFile(FilePath, content);
            AssetDatabase.Refresh();
        }
コード例 #25
0
        /// <summary>
        /// 复制音频
        /// </summary>
        public static void CopyOnceAuido()
        {
            BuildTarget platfrom = EditorUserBuildSettings.activeBuildTarget;

            if (platfrom != BuildTarget.Android)
            {
                return;
            }
            string sourcePath = AppSetting.DataPath + "GameRes/BundleRes/Audio/Once";
            string targetPath = GetExportPath() + "audio/once";

            ToolsHelper.Log("音效源目录: " + sourcePath);
            ToolsHelper.Log("targetPath: " + targetPath);
            //找到目录下所有音频文件
            DirectoryInfo folder    = new DirectoryInfo(sourcePath);
            List <string> AuiodFile = new List <string>();

            foreach (var file in folder.GetFiles())
            {
                if (file.FullName.EndsWith(".meta"))
                {
                    continue;
                }
                AuiodFile.Add(file.Name);
            }
            //foreach (var item in AuiodFile)
            //{
            //    ToolsHelper.Log(item);
            //}
            foreach (var item in AuiodFile)
            {
                string FileSourcePath     = Path.Combine(sourcePath, item);
                string FileTargetPathPath = Path.Combine(targetPath, item);
                if (File.Exists(FileTargetPathPath))
                {
                    continue;
                }
                //ToolsHelper.Log()
                File.Copy(FileSourcePath, FileTargetPathPath);
            }

            ToolsHelper.Log("音频文件复制完成");
        }
コード例 #26
0
        public static void OpenMainScene()
        {
#if UNITY_5 || UNITY_2017_1_OR_NEWER
            var currentScene = EditorSceneManager.GetActiveScene().path;
#else
            var currentScene = EditorApplication.currentScene;
#endif
            var mainScene = "Assets/GameRes/BundleRes/Scene/MineGameMain.unity";
            if (mainScene != currentScene)
            {
                EditorPrefs.SetString(LastScenePrefKey, currentScene);
            }

            ToolsHelper.OpenScene(mainScene);

            if (!EditorApplication.isPlaying)
            {
                EditorApplication.isPlaying = true;
            }
        }
コード例 #27
0
        /// <summary>
        /// Unity 5新AssetBundle系统,需要为打包的AssetBundle配置名称
        /// GameRes/BundleRes目录整个自动配置名称,因为这个目录本来就是整个导出
        /// </summary>
        public static void MakeAssetBundleNames()
        {
            string baseBunldDir = AppSetting.BundleResDir;

            // 设置新的资源名
            foreach (string filepath in Directory.GetFiles(baseBunldDir, "*.*", SearchOption.AllDirectories))
            {
                if (filepath.EndsWith(".meta"))
                {
                    continue;
                }
                var importer = AssetImporter.GetAtPath(filepath);
                if (importer == null)
                {
                    ToolsHelper.Error(string.Format("Not found: {0}", filepath));
                    continue;
                }
                // var bundleName = filepath.Substring(baseBunldDir.Length, filepath.Length - baseBunldDir.Length);

                string bundleName = filepath.Substring(baseBunldDir.Length);

                bundleName = bundleName.Replace("\\", "/").ToLower();
                if (bundleName.StartsWith(AppSetting.ConfigBundleDir.ToLower()))  //config全部打到一个文件夹中
                {
                    bundleName = StringTools.SubstringIndexOf(bundleName, '/', 1);
                }
                //bundleName = bundleName.Replace("\\", "/").ToLower();
                //if (bundleName.StartsWith("lua/"))
                //{
                //    bundleName = StringUtil.SubstringIndexOf(bundleName, '/', AppSetting.LuaAssetBundleDepth);
                //}
                importer.assetBundleName = bundleName + AppSetting.ExtName;
            }
            //setAtlasIncludeInBuild(true);
            //setUIAtlasPropert(); //设置UIAtlas
            MakeArtResAssetBundleNames();
            ToolsHelper.Log("设置全部资源AssetBundle名称完成!");
        }
コード例 #28
0
 /// <summary>
 /// 打开外部程序
 /// </summary>
 /// <param name="_exePathName">EXE所在绝对路径及名称带.exe</param>
 /// <param name="_exeArgus">启动参数</param>
 public static void OpenEXE(string filePath, string _exeArgus = null)
 {
     try
     {
         FileInfo file = new FileInfo(filePath);
         if (!file.Exists)
         {
             ToolsHelper.Error("文件不存在:"+ file.FullName);
             return;
         }
         Process myprocess = new Process();
         //ProcessStartInfo startInfo = new ProcessStartInfo(file.FullName, _exeArgus);
         myprocess.StartInfo.FileName = file.FullName;
         myprocess.StartInfo.WorkingDirectory = file.DirectoryName;
         myprocess.StartInfo.UseShellExecute = false;
         myprocess.StartInfo.CreateNoWindow = true;
         myprocess.Start();
     }
     catch (Exception ex)
     {
         ToolsHelper.Error("出错原因:" + ex.Message);
     }
 }
コード例 #29
0
        public static void SymbolLinkFolder(string srcFolderPath, string targetPath)
        {
            var os = Environment.OSVersion;

            if (os.ToString().Contains("Windows"))
            {
                ToolsHelper.ExecuteCommand(String.Format("mklink /J \"{0}\" \"{1}\"", targetPath, srcFolderPath));
            }
            else if (os.ToString().Contains("Unix"))
            {
                var fullPath = Path.GetFullPath(targetPath);
                if (fullPath.EndsWith("/"))
                {
                    fullPath = fullPath.Substring(0, fullPath.Length - 1);
                    fullPath = Path.GetDirectoryName(fullPath);
                }
                ToolsHelper.ExecuteCommand(String.Format("ln -s {0} {1}", Path.GetFullPath(srcFolderPath), fullPath));
            }
            else
            {
                ToolsHelper.Error(String.Format("[SymbolLinkFolder]Error on OS: {0}", os.ToString()));
            }
        }
コード例 #30
0
        public static void RemoveAssetBundleNames()
        {
            List <string> filterDir = new List <string>();

            filterDir.Add(AppSetting.BundleResDir);
            foreach (string fold in AppSetting.BundleArtResFolders)
            {
                filterDir.Add(AppSetting.BundleArtResDir + fold);
            }

            bool isClena = false;

            foreach (string assetGuid in AssetDatabase.FindAssets(""))
            {
                string        assetPath     = AssetDatabase.GUIDToAssetPath(assetGuid);
                AssetImporter assetImporter = AssetImporter.GetAtPath(assetPath);
                string        bundleName    = assetImporter.assetBundleName;
                if (string.IsNullOrEmpty(bundleName))
                {
                    continue;
                }
                isClena = true;
                foreach (string filter in filterDir)
                {
                    if (assetPath.StartsWith(filter)) //清除非打包资源目录下的资源名
                    {
                        isClena = false;
                        break;
                    }
                }
                if (isClena)
                {
                    assetImporter.assetBundleName = null;
                }
            }
            ToolsHelper.Log("全部非打包资源AssetBundle名称已清除!");
        }