Beispiel #1
0
    static void SaveAssetList()
    {
        StreamWriter writerXml = new StreamWriter(ASSETSFILE);

        writerXml.Write(list.ToXml());
        writerXml.Close();
        writerXml.Dispose();
    }
Beispiel #2
0
    static void SaveBuildList(string outputPath)
    {
        AssetList        buildList = new AssetList();
        HashSet <string> bundeList = new HashSet <string>();

        buildList.manifest = EditorUserBuildSettings.activeBuildTarget.ToString();
        bundeList.Add(buildList.manifest);

        foreach (var file in list.assets.Values)
        {
            if (file.asset.Contains("resources/") == false || string.IsNullOrEmpty(file.bundle) == false)
            {
                if (buildList.Contains(file.name) == false && buildList.assets.ContainsValue(file) == false)
                {
                    if (string.IsNullOrEmpty(file.bundle))
                    {
                        string fullPath = string.Format("{0}{1}", outputPath, file.asset);
                        byte[] bytes    = File.ReadAllBytes(fullPath);
                        file.size = bytes.Length;
                        file.md5  = MD5Hash.Get(bytes);
                    }
                    else
                    {
                        file.size = 0;
                        file.md5  = null;
                        bundeList.Add(file.bundle);
                    }
                    buildList.assets.Add(file.name, file);
                }
            }
            else
            {
                if (buildList.Contains(file.name) == false && buildList.assets.ContainsValue(file) == false)
                {
                    string fullPath = string.Format("{0}{1}", Application.dataPath.Replace("Assets", ""), file.asset);
                    byte[] bytes    = File.ReadAllBytes(fullPath);
                    file.size = bytes.Length;
                    file.md5  = MD5Hash.Get(bytes);
                    buildList.assets.Add(file.name, file);
                }
            }
        }
        foreach (var name in bundeList)
        {
            string    fullPath = string.Format("{0}{1}", outputPath, name);
            byte[]    bytes    = File.ReadAllBytes(fullPath);
            AssetFile file     = new AssetFile();
            file.name   = name;
            file.bundle = name;
            file.size   = bytes.Length;
            file.md5    = MD5Hash.Get(bytes);
            buildList.assets.Add(file.name, file);
        }

        string assetXmlFile = outputPath + "/" + AssetPath.ASSETSFILE;

        StreamWriter writerXml = new StreamWriter(assetXmlFile);

        writerXml.Write(buildList.ToXml());
        writerXml.Close();
        writerXml.Dispose();
    }