Knowledge Preparation (1)

Export to UnityPackgae basically divided into the following steps:

1. Click on the menu bar, the output file

2. Copy the name of the console

3. Right-click "QFramework" folder

4. deselect "include" option

5. Copy and paste the name is derived;

 

(A) Export Unitypackage

  Export Library named QFramework_20190801_23  

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;

public class name : MonoBehaviour 
{
#if UNITY_EDITOR
    [MenuItem("QFramework/1.生成文件名")]
#endif
    private static void MenuClicked()
    {
        Debug.Log("QFramework" + DateTime.Now.ToString("yyyyMMdd_HH"));
    }
}

  This will automatically generate an export file name it;

  Here we continue to do.

(Ii) the name directly copied into the clipboard

   Click on the menu bar to generate names and copy;

using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif


namespace QFramework
{
    public class copy : MonoBehaviour
    {
#if UNITY_EDITOR
        [MenuItem("QFramework/2复制文本")]
#endif
        private static void MenuClick()
        {
            GUIUtility.systemCopyBuffer = "复制文本";
        }
    }
}

Mainly using the editor copy API, in conjunction with the first paragraph of the generated file name, file name can be automatically generated and copied, twelve-step merger. (Note: the output path can not have a Chinese name)

 GUIUtility.systemCopyBuffer = "QFramework" + DateTime.Now.ToString("yyyyMMdd_HH");

This, the second step to complete it. Part III below.

(C) files are packaged using AssetDatabase.ExportPackage;

 

using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace QFramework
{
    public class Package : MonoBehaviour
    {
#if UNITY_EDITOR
        [MenuItem("QFramework/4.打包")]
#endif
        private static void MenuClicked()
        {
            var assetPathName = "Assets/QFramework";
            var fileName = "QFramework_" + DateTime.Now.ToString("yyyyMMdd_HH") + ".unitypackage";
            AssetDatabase.ExportPackage(assetPathName, fileName, ExportPackageOptions.Recurse);
        }
    }
}

Note: 1 To static;.

2. Export path to write to;

Guess you like

Origin www.cnblogs.com/dream-seeker-201907/p/11286084.html