Beispiel #1
0
    private static Dictionary <string, Bundle2Check> ReadLocalXML()
    {
        Dictionary <string, Bundle2Check> dictionary = new Dictionary <string, Bundle2Check>();

        if (!File.Exists(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH))
        {
            XmlDocument xmlDocument = new XmlDocument();
            XmlElement  newChild    = xmlDocument.CreateElement("BundleInfoes");
            xmlDocument.AppendChild(newChild);
            xmlDocument.Save(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH);
        }
        XmlDocument xmlDocument2 = new XmlDocument();

        xmlDocument2.Load(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH);
        XmlElement documentElement = xmlDocument2.DocumentElement;

        foreach (XmlNode xmlNode in documentElement.ChildNodes)
        {
            if (xmlNode is XmlElement)
            {
                Bundle2Check info = AssetBundleChecker.GetInfo(xmlNode);
                if (!dictionary.ContainsKey(info.bundleName))
                {
                    dictionary.Add(info.bundleName, info);
                }
            }
        }
        return(dictionary);
    }
Beispiel #2
0
 void Start() //開始檢查版本
 {
     assetLoader          = gameObject.AddComponent <AssetLoader>();
     bundleChecker        = gameObject.AddComponent <AssetBundleChecker>();
     visionChecker        = new VisionChecker();
     Global.ReturnMessage = "開始檢查遊戲資源. . .";
     StartCoroutine(visionChecker.CheckVision());
     Global.prevScene = Application.loadedLevel;
 }
Beispiel #3
0
    public static List <Bundle2Check> compareBundleInfoes(string text, string localPath)
    {
        List <Bundle2Check> list = new List <Bundle2Check>();
        Dictionary <string, Bundle2Check> dictionary = AssetBundleChecker.ReadLocalXML();
        XmlDocument xmlDocument = new XmlDocument();

        xmlDocument.LoadXml(text);
        XmlElement documentElement = xmlDocument.DocumentElement;
        string     empty           = string.Empty;

        foreach (XmlNode xmlNode in documentElement.ChildNodes)
        {
            if (xmlNode is XmlElement)
            {
                Bundle2Check info = AssetBundleChecker.GetInfo(xmlNode);
                if (dictionary.ContainsKey(info.bundleName))
                {
                    string path = Application.persistentDataPath + "/" + info.bundleName + ".unity3d";
                    if (!File.Exists(path) || !info.bundleMD5.Equals(dictionary[info.bundleName].bundleMD5))
                    {
                        Bundle2Check item = new Bundle2Check
                        {
                            assetType     = info.assetType,
                            bundleMD5     = info.bundleMD5,
                            bundleVersion = info.bundleVersion,
                            bundleName    = info.bundleName,
                            bundleSize    = info.bundleSize
                        };
                        list.Add(item);
                    }
                }
                else
                {
                    Bundle2Check item2 = new Bundle2Check
                    {
                        assetType     = info.assetType,
                        bundleMD5     = info.bundleMD5,
                        bundleVersion = info.bundleVersion,
                        bundleName    = info.bundleName,
                        bundleSize    = info.bundleSize
                    };
                    list.Add(item2);
                }
                AssetBundleInfo.Init(info.bundleName, info.assetType);
                AssetCache.Init(info.bundleName);
            }
        }
        return(list);
    }
Beispiel #4
0
    public static void OverrideLocalXML(string bundleName, int assetType, string md5Code, int newVersion, long nbundleSize)
    {
        Dictionary <string, Bundle2Check> dictionary = AssetBundleChecker.ReadLocalXML();

        if (dictionary.ContainsKey(bundleName))
        {
            if (!dictionary[bundleName].bundleMD5.Equals(md5Code))
            {
                dictionary[bundleName].bundleVersion = newVersion;
                dictionary[bundleName].bundleMD5     = md5Code;
                dictionary[bundleName].bundleSize    = nbundleSize;
            }
        }
        else
        {
            dictionary.Add(bundleName, new Bundle2Check
            {
                bundleVersion = newVersion,
                bundleMD5     = md5Code,
                assetType     = assetType,
                bundleSize    = nbundleSize
            });
        }
        if (File.Exists(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH))
        {
            File.Delete(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH);
        }
        XmlDocument xmlDocument = new XmlDocument();
        XmlElement  xmlElement  = xmlDocument.CreateElement("BundleInfoes");

        xmlDocument.AppendChild(xmlElement);
        foreach (KeyValuePair <string, Bundle2Check> current in dictionary)
        {
            XmlElement xmlElement2 = xmlDocument.CreateElement("Info");
            xmlElement.AppendChild(xmlElement2);
            xmlElement2.SetAttribute("bundleMD5", current.Value.bundleMD5.ToString());
            xmlElement2.SetAttribute("bundleVersion", current.Value.bundleVersion.ToString());
            xmlElement2.SetAttribute("assetType", current.Value.assetType.ToString());
            xmlElement2.SetAttribute("bundleName", current.Key);
            xmlElement2.SetAttribute("bundleSize", current.Value.bundleSize.ToString());
        }
        xmlDocument.Save(AssetBundleChecker.BUNDLE_INFO_XML_PERSIST_PATH);
        xmlDocument = null;
    }