Unity 中关于Assetbundle的Editor操作

 //
    // 摘要:
    //   把资源打成AssetBundle包,

    //
 [MenuItem("Tools/Build Hall AssetBundles")]
    static void BuildHallAssetBundles()
    {
                //执行打包
        BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.DeterministicAssetBundle, EditorUserBuildSettings.activeBuildTarget);

        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
}

// // 摘要: // 列出编辑器Project窗口中选中的文件,它所依赖的资源 // // [MenuItem("Tools/List Dependencies")] static void ListDependencies() { string path = AssetDatabase.GetAssetPath(UnityEditor.Selection.activeObject); if (path != "") { string[] dps = AssetDatabase.GetDependencies(path); Debug.Log(string.Format("List dependencies:[{0}]", path)); for (int i = 0; i < dps.Length; i++) { Debug.Log(string.Format(" Item {0}:", i + 1)); Debug.Log(string.Format(" path:{0}", dps[i])); Debug.Log(string.Format(" GUID:{0}", AssetDatabase.AssetPathToGUID(dps[i]))); } } }
//
    // 摘要:
    //     清理游戏本地的设置数据,PlayerPrefs,
    //
    //
    [MenuItem("Tools/Clear PlayerPrefs")]
    public static void ClearPlayerPrefs()
    {
        PlayerPrefs.DeleteAll();
    }

    //
    // 摘要:
    //     显示PC中StreamingAssets下的所有assetbundle名字
    //
    //
    [MenuItem("Tools/Show All AssetBundles")]
    public static void ShowAllAssetBundles()
    {
        AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "StreamingAssets"));
        AssetBundleManifest manifest = bundle.LoadAsset("AssetBundleManifest");
        bundle.Unload(false);
        string[] BundleNames = manifest.GetAllAssetBundles();
        foreach (string name in BundleNames)
        {
            Debug.Log("ResTools: " + name);
        }
    }
    //
    // 摘要:
    //     打开PC的persistentDataPath目录
    //
    //
    [MenuItem("Tools/Show PersistentData in Explorer...")]
    public static void ShowPersistentDataInExplor()
    {
        string path = Application.persistentDataPath.Replace("/", "\\");
        System.Diagnostics.Process.Start(path);
    }



你可能感兴趣的:(unity)