public override void OnGUI(string searchContext)
        {
            base.OnGUI(searchContext);

            AssetVersionSetting setting = AssetVersionSetting.GetInstance();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("保存"))
            {
                setting.Save();
            }

            if (GUILayout.Button("生成资源版本文件"))
            {
                AssetVersionBuilder.GenerateAssetVersionFile();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            if (EGLUtility.Folder(out setting.AssetVersionFilePath
                                  , "资源版本文件路径"
                                  , setting.AssetVersionFilePath))
            {
                m_FormatedVersionFilePath = setting.GetFormatedAssetVersionFilePath();
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("资源版本文件路径", m_FormatedVersionFilePath);
            if (GUILayout.Button("打开", GUILayout.Width(36)))
            {
                EditorUtility.RevealInFinder(m_FormatedVersionFilePath);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
예제 #2
0
        /// <summary>
        /// 根据平台生成平台包下的所有文件的配置信息
        /// </summary>
        public static void GenerateAssetVersionFile()
        {
            AssetVersionSetting setting = AssetVersionSetting.GetInstance();

            string directory = string.Empty;

            directory = Path.GetDirectoryName(setting.GetFormatedAssetVersionFilePath());
            DirectoryInfo directoryInfo = new DirectoryInfo(directory);

            directory = directoryInfo.FullName;
            directory = directory.Replace("\\", "/");
            if (string.IsNullOrEmpty(directory))
            {
                MDebug.LogError(LOG_NAME, "Target AssetVersionFile Path invalid !");
                return;
            }
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            string        assetVersionFilePath = setting.GetFormatedAssetVersionFilePath();
            StringBuilder str = new StringBuilder();

            FileInfo[] files = directoryInfo.GetFiles("*", SearchOption.AllDirectories);
            if (files != null)
            {
                string assetVersionFileName = setting.GetAssetVersionFileName();
                for (int i = 0; i < files.Length; i++)
                {
                    FileInfo fileInfo     = files[i];
                    string   fileFullName = fileInfo.FullName;
                    fileFullName = fileFullName.Replace("\\", "/");
                    string fileName         = fileFullName.Substring(fileFullName.LastIndexOf("/") + 1);
                    string fileRelativePath = fileFullName.Substring(directory.Length + 1);
                    if (fileName.Contains(".meta") ||
                        fileName.Equals(assetVersionFileName))
                    {
                        continue;
                    }
                    string md5       = EncrypUtil.GetFileMD5(fileFullName);
                    string size      = Math.Ceiling(fileInfo.Length / 1024f).ToString();
                    string commitStr = $"{fileRelativePath} {md5} {size}";
                    str.AppendLine(commitStr);
                }
            }
            File.WriteAllText(assetVersionFilePath, str.ToString());
            EditorUtility.DisplayDialog(LOG_NAME
                                        , "生成资源版本文件完成!"
                                        , "OK");
        }
 public AssetVersionSettingProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null)
     : base(path, scopes, keywords)
 {
     m_FormatedVersionFilePath = AssetVersionSetting.GetInstance().GetFormatedAssetVersionFilePath();
 }