/// <summary> /// 指定扩展名称是否忽略设置AssetBundleName /// </summary> /// <param name="_ext">扩展名</param> /// <returns>True:忽略,False:不忽略</returns> public bool IsIgnoreSetAssetBundleName(string _ext) { int key = _ext.UniqueHashCode(); if (!mIgnoreExtMaping.ContainsKey(key)) { FileExtAttribute attr = null; bool isIgnore = false; for (int i = 0; i < msrIgnoreAssetBundleNames.Count; i++) { attr = typeof(enFileExt).GetAttributeForConstField <FileExtAttribute>(msrIgnoreAssetBundleNames[i]); isIgnore |= attr.IsExt(_ext); if (isIgnore) { break; } } mIgnoreExtMaping.Add(key, isIgnore); } return(mIgnoreExtMaping[key]); }
/// <summary> /// 绘制GUI /// </summary> public void DrawGUI() { mTempIsDirty = false; mTempPaths.Clear(); if (paths != null && paths.Length > 0) { mTempPaths.AddRange(paths); } EditorGUILayout.LabelField(drawGUIDesc); #region Add Path if (GUILayout.Button("Add " + classify.ToString())) { if (mTempPaths.Count < allowOprNum) { #region Add string path = string.Empty; string error = string.Empty; string ext = string.Empty; List <string> legalExts = new List <string>(); bool isLegalFileExt = false; FileExtAttribute fextAttr = null; switch (classify) { case enEditorSavedAssetClassify.File: path = EditorUtility.OpenFilePanel("Add " + classify.ToString(), EditorStrayFogApplication.assetsPath, ""); ext = Path.GetExtension(path); int[] legalFileExts = OnLegalFileExts(); if (legalFileExts != null && legalFileExts.Length > 0) { foreach (int fext in legalFileExts) { fextAttr = typeof(enFileExt).GetAttributeForConstField <FileExtAttribute>(fext); isLegalFileExt |= fextAttr.IsExt(ext); legalExts.Add(fextAttr.ext); } } if (!isLegalFileExt) { error = string.Format("The file must be 【{0}】", string.Join(",", legalExts.ToArray())); } break; case enEditorSavedAssetClassify.Folder: path = EditorUtility.OpenFolderPanel("Add " + classify.ToString(), EditorStrayFogApplication.assetsPath, ""); break; } bool isLegalPath = false; string errTip = string.Empty; #region 判定路径是否合法 switch (pattern) { case enEditorSavedAssetPattern.OnlyInAssets: isLegalPath = EditorStrayFogApplication.IsSubToAssets(path); if (isLegalPath) { path = EditorStrayFogApplication.GetRelativeToAssets(path); } errTip = "in"; break; case enEditorSavedAssetPattern.OnlyOutAssets: isLegalPath = !EditorStrayFogApplication.IsSubToAssets(path); errTip = "out"; break; } #endregion if (isLegalPath) { if (string.IsNullOrEmpty(error)) { if (!mTempPaths.Contains(path)) { mTempPaths.Add(path); mTempIsDirty = true; } } else { EditorUtility.DisplayDialog(classify.ToString(), error, "OK"); } } else { EditorUtility.DisplayDialog(classify.ToString(), classify.ToString() + " must be " + errTip + " 【" + EditorStrayFogApplication.assetsPath + "】", "OK"); } #endregion } else { EditorUtility.DisplayDialog("Add Error", $"Only allow operation {allowOprNum} {classify}", "OK"); } } #endregion #region Display and Delete if (mTempPaths.Count > 0) { int delIndex = -1; for (int i = 0; i < mTempPaths.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField( string.Format("{0}.{1}", (i + 1).PadLeft(mTempPaths.Count), mTempPaths[i])); if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mTempPaths[i]); } if (GUILayout.Button("Reveal")) { EditorStrayFogApplication.RevealInFinder(mTempPaths[i]); } if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete " + classify.ToString(), "Are you sure to delete " + classify.ToString() + " 【" + mTempPaths[i] + "】", "OK", "Cancel")) { delIndex = i; break; } } EditorGUILayout.EndHorizontal(); } if (delIndex >= 0) { mTempPaths.RemoveAt(delIndex); mTempIsDirty = true; } } #endregion if (mTempIsDirty) { paths = mTempPaths.ToArray(); } OnDrawGUI(); GUILayout.HorizontalSlider(0, 0, 0, GUILayout.Height(1)); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (mTempIsDirty) { EditorUtility.SetDirty(this); } }