Ejemplo n.º 1
0
    public void GetPrefab(string abName, string assetName, System.Action <UnityEngine.Object> onLoad)
    {
        abName = GetFilePathByFileName(abName);


        if (IsUseAssetBundle)
        {
            //LoadAssetBundle(abName, assetName, loadPrefab);
            LoadAssetBundle(abName, assetName, onLoad);
        }
        else
        {
            if (abName.EndsWith(mAssetBundleSuffix))
            {
                abName = abName.Remove(abName.Length - mAssetBundleSuffix.Length);
            }

            //去掉后缀名
            abName = MyFileUtil.GetFileNameWithoutExtension(abName);

            string             newAbName = DirNameForAssetBundlesBuildFrom + "/" + abName;
            UnityEngine.Object obj       = GetResourcePrefab(newAbName);
            if (obj == null)
            {
                obj = GetResourcePrefab(abName);
            }

            onLoad(obj);
            obj = null;
        }
    }
Ejemplo n.º 2
0
    private static void CreateSpritePacker(ref SpriteInfo data)
    {
        var path       = data.path.Substring(data.path.IndexOf("Assets"));
        var packingTag = Path.GetFileName(path);

        data.tag  = packingTag;
        data.path = path;
        List <string> fileList = new List <string>();;

        MyFileUtil.GetFileList(path, ref fileList, null, ".meta");
        List <Sprite> sprites = new List <Sprite>();

        foreach (var itemPath in fileList)
        {
            var newPath   = itemPath.Substring(itemPath.IndexOf("Assets"));
            var extension = Path.GetExtension(newPath);
            if (extension.Equals(".asset"))
            {
                continue;
            }
            var improter = AssetImporter.GetAtPath(newPath) as TextureImporter;
            improter.textureType      = TextureImporterType.Sprite;
            improter.mipmapEnabled    = false;
            improter.spritePackingTag = packingTag;
            improter.SaveAndReimport();
            sprites.Add(AssetDatabase.LoadAssetAtPath <Sprite>(newPath));
        }
        GeneratePacker(sprites, path + "/" + packingTag + "SpritePacker.asset");

        AssetDatabase.Refresh();
    }
Ejemplo n.º 3
0
    static public void GenerateEffectNamePath()
    {
        try
        {
            string          strEffectDir = Application.dataPath + "/Resources/Effect";
            List <FileUnit> fileList     = new List <FileUnit>();
            MyFileUtil.GetRelativeFileListWithSpecialFileType(strEffectDir, "Effect", ref fileList, "prefab");

            string       filePath = Application.dataPath + "/StreamingAssets/ResoucesConfig/ResoucesConfig.csv";
            StreamWriter writer   = new StreamWriter(filePath);
            writer.WriteLine("资源名,资源路径");
            writer.WriteLine("string,string");

            for (int i = 0; i < fileList.Count; ++i)
            {
                fileList[i].name         = fileList[i].name.Replace(".prefab", "");
                fileList[i].relativePath = fileList[i].relativePath.Replace(".prefab", "");

                string str = string.Format("{0:s},{1:s}", fileList[i].name, fileList[i].relativePath);
                writer.WriteLine(str);
            }
            writer.Close();
            Debug.Log("GenerateEffectNamePath结束");
        }
        catch (System.Exception ex)
        {
            Debug.LogError("CheckFile.GenerateEffectNamePath:" + ex.Message);
        }
    }
Ejemplo n.º 4
0
    //保存版本信息
    public void SaveLocalVersionInfo(VersionInfo versionInfo)
    {
        m_LocalVersionInfo = versionInfo;
        string data = VersionInfo.Serialize(versionInfo);

        MyFileUtil.WriteConfigDataInCacheDir(VersionInfoFilePath, data);
    }
Ejemplo n.º 5
0
    //异步获取本地版本信息
    public void GetLocalVersionInfoAsync(Action <VersionInfo> callback)
    {
        if (m_LocalVersionInfo != null)
        {
            callback(m_LocalVersionInfo);
            return;
        }
        //获取安装包中版本信息
        MyFileUtil.ReadConfigDataInStreamingAssetsAsync(VersionInfoFilePath, (innerText) =>
        {
            VersionInfo innerVersionInfo = VersionInfo.ParseData(innerText);

            //外部版本信息
            MyFileUtil.ReadConfigDataInCacheDirAsync(VersionInfoFilePath, (outText) =>
            {
                if (outText != null)
                {
                    VersionInfo outVersionInfo    = VersionInfo.ParseData(outText);
                    outVersionInfo.ProgramVersion = innerVersionInfo.ProgramVersion;
                    callback(outVersionInfo);
                    return;
                }

                callback(innerVersionInfo);
            });
        });
    }
Ejemplo n.º 6
0
    public UnityEngine.Object GetPrefabSync(string abName, string assetName)
    {
        abName = GetFilePathByFileName(abName);


        if (IsUseAssetBundle)
        {
            //LoadAssetBundle(abName, assetName, loadPrefab);
            return(LoadAssetBundleSync(abName, assetName));
        }
        else
        {
            if (abName.EndsWith(mAssetBundleSuffix))
            {
                abName = abName.Remove(abName.Length - mAssetBundleSuffix.Length);
            }

            //去掉后缀名
            abName = MyFileUtil.GetFileNameWithoutExtension(abName);

            string             newAbName = DirNameForAssetBundlesBuildFrom + "/" + abName;
            UnityEngine.Object obj       = GetResourcePrefab(newAbName);
            if (obj == null)
            {
                obj = GetResourcePrefab(abName);
            }

            return(obj);
        }
    }
Ejemplo n.º 7
0
    public VersionInfo GetInnerVersionInfo()
    {
        string      innerText        = MyFileUtil.ReadConfigDataInStreamingAssets(VersionInfoFilePath);
        VersionInfo innerVersionInfo = VersionInfo.ParseData(innerText);

        return(innerVersionInfo);
    }
Ejemplo n.º 8
0
    //在生成资源包时使用
    static public string SerializeInEditor(List <ResInfo> listResInfo)
    {
        string      innerText        = MyFileUtil.ReadConfigDataInStreamingAssets(VersionManager.VersionInfoFilePath);
        VersionInfo innerVersionInfo = VersionInfo.ParseData(innerText);

        var root = new System.Security.SecurityElement("root");

        root.AddChild(new System.Security.SecurityElement("ProgramVersion", innerVersionInfo.ProgramVersion.ToString()));
        root.AddChild(new System.Security.SecurityElement("ApkUrl", innerVersionInfo.ApkUrl));
        root.AddChild(new System.Security.SecurityElement("ApkMd5"));
        root.AddChild(new System.Security.SecurityElement("IOSAppUrl", innerVersionInfo.IOSAppUrl));
        root.AddChild(new System.Security.SecurityElement("IOSAppStoreUrl", innerVersionInfo.IOSAppStoreUrl));
        root.AddChild(new System.Security.SecurityElement("IsAppleAppStore", innerVersionInfo.IsAppleAppStore.ToString()));
        root.AddChild(new System.Security.SecurityElement("IsOpenAutoUpdateInAppStore", innerVersionInfo.IsOpenAutoUpdateInAppStore.ToString()));
        root.AddChild(new System.Security.SecurityElement("IsForceToUpdate", innerVersionInfo.IsForceToUpdate.ToString()));
        var resInfoNode = new System.Security.SecurityElement("ResInfo");

        root.AddChild(resInfoNode);

        foreach (var item in listResInfo)
        {
            var recordNode = new System.Security.SecurityElement("Record");
            resInfoNode.AddChild(recordNode);

            recordNode.AddChild(new System.Security.SecurityElement("ResName", item.resName));
            recordNode.AddChild(new System.Security.SecurityElement("ResMD5", item.resMD5));
            recordNode.AddChild(new System.Security.SecurityElement("ResURL", item.resURL));
            recordNode.AddChild(new System.Security.SecurityElement("ResSize", item.resSize.ToString()));
            recordNode.AddChild(new System.Security.SecurityElement("ResRequire", "true"));
            recordNode.AddChild(new System.Security.SecurityElement("resRequireID", item.resRequireID.ToString()));
        }

        return(root.ToString());
    }
Ejemplo n.º 9
0
    static public void CheckParticleNum()
    {
        try
        {
            int             maxParticles = 60;
            string          strEffectDir = Application.dataPath + "/Resources/Effect";
            List <FileUnit> fileList     = new List <FileUnit>();
            MyFileUtil.GetRelativeFileListWithSpecialFileType(strEffectDir, "Effect", ref fileList, "prefab");

            Dictionary <string, int> fileNeedModifyList = new Dictionary <string, int>();
            for (int i = 0; i < fileList.Count; ++i)
            {
                fileList[i].relativePath = fileList[i].relativePath.Replace(".prefab", "");

                GameObject go = Resources.Load <GameObject>(fileList[i].relativePath);
                if (go == null)
                {
                    string str = string.Format("CheckFile.CheckParticleNum:effec {0:s} is null", fileList[i].relativePath);
                    Debug.LogError(str);
                    continue;
                }
                go = Instantiate(go) as GameObject;
                ParticleSystem[] psList = go.GetComponentsInChildren <ParticleSystem>();

                if (psList == null || psList.Length == 0)
                {
                    DestroyImmediate(go);
                    continue;
                }

                int totalNum = 0;
                foreach (ParticleSystem ps in psList)
                {
                    totalNum += ps.maxParticles;
                }

                if (totalNum > maxParticles)
                {
                    fileNeedModifyList.Add(fileList[i].relativePath, totalNum);
                }

                DestroyImmediate(go);
            }

            string       time     = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
            string       filePath = string.Format("{0:s}/../{1:s}_CheckParticleNum_{2:s}.txt", Application.dataPath, Application.loadedLevelName, time);
            StreamWriter writer   = new StreamWriter(filePath);
            foreach (string name in fileNeedModifyList.Keys)
            {
                string str = string.Format("特效名:{0,-90}粒子数量:{1:d}", name, fileNeedModifyList[name]);
                writer.WriteLine(str);
            }
            writer.Close();
        }
        catch (System.Exception ex)
        {
            Debug.LogError("CheckFile.CheckParticleNum:" + ex.Message);
        }
        Debug.Log("CheckParticleNum结束");
    }
Ejemplo n.º 10
0
    public static void EncodeConfigFile()
    {
        if (SystemConfig.Instance.IsEncryptConfigFile == false)
        {
            return;
        }

        List <string> configList = new List <string>();

        MyFileUtil.GetFileList(MyFileUtil.InnerConfigDir, ref configList, ".xml");

        foreach (string fileName in configList)
        {
            if (fileName.EndsWith(".meta") == true)
            {
                continue;
            }

            byte[] data = File.ReadAllBytes(fileName);
            data = DESCrypto.Encrypt(data, MyFileUtil.EncryptKey);
            File.WriteAllBytes(fileName + MyFileUtil.EncryptXMLFileSuffix, data);
            //MyFileUtil.DeleteFile(fileName);
        }

        AssetDatabase.Refresh();
        Debug.Log("加密配置文件结束");
    }
Ejemplo n.º 11
0
 static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
 {
     for (int i = 0; i < importedAssets.Length; ++i)
     {
         string filePath = MyFileUtil.GetParentDir(Application.dataPath) + importedAssets[i];
         ConvertToUTF8(filePath);
     }
 }
Ejemplo n.º 12
0
    static void EncryptLuaCodeCopyToTargetDir()
    {
        EncryptLuaCodeImp(LuaEncryptType.Auto);

        string luaCodeFilePath = CopyProjectTargetDir + "Assets/StreamingAssets/" + ResourcesManager.LuaZipFileName;

        MyFileUtil.CopyFile(ResourcesManager.LuaZipFileFullPath, luaCodeFilePath);

        Debug.Log("加密Lua代码并复制到拷贝工程");
    }
Ejemplo n.º 13
0
    public static void SetSelectedScriptsToUTF8_BOM()
    {
        foreach (Object obj in Selection.objects)
        {
            string filePath = MyFileUtil.GetParentDir(Application.dataPath) + AssetDatabase.GetAssetPath(obj);
            TextImporter.ConvertToUTF8(filePath);
        }

        Debug.Log("转换文件格式结束");
    }
Ejemplo n.º 14
0
    public static void ClearCoyProjectRes()
    {
        string targetDir = CopyProjectTargetDir;

        //清理目标工程下未加密的配置文件
        List <string> configFileList = new List <string>();

        MyFileUtil.GetFileList(targetDir + "Assets/StreamingAssets/Config", ref configFileList, ".xml");
        foreach (string filePath in configFileList)
        {
            MyFileUtil.DeleteFile(filePath);
        }

        //清理sdk配置文件
        // string localVersionInfoConfigFilePath = targetDir + "Assets/StreamingAssets/Config/" + LocalVersionInfoConfig.fileName + MyFileUtil.EncryptXMLFileSuffix;
        // MyFileUtil.DeleteFile(localVersionInfoConfigFilePath);

        //清理目标工程下未加密的lua文件
        string luaDir = targetDir + "Assets/StreamingAssets/Lua";

        MyFileUtil.DeleteDir(luaDir);

        //清理lua项目配置文件
        List <string> luaProjectFiles    = new List <string>();
        string        streamingAssetsDir = targetDir + "Assets/StreamingAssets";
        DirectoryInfo di = new DirectoryInfo(streamingAssetsDir);
        var           fs = di.GetFiles();

        foreach (var item in fs)
        {
            if (item.FullName.EndsWith(".user"))
            {
                MyFileUtil.DeleteFile(item.FullName);
            }

            if (item.FullName.EndsWith(".luaproj"))
            {
                MyFileUtil.DeleteFile(item.FullName);
            }

            if (item.FullName.EndsWith(".config"))
            {
                MyFileUtil.DeleteFile(item.FullName);
            }
        }

        //清理Resources目录下的文件
        string ResourcesDir = targetDir + "Assets/Resources/" + ResourcesManager.DirNameForAssetBundlesBuildFrom;

        MyFileUtil.DeleteDir(ResourcesDir);


        Debug.Log("清理拷贝工程多余资源");
    }
Ejemplo n.º 15
0
    public static void CopyProject()
    {
        //先删除旧工程
        MyFileUtil.DeleteDir(CopyProjectTargetDir);

        string srcDir = MyFileUtil.GetParentDir(Application.dataPath);

        MyFileUtil.CopyDir(srcDir, CopyProjectTargetDir);

        AssetDatabase.Refresh();
        Debug.Log("拷贝工程结束");
    }
Ejemplo n.º 16
0
    static void FormatChoose()
    {
        string          luaDir   = Application.dataPath + "/StreamingAssets/Lua";
        List <FileUnit> fileList = new List <FileUnit>();

        MyFileUtil.GetRelativeFileListWithSpecialFileType(luaDir, "", ref fileList, "lua");
        for (int i = 0; i < fileList.Count; i++)
        {
            TextImporter.ConvertToUTF8(fileList[i].fullPath);
        }

        Debug.Log("转换Lua脚本格式结束");
    }
Ejemplo n.º 17
0
    static void VersionsDifferenceZipImp(string oldVersionDir, string newVersionDir)
    {
        oldVersionDir = MyFileUtil.DealFilePathSlash(oldVersionDir);
        newVersionDir = MyFileUtil.DealFilePathSlash(newVersionDir);

        List <string> oldFileList = new List <string>();
        List <string> newFileList = new List <string>();

        MyFileUtil.GetFileList(oldVersionDir, ref oldFileList);
        MyFileUtil.GetFileList(newVersionDir, ref newFileList);

        List <string> modificationFileList = new List <string>();

        foreach (string newFilePath in newFileList)
        {
            int index = oldFileList.IndexOf(newFilePath);
            if (index < 0)
            {
                //添加新的文件
                modificationFileList.Add(newFilePath);
            }
            else
            {
                string oldFilePath = oldFileList[index];
                if (MD5Tool.VerifyFile(newFilePath, oldFilePath) == false)
                {
                    //文件改变
                    modificationFileList.Add(newFilePath);
                }
            }
        }

        //string time = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");

        string modificationDir = MyFileUtil.GetParentDir(newVersionDir) + "update_tmp";

        MyFileUtil.DeleteDir(modificationDir);
        MyFileUtil.CreateDir(modificationDir);

        foreach (string filePath in modificationFileList)
        {
            string newFilePath = filePath.Replace(newVersionDir, modificationDir);
            MyFileUtil.CopyFile(filePath, newFilePath);
        }

        string zipFilePath = modificationDir + ".zip";

        ZIPTool.CompressDirectory(modificationDir, zipFilePath, 0, false);

        Debug.Log("");
    }
Ejemplo n.º 18
0
    public static bool IsReleaseAssetBundleImmediately = false; //是否立即释放AssetBundle

    public void UnloadAsset(string assetBundleName)
    {
        if (IsUseAssetBundle)
        {
            assetBundleName = GetFilePathByFileName(assetBundleName);
            UnloadAssetBundle(assetBundleName, true);
        }
        else
        {
            assetBundleName = GetFilePathByFileName(assetBundleName);
            if (assetBundleName.EndsWith(mAssetBundleSuffix))
            {
                assetBundleName = assetBundleName.Remove(assetBundleName.Length - mAssetBundleSuffix.Length);
            }

            //去掉后缀名
            assetBundleName = MyFileUtil.GetFileNameWithoutExtension(assetBundleName);

            string newAbName = DirNameForAssetBundlesBuildFrom + "/" + assetBundleName;
            if (mDictResources.ContainsKey(newAbName) == false)
            {
                if (mDictResources.ContainsKey(assetBundleName) == false)
                {
                    ResourceUnit ru = mDictResources[assetBundleName];
                    mDictResources.Remove(assetBundleName);
                    foreach (UnityEngine.Object obj in ru.instanceList)
                    {
                        UnityEngine.Object.Destroy(obj);
                    }
                    ru.prefab = null;
                    ru        = null;
                    Resources.UnloadUnusedAssets();
                }
                else
                {
                    Debug.LogError("Not Found Resource When UnloadAsset : " + assetBundleName);
                }
            }
            else
            {
                ResourceUnit ru = mDictResources[newAbName];
                mDictResources.Remove(newAbName);
                foreach (UnityEngine.Object obj in ru.instanceList)
                {
                    UnityEngine.Object.Destroy(obj);
                }
                ru.prefab = null;
                ru        = null;
            }
        }
    }
Ejemplo n.º 19
0
    //[MenuItem("Build/清理当前工程下加密的lua文件")]
    public static void ClearCurrentProjectLuaRes()
    {
        List <string> srcLuaFileList = new List <string>();

        MyFileUtil.GetFileList(ResourcesManager.LuaDirForBuild, ref srcLuaFileList, MyFileUtil.EncryptXMLFileSuffix);
        foreach (string filePath in srcLuaFileList)
        {
            MyFileUtil.DeleteFile(filePath);
        }

        MyFileUtil.DeleteFile(ResourcesManager.LuaZipFileFullPath);

        AssetDatabase.Refresh();
    }
Ejemplo n.º 20
0
    static private void ParseConfig()
    {
        m_ListConfig = new List <ZipResConfig>();

        string xmlContent = MyFileUtil.ReadConfigDataInStreamingAssets("ZipResConfig.xml");

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmlContent);

        var root       = doc.DocumentElement;
        var recordList = root.GetElementsByTagName("Record");

        foreach (var recordNode in recordList)
        {
            ZipResConfig config = new ZipResConfig();

            XmlElement recordElem = ((XmlElement)recordNode);
            foreach (var resNode in recordElem.ChildNodes)
            {
                XmlElement resElem  = ((XmlElement)resNode);
                string     nodeName = resElem.Name.ToLower();
                switch (nodeName)
                {
                case "resdir": config.resDir = resElem.InnerText; break;

                case "ressuffix":
                {
                    string[] suffixArray = resElem.InnerText.Split(',');
                    foreach (string suffix in suffixArray)
                    {
                        config.listResSuffix.Add(suffix.Trim());
                    }
                }
                break;

                case "specialrespath": config.listSpecialResPath.Add(resElem.InnerText); break;

                case "reszipname": config.resZipName = resElem.InnerText; break;

                case "resrequireid":
                    config.resRequireID = int.Parse(resElem.InnerText);
                    break;
                }
            }

            m_ListConfig.Add(config);
        }
    }
Ejemplo n.º 21
0
        public static List <ResourceApiInfo> GetVipParserApiList()
        {
            string dirPath = GetDllRoot() + "VipParser.txt";

            if (File.Exists(dirPath))
            {
                MyJsonUtil <List <ResourceApiInfo> > myJsonUtil = new MyJsonUtil <List <ResourceApiInfo> >();
                List <ResourceApiInfo> list = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath));
                return(list);
            }
            else
            {
                return(new List <ResourceApiInfo>());
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 获取基础配置
        /// </summary>
        /// <returns></returns>
        public static BaseJson GetBaseJsonConfig()
        {
            string dirPath = GetDllRoot() + "BaseJson.txt";

            if (File.Exists(dirPath))
            {
                MyJsonUtil <BaseJson> myJsonUtil = new MyJsonUtil <BaseJson>();
                BaseJson baseJson = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath));
                return(baseJson);
            }
            else
            {
                return(new BaseJson());
            }
        }
Ejemplo n.º 23
0
        public static MovieConfig GetMovieJsonConfig()
        {
            string dirPath = GetDllRoot() + "MovieConfig.txt";

            if (File.Exists(dirPath))
            {
                MyJsonUtil <MovieConfig> myJsonUtil = new MyJsonUtil <MovieConfig>();
                MovieConfig movieConfig             = myJsonUtil.parseJsonStr(MyFileUtil.readFileAll(dirPath));
                return(movieConfig);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 24
0
    public static void BuildAllAssetBundles()
    {
        string assetbundlePath = ResourcesManager.AssetBundlesResDirInStreamingAssetsPath;

        //先删除所有旧文件
        string rootDir = MyFileUtil.GetParentDir(assetbundlePath);

        MyFileUtil.DeleteDir(rootDir);
        MyFileUtil.CreateDir(assetbundlePath);

        //获取文件列表
        List <string> fileList = ResourcesManager.GenerateFileList(ResourcesManager.DirForAssetBundlesBuildFrom);

        //-------------------------------------------------------------//

        List <AssetBundleBuild> bundleList = new List <AssetBundleBuild>();

        for (int i = 0; i < fileList.Count; ++i)
        {
            string filePath = fileList[i];
            if (filePath.EndsWith(".meta"))
            {
                continue;
            }

            List <string> assetList = new List <string>();
            string        assetPath = filePath.Substring(filePath.IndexOf("Assets"));
            assetList.Add(assetPath);

            string dirNameForAssetBundlesBuildFrom = "/" + ResourcesManager.DirNameForAssetBundlesBuildFrom + "/";
            int    startPos = assetPath.IndexOf(dirNameForAssetBundlesBuildFrom) + dirNameForAssetBundlesBuildFrom.Length;
            //int endPos = assetPath.LastIndexOf(".");
            //string assetBundleName = assetPath.Substring(startPos, endPos - startPos);
            string assetBundleName = assetPath.Substring(startPos);

            AssetBundleBuild assetBundleBuild = new AssetBundleBuild();
            assetBundleBuild.assetBundleName = assetBundleName + ResourcesManager.mAssetBundleSuffix;
            //assetBundleBuild.assetBundleVariant = ResourcesManager.mAssetBundleSuffix.Replace(".", "");
            assetBundleBuild.assetNames = assetList.ToArray();

            bundleList.Add(assetBundleBuild);
        }

        BuildPipeline.BuildAssetBundles(assetbundlePath, bundleList.ToArray(), BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);

        Debug.Log("BuildAssetBundles Over");
    }
Ejemplo n.º 25
0
    static void CheckRepeatFileName()
    {
        string          dir      = MyFileUtil.CacheDir;
        List <FileUnit> fileList = new List <FileUnit>();

        MyFileUtil.GetRelativeFileList(dir, ref fileList, ".meta");

        for (int i = 0; i < fileList.Count; ++i)
        {
            FileUnit unit = fileList[i];
            FileInfo fi   = new FileInfo(unit.name);
            string   ext  = fi.Extension;
            unit.name = unit.name.Replace(ext, "");
        }

        List <string>    mNameList = new List <string>();
        HashSet <string> mDictName = new HashSet <string>();

        foreach (FileUnit unit in fileList)
        {
            if (mDictName.Contains(unit.name))
            {
                mNameList.Add(unit.name);
            }
            else
            {
                mDictName.Add(unit.name);
            }
        }

        if (mDictName.Count > 0)
        {
            string time     = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");
            string filePath = string.Format("{0:s}/../CheckRepeatFileName_{1:s}.txt", Application.dataPath, time);

            StreamWriter writer = new StreamWriter(filePath);
            writer.WriteLine("重复文件名:");
            foreach (string name in mNameList)
            {
                writer.WriteLine(name);
            }

            writer.Close();
        }

        Debug.Log("CheckRepeatFileName结束");
    }
Ejemplo n.º 26
0
    //-----------------------------------------------------------------------------------//

    //检查安装包中版本号和本地版本号--可能在游戏重新安装时缓存文件没被清理
    public void CheckInstallationPackageVersionWithLocal(Action callback = null)
    {
        MyFileUtil.ReadConfigDataInCacheDirAsync(VersionInfoFilePath, (outText) =>
        {
            if (outText == null)
            {
                if (callback != null)
                {
                    callback();
                }
                return;
            }

            //判断本地版本号和包体内部版本号
            MyFileUtil.ReadConfigDataInStreamingAssetsAsync(VersionInfoFilePath, (innerText) =>
            {
                VersionInfo innerVersionInfo = VersionInfo.ParseData(innerText);

                VersionInfo outVersionInfo = VersionInfo.ParseData(outText);

                if (innerVersionInfo.ProgramVersion > outVersionInfo.ProgramVersion)
                {
                    //清空本地资源
                    MyFileUtil.DeleteDir(MyFileUtil.CacheDir);
                    MyFileUtil.CreateDir(MyFileUtil.CacheDir);
                }

                /*
                 * foreach(var item in innerVersionInfo.dictRes)
                 * {
                 *  if(outVersionInfo.dictRes.ContainsKey(item.Key))
                 *  {
                 *      ResInfo outResInfo = outVersionInfo.dictRes[item.Key];
                 *  }
                 * }
                 */

                Debug.Log("VersionManager.CheckLocalLuaCodeVersion");
                if (callback != null)
                {
                    callback();
                }
            });
        });
    }
Ejemplo n.º 27
0
    static private void CreateCharacterPrefab()
    {
        foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets))
        {
            GameObject go = obj as GameObject;
            if (go == null)
            {
                continue;
            }

            string path = AssetDatabase.GetAssetPath(go);
            if (path.Contains("Art/Character/") == false)
            {
                continue;
            }

            if (path.Contains("@"))
            {
                continue;
            }

            if (path.EndsWith(".fbx", true, null) == false)
            {
                continue;
            }

            path = path.Replace("Art/Character/", "ForAssetBundles/Player/");
            string dir = MyFileUtil.GetParentDir(path);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            int index = path.LastIndexOf(".");
            if (index > 0)
            {
                path = path.Substring(0, index);
            }
            path += ".prefab";
            PrefabUtility.CreatePrefab(path, go, ReplacePrefabOptions.Default);
        }

        AssetDatabase.Refresh();
        Debug.Log("CreateCharacterPrefab Over");
    }
Ejemplo n.º 28
0
    public static void ClearCurrentProjectRes()
    {
        //清理当前工程下加密的配置文件
        List <string> srcConfigFileList = new List <string>();

        MyFileUtil.GetFileList(MyFileUtil.InnerConfigDir, ref srcConfigFileList, MyFileUtil.EncryptXMLFileSuffix);

        foreach (string filePath in srcConfigFileList)
        {
            MyFileUtil.DeleteFile(filePath);
        }

        //清理当前工程下加密的lua文件
        ClearCurrentProjectLuaRes();

        AssetDatabase.Refresh();
        Debug.Log("清理当前工程多余资源");
    }
Ejemplo n.º 29
0
    static public void SaveFileList()
    {
        string dir = "";

        if (IsUseAssetBundle)
        {
            dir = AssetBundlesResDirInStreamingAssetsPath;
        }
        else
        {
            dir = DirForAssetBundlesBuildFrom;
        }

        List <string> fileList = GenerateFileList(dir);
        string        xml      = GetFileListXMLString(fileList, dir);

        MyFileUtil.WriteConfigDataInStreamingAssets(FileListConfigFileName, xml);
    }
Ejemplo n.º 30
0
 /// <summary>
 /// 获取本地配置文件
 /// </summary>
 /// <returns></returns>
 public static SystemConfigJson GetSystemConfigJson()
 {
     try
     {
         if (!File.Exists(GetSystemConfigJsonPath()))
         {
             return(null);
         }
         else
         {
             MyJsonUtil <SystemConfigJson> myJsonUtil = new MyJsonUtil <SystemConfigJson>();
             string           content          = MyFileUtil.readFileAll(GetSystemConfigJsonPath());
             SystemConfigJson systemConfigJson = myJsonUtil.parseJsonStr(content);
             return(systemConfigJson);
         }
     }catch (Exception e)
     {
         return(null);
     }
 }