QFrameWork学习笔记 《一》导出unity包

  1. 生成文件名:
 public static string GenerateUnityPackageName()
        {
            return "QFramework_" + DateTime.Now.ToString("yyyyMMdd_HHmm");
        }
  1. 文本复制到剪切板
 public static void CopyText(string text)
        {
            GUIUtility.systemCopyBuffer = text;
        }
  1. 导出包
        public static void ExportPackage(string assetPathName, string fileName)
        {
            AssetDatabase.ExportPackage(assetPathName, fileName, ExportPackageOptions.Recurse);
        }
  1. 打开文件夹
  public static void OpenInFolder(string folderPath)
        {
            Application.OpenURL("file:///" + folderPath);
        }
  1. 复用MenuItem
  public static void CallMenuItem(string menuPath)
        {
            EditorApplication.ExecuteMenuItem(menuPath);
        }
  1. 自定义快捷键
        #if UNITY_EDITOR
        [UnityEditor.MenuItem("QFramework/Example/3.自定义快捷键导出 %e", false, 3)]       
        private static void ClickShortCut()
        {          
            EditorUtil.CallMenuItem("QFramework/Framework/Editor/导出unityPackage");
            Debug.Log("自定义快捷键导出:ExporterExample");
        }
        #endif

总结

 public partial class Exporter
    {

    
        [MenuItem("QFramework/Framework/Editor/生成文件名", false, 1)]
        private static void ClickGeneratePackageName()
        {
            Debug.Log(GenerateUnityPackageName());
        }



        [MenuItem("QFramework/Framework/Editor/导出unityPackage", false, 2)]
        private static void MenuClicked()
        {
            EditorUtil.ExportPackage("Assets/QFramework", GenerateUnityPackageName() + ".unitypackage");
            EditorUtil.OpenInFolder(Path.Combine(Application.dataPath, "../"));
        }

 
        //---------------------生成文件名--------------------------
        
        public static string GenerateUnityPackageName()
        {
            return "QFramework_" + DateTime.Now.ToString("yyyyMMdd_HHmm");
        }
    }
  public partial class EditorUtil
    {
        #if UNITY_EDITOR
        //导出包
        public static void ExportPackage(string assetPathName, string fileName)
        {
            AssetDatabase.ExportPackage(assetPathName, fileName, ExportPackageOptions.Recurse);
        }

        //打开文件夹
        public static void OpenInFolder(string folderPath)
        {
            Application.OpenURL("file:///" + folderPath);
        }

        //复用MenuItem
        public static void CallMenuItem(string menuPath)
        {
            EditorApplication.ExecuteMenuItem(menuPath);
        }
        #endif
    }

你可能感兴趣的:(QFramework框架)