示例#1
0
    bool ExportVersion(string moduleName)
    {
        int streamingHotVersion = 0;
        int cdnHotVersion       = 0;

        if (FileManager.IsFileExist(ConstValue.STREAMING_DIR_PATH + "/" + moduleName + "/" + ConstValue.VERSION_NAME))
        {
            byte[] streamingVersionBytes = FileManager.Read(ConstValue.STREAMING_DIR_PATH + "/" + moduleName + "/" + ConstValue.VERSION_NAME);
            string streamingVersionStr   = streamingVersionBytes == null ? null : ConvertExt.BytesToString(streamingVersionBytes);
            //Debug.LogError("streamingVersionStr = " + streamingVersionStr);

            JsonObject streamingVersionInfoJo = StringParser.StringToJo(streamingVersionStr, false);
            m_streamingVersion = JsonParser.JoItemToString(streamingVersionInfoJo, ConstValue.VERSION_KEY, ConstValue.VERSION);
            //Debug.LogError("streaming version: " + m_streamingVersion);
            string[] streamingVersions = m_streamingVersion.Split('.');
            streamingHotVersion = StringParser.StringToInt(streamingVersions[2]);
        }
        else
        {
            return(false);
        }

        if (FileManager.IsFileExist(m_CdnNativePath + "/" + moduleName + "/" + ConstValue.VERSION_NAME))
        {
            byte[] cdnVersionBytes = FileManager.Read(m_CdnNativePath + "/" + moduleName + "/" + ConstValue.VERSION_NAME);
            string cdnVersionStr   = cdnVersionBytes == null ? null : ConvertExt.BytesToString(cdnVersionBytes);
            //Debug.LogError("cdnVersionStr = " + cdnVersionStr);

            JsonObject cdnVersionInfoJo = StringParser.StringToJo(cdnVersionStr, false);
            m_CdnVersion = JsonParser.JoItemToString(cdnVersionInfoJo, ConstValue.VERSION_KEY, ConstValue.VERSION);
            //Debug.LogError("Cdn version: " + m_CdnVersion);
            string[] cdnVersions = m_CdnVersion.Split('.');
            cdnHotVersion = StringParser.StringToInt(cdnVersions[2]);
        }
        else
        {
            return(false);
        }

        if (streamingHotVersion <= cdnHotVersion)
        {
            return(false);
        }

        FileCopyTo(ConstValue.STREAMING_DIR_PATH + "/" + moduleName + "/" + ConstValue.VERSION_NAME,
                   m_PackagePath + "/" + moduleName + "/" + ConstValue.VERSION_NAME);

        return(true);
    }
示例#2
0
    void ExportAssetBundles(string moduleName)
    {
        if (FileManager.IsFileExist(ConstValue.STREAMING_DIR_PATH + "/" + moduleName + "/" + ConstValue.FILE_LIST_NAME))
        {
            byte[] streamingFileListBytes = FileManager.Read(ConstValue.STREAMING_DIR_PATH + "/" + moduleName + "/" + ConstValue.FILE_LIST_NAME);
            string streamingFileListStr   = streamingFileListBytes == null ? null : ConvertExt.BytesToString(streamingFileListBytes);
            m_StreamingFileList = StringParser.StringToJo(streamingFileListStr, false);
        }
        else
        {
            m_StreamingFileList = new JsonObject();
        }

        if (FileManager.IsFileExist(m_CdnNativePath + "/" + moduleName + "/" + ConstValue.FILE_LIST_NAME))
        {
            byte[] cdnFileListBytes = FileManager.Read(m_CdnNativePath + "/" + moduleName + "/" + ConstValue.FILE_LIST_NAME);
            string cdnFileListStr   = cdnFileListBytes == null ? null : ConvertExt.BytesToString(cdnFileListBytes);
            m_CdnFileList = StringParser.StringToJo(cdnFileListStr, false);
        }
        else
        {
            m_CdnFileList = new JsonObject();
        }

        foreach (string fileName in m_StreamingFileList.Keys)
        {
            string     srcPath         = ConstValue.STREAMING_DIR_PATH + "/" + fileName;
            string     destPath        = m_PackagePath + "/" + fileName;
            JsonObject streamingInfoJo = JsonParser.JoItemToJo(m_StreamingFileList, fileName);
            string     streamingMd5    = JsonParser.JoItemToString(streamingInfoJo, ConstValue.FILE_LIST_MD5_KEY);
            if (m_CdnFileList.ContainsKey(fileName))
            {
                JsonObject cdnInfoJo = JsonParser.JoItemToJo(m_CdnFileList, fileName);
                string     cdnMd5    = JsonParser.JoItemToString(cdnInfoJo, ConstValue.FILE_LIST_MD5_KEY);
                if (!string.Equals(streamingMd5, cdnMd5))
                {
                    FileCopyTo(srcPath, destPath);
                }
            }
            else
            {
                FileCopyTo(srcPath, destPath);
            }
        }
        AssetDatabase.Refresh();
    }