Exemplo n.º 1
0
    public IEnumerator Teardown()
    {
        Autoya.AssetBundle_UnloadOnMemoryAssetBundles();


        var discarded = false;

        // delete assetBundleList anyway.
        Autoya.AssetBundle_DiscardAssetBundleList(
            () =>
        {
            discarded = true;
        },
            (code, reason) =>
        {
            switch (code)
            {
            case Autoya.AssetBundlesError.NeedToDownloadAssetBundleList:
                {
                    discarded = true;
                    break;
                }

            default:
                {
                    Fail("code:" + code + " reason:" + reason);
                    break;
                }
            }
        }
            );

        yield return(WaitUntil(
                         () => discarded,
                         () => { throw new TimeoutException("too late."); }
                         ));

        var listExists = Autoya.AssetBundle_IsAssetBundleFeatureReady();

        True(!listExists, "exists, not intended.");

        True(Caching.CleanCache());
    }
Exemplo n.º 2
0
    static void CreateAssetBunldesALL()
    {
        Caching.CleanCache();
        string Path = Application.dataPath + "/StreamingAssets/ALL.assetbundle";

        Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        foreach (Object obj in SelectedAsset)
        {
            Debug.Log("Create AssetBunldes name :" + obj);
        }

        if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.CollectDependencies))
        {
            AssetDatabase.Refresh();
        }
        else
        {
        }
    }
    public static IEnumerator DownLoadAsset <T>(string url, string assetName, int version, Action <T> OnDownloadComplete) where T : UnityEngine.Object
    {
                #if UNITY_EDITOR
        Caching.CleanCache();
                #endif
        WWW www = WWW.LoadFromCacheOrDownload(url, version);

        // Wait for download to complete
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            OnDownloadComplete(null);
        }
        else
        {
            // Load and retrieve the AssetBundle
            AssetBundle bundle = www.assetBundle;

            // Load the object asynchronously
            // UnityEngine.Object[] objects = bundle.LoadAll();

            // foreach(var item in objects)
            //	F2ULogManager.F2ULog("Downloaded " + item.name + " of type " + item.GetType().FullName, F2ULogManager.Type.Notice);

            AssetBundleRequest request = bundle.LoadAsync(assetName, typeof(T));

            // Wait for completion
            yield return(request);

            // Get the reference to the loaded object
            T obj = request.asset as T;

            OnDownloadComplete(obj);

            // Unload the AssetBundles compressed contents to conserve memory
            bundle.Unload(false);

            // Frees the memory from the web stream
            www.Dispose();
        }
    }
Exemplo n.º 4
0
    protected virtual void EnterAwakeState(fsm.State _from, fsm.State _to, fsm.Event _event)
    {
        //Debug.Log("EnterAwakeState");
        if (!isDevelopmentPattern)
        {
            Application.targetFrameRate = 30;//限制最多每秒计算30帧
        }
        Caching.CleanCache();
        //LayerMng.Init();
        if (stageObj == null)
        {
            stageObj = new GameObject();
            stageObj.transform.parent        = this.transform;
            stageObj.transform.localPosition = Vector3.zero;
            stageObj.name = "Stage";
        }


        GameObject assetLoadObj = new GameObject();

        assetLoadObj.transform.parent        = this.transform;
        assetLoadObj.transform.localPosition = Vector3.zero;
        assetLoadObj.name = "AssetLoad";
        AssetMng assetMng = assetLoadObj.AddComponent <AssetMng>();

        assetMng.Init();

        GameObject.DontDestroyOnLoad(this.gameObject);

        ResgistMsg();

        //UI部分
        if (isDevelopmentPattern)
        {
            stateMachine.Send((int)EventType.INIT_CONFIG);
        }
        else
        {
            //GameCenter.uIMng.SwitchToUI(GUIType.UPDATEASSET);
            stateMachine.Send((int)EventType.UPDATEASSET);
        }
    }
Exemplo n.º 5
0
    static void CreateSingleAssetBundle()
    {
        Caching.CleanCache();

        Object[] SelectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        foreach (Object obj in SelectedAsset)
        {
            Debug.Log("Create AssetBunldes name :" + obj);
        }
        string Path = Application.streamingAssetsPath;

        Path = EditorUtility.SaveFilePanel("save", Path, "", "unity3d");

        //这里注意第二个参数就行
        if (BuildPipeline.BuildAssetBundle(null, SelectedAsset, Path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android))
        {
            AssetDatabase.Refresh();
        }
    }
Exemplo n.º 6
0
 void Awake()
 {
     if (instance == null)
     {
         Caching.CleanCache();
         DontDestroyOnLoad(this);
         prefab_dict = new Dictionary <string, GameObject>();
         mat_dict    = new Dictionary <string, Material>();
         changelog   = new Dictionary <int, JsonData>();
         StartCoroutine(LoadAssetBundleOnApp(material_bundle_name, "material"));
         StartCoroutine(LoadAssetBundleOnApp(prefab_bundle_name, "prefab"));
         StartCoroutine(LoadAssetBundleOnApp(scene_bundle_name, "scenes"));
         instance   = this;
         obj_in_use = null;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 7
0
        public static void BuildAssetBundles(bool deleteOld = false)
        {
            string outputPath = Path.Combine(Utility.AssetBundlesOutputPath, Utility.GetPlatformName());

            if (Directory.Exists(outputPath))
            {
                if (deleteOld)
                {
                    Directory.Delete(outputPath, true);
                    Directory.CreateDirectory(outputPath);
                }
            }
            else
            {
                Directory.CreateDirectory(outputPath);
            }
            Caching.CleanCache();
            BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
            AssetBundleBuilder.CopyAssetBundlesTo(Path.Combine(Application.streamingAssetsPath, Utility.AssetBundlesOutputPath));
        }
Exemplo n.º 8
0
 public static void BuildResourceFromUnityRule()
 {
     //清空所有Assetbundle数据
     if (Directory.Exists(ResourceCommon.assetbundleFilePath))
     {
         Debug.Log("存在目录先删除");
         Directory.Delete(ResourceCommon.assetbundleFilePath, true);
     }
     //刷新数据
     Caching.CleanCache();
     AssetDatabase.Refresh();
     //获取资源信息
     //GetBuildScenes();
     GetBuildResource();
     //获取打包的所有Asset
     GetAllAssets();
     BuildResource();
     DumpResourceInfoFile();
     AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
 }
    public IEnumerator Start()
    {
        AssetBundlePersistentPath = Application.persistentDataPath + "/" + "myfirstassetbundle";
        //キャッシュクリア
        Caching.CleanCache();

        // ファイルが無かったらやめる
        if (!System.IO.File.Exists(AssetBundlePersistentPath))
        {
            Debug.Log("File does NOT exist!!, path = " + AssetBundlePersistentPath);
            speare.GetComponent <Renderer> ().material.color = Color.red;
            yield break;
        }

        // Asset Bundleのロード処理
        yield return(StartCoroutine(LoadAssetBundleCoroutine()));

        // ロード完了後、Assetが取り出せるようになる
        speare.GetComponent <Renderer>().material.mainTexture = GetSpriteFromAssetBundle("Alexs_Apt_8k").texture;
    }
Exemplo n.º 10
0
    static void CreateAssetBunldesScenes_Windows()
    {
        Caching.CleanCache();

        Object[] selectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        string[] selectPaths = new string[selectedAsset.Length];

        string sceneNames = "";

        for (int i = 0; i < selectedAsset.Length; i++)
        {
            selectPaths[i] = AssetDatabase.GetAssetPath(selectedAsset[i]);
            if (!selectPaths[i].Contains(".unity"))
            {
                Debug.LogError("打包失败!场景选的不对!");
                return;
            }

            sceneNames += selectedAsset[i].name;

            if (i < selectedAsset.Length - 1)
            {
                sceneNames += "-";
            }
        }
        string targetPath = Application.streamingAssetsPath + "/AssetBundles/Win32/Scenes/";

        if (!System.IO.Directory.Exists(targetPath))
        {
            System.IO.Directory.CreateDirectory(targetPath);
        }

        targetPath += (sceneNames + "_Win32_Scene.assetbundle");

        BuildPipeline.BuildStreamedSceneAssetBundle(selectPaths, targetPath, BuildTarget.StandaloneWindows);

        Debug.Log(sceneNames + "打包成功。\n路径:" + targetPath);

        AssetDatabase.Refresh();
    }
Exemplo n.º 11
0
        public override void Start()
        {
            Service.Get <EventManager>().SendEvent(EventId.AssetLoadStart, null);
            if (!GameConstants.ASSET_BUNDLE_CACHE_CLEAN_DISABLED)
            {
                int @int = PlayerPrefs.GetInt("cacheCleanVersion", 0);
                if (@int < GameConstants.ASSET_BUNDLE_CACHE_CLEAN_VERSION)
                {
                    bool isSuccess = Caching.CleanCache();
                    Service.Get <BILoggingController>().TrackAssetBundleCacheClean(GameConstants.ASSET_BUNDLE_CACHE_CLEAN_VERSION, isSuccess);
                    PlayerPrefs.SetInt("cacheCleanVersion", GameConstants.ASSET_BUNDLE_CACHE_CLEAN_VERSION);
                    PlayerPrefs.Save();
                }
            }
            new ProjectorManager();
            AssetManager assetManager  = Service.Get <AssetManager>();
            bool         fueInProgress = Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress;

            assetManager.SetupManifest(fueInProgress);
            assetManager.LoadGameShaders(new AssetsCompleteDelegate(this.OnShadersComplete), null);
        }
Exemplo n.º 12
0
    IEnumerator loadBundle(string name)
    {
        if (assetBundle != null)
        {
            assetBundle.Unload(false);
        }
        Caching.CleanCache();
        var www = WWW.LoadFromCacheOrDownload("" + name + "?c=3", 1); //31.7.162.98, inside aua 10.1.0.118

        loadScreen.SetActive(true);
        //
        while (!www.isDone)
        {
            Debug.Log(www.progress);
            slider.value = www.progress;
            yield return(null);
        }
        Debug.Log("Downloaded");
        assetBundle = www.assetBundle;
        SceneManager.LoadScene(name, LoadSceneMode.Single);
    }
Exemplo n.º 13
0
    static void BuildResourcesExecute()
    {
        Caching.CleanCache();//使用cach模式加载,第一次指定BundleURL,之后会有缓存,需要清除一下

        string buildPath = BuildUtil.GetBuildDir(target);
        string resPath   = Path.Combine(buildPath, "res");

        //if (Directory.Exists(streamPath))
        //{
        //    Directory.Delete(streamPath, true);
        //    if (File.Exists(streamPath + ".meta"))
        //        File.Delete(streamPath + ".meta");
        //}

        AssetDatabase.Refresh();

        ResourcesHandle(resPath);

        BuildUtil.GenVersionFile(buildPath, BuildUtil.VersionEnum.RES);
        BuildUtil.BuildFileIndex(buildPath);
    }
Exemplo n.º 14
0
    public void GetManifest(bool forceRedownloadAsset = false)
    {
        if (null == Instance)
        {
            return;
        }

        if (null == mMainfestMgr)
        {
            mMainfestMgr = new ManifestManager();
        }

        string cachePath = Application.persistentDataPath + "/UnityCache/Shared/";

        if (forceRedownloadAsset && Caching.CleanCache())
        {
            Debug.Log("Successfully cleaned the cache.");
        }

        StartCoroutine(StartDownload());
    }
Exemplo n.º 15
0
        public void Start()
        {
            var assemblyFile = Assembly.GetExecutingAssembly().Location;
            var bundlePath   = "file://" + assemblyFile.Replace(new FileInfo(assemblyFile).Name, "").Replace("\\", "/") + "../AssetBundles/";

            //var filePath = assemblyFile.Replace(new FileInfo(assemblyFile).Name, "") + "../AssetBundles/";

            Logger.Log("Loading bundles from BundlePath: " + bundlePath, Logger.Level.Debug);

            //need to clean cache
            Caching.CleanCache();

            StartCoroutine(LoadBundle(bundlePath + "ir_ui_objects.ksp"));

            /*if(IRAssetBundle==null)
             * {
             *  Logger.Log("Loading bundles from filePath: " + filePath, Logger.Level.Debug);
             *  LoadBundleFromDisk(filePath + "ir_ui_objects.ksp"); //bundle must be uncompressed for this function to work
             * }
             */
        }
Exemplo n.º 16
0
 void Build()
 {
     Caching.CleanCache();
     Object[] selectedAsset = Selection.GetFiltered(typeof(Object), _selectionMode);
     Debug.Log("selected object count :" + selectedAsset == null? 0: selectedAsset.Length);
     if (selectedAsset != null && selectedAsset.Length > 0)
     {
         string path = Application.dataPath + "/StreamingAssets/" + bundleName + ".assetbundle";
         Debug.Log("path :" + path);
         BuildTarget selMode = (BuildTarget)System.Enum.Parse(typeof(BuildTarget), _plateformAry [_plateformIdx]);
         if (BuildPipeline.BuildAssetBundle(null, selectedAsset, path, BuildAssetBundleOptions.CollectDependencies, selMode))
         {
             AssetDatabase.Refresh();
             result = "success!";
         }
         else
         {
             result = "failed!";
         }
     }
 }
Exemplo n.º 17
0
    //导出场景资源包
    public static void ExportScenes(List <string> scenes)
    {
        UnityEngine.Debug.ClearDeveloperConsole();
        Caching.CleanCache();
        if (scenes.Count > 0)
        {
            int createdBundles = 0;
            int allBundles     = scenes.Count;
            foreach (string pair in scenes)
            {
                string[] levels = { pair };

                DirectoryInfo dirInfo   = new DirectoryInfo(pair);
                string        sceneName = dirInfo.Name;
                sceneName = sceneName.Replace(".unity", EditorTools.mFileExtension);

                string path = EditorTools.mExportFolderLocationFloder;

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                BuildPipeline.BuildStreamedSceneAssetBundle(levels, path + sceneName, EditorTools.mBuildTarget);

                createdBundles++;

                Debug.Log("场景:   " + sceneName + "  导出完毕!  适用于:" + EditorTools.mBuildTarget + " 平台!");
            }
            if (createdBundles > 0)
            {
                Debug.Log("***本地 场景 成功打包: " + createdBundles + "/" + allBundles + " 场景资源!***");
            }
        }
        else
        {
            Debug.Log("没有资源可以打包!请选择资源!");
        }
        AssetDatabase.Refresh();
    }
Exemplo n.º 18
0
    //-------------------------------------------------------------------------
    void _packAssetBundleCompressAll(string target_path)
    {
        EditorUserBuildSettings.SwitchActiveBuildTarget(mCurrentBuildTargetPlatform);
        deleteFile(mTargetPlatformRootPath);

        Caching.CleanCache();

        mListAllPkgSingleABFile.Clear();
        _getAllPkgSingleFiles(mAssetBundleResourcesPkgSinglePath);
        mListAllPkgFoldABFold.Clear();
        _getAllPkgFoldFold(mAssetBundleResourcesPkgFoldPath);

        _pakABSingle();
        _pakABFold();

        if (Directory.Exists(mRowAssetPath))
        {
            copyFile(mRowAssetPath, target_path, "Assets/");
        }

        Debug.Log("裸资源复制完毕!");
    }
Exemplo n.º 19
0
    public static bool BuildBundle(BuildTarget target)
    {
        string bundleDirPath = GetTargetPath(target);

        if (Directory.Exists(bundleDirPath))
        {
            Directory.Delete(bundleDirPath, true);
        }

        if (!ConfigurationController.Instance.BuildAssetBundle)
        {
            return(true);
        }

        try {
            Caching.CleanCache();
            m_BundleMap.Clear();

            Directory.CreateDirectory(bundleDirPath);
            BuildPipeline.BuildAssetBundles(bundleDirPath, BuildAssetBundleOptions.None, target);

            string[] manifests = Directory.GetFiles(bundleDirPath, "*.manifest", SearchOption.AllDirectories);
            foreach (string s in manifests)
            {
                if (s.Replace(bundleDirPath, "") == MiscUtils.GetCurrentPlatform() + ".manifest")
                {
                    continue;
                }
                File.Delete(s);
            }
        } catch (Exception e) {
            Debug.Log(e.Message);
            return(false);
        } finally {
            AssetDatabase.Refresh();
        }

        return(true);
    }
Exemplo n.º 20
0
    void Pack(string path, string pathName)
    {
        Caching.CleanCache();
        List <Object> files = new List <Object>();

        if (path.Contains("."))
        {
            string filePath = cut2AssetFolder(path);
            files.Add(AssetDatabase.LoadAssetAtPath(filePath, typeof(Object)));
        }
        else
        {
            string[] filePaths = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
            for (int i = 0; i < filePaths.Length; ++i)
            {
                string filePath = cut2AssetFolder(filePaths[i]);
                files.Add(AssetDatabase.LoadAssetAtPath(filePath, typeof(Object)));
            }
        }

        if (!pathName.Contains("."))
        {
            string tName = path.Substring(path.LastIndexOf("/"));
            if (tName == "/")
            {
                tName = path.Substring(path.Remove(path.LastIndexOf("/")).LastIndexOf("/")).Replace("/", "");
            }
            if (tName.Contains("."))
            {
                tName = tName.Remove(tName.IndexOf("."));
            }
            pathName = string.Format("{0}/{1}{2}", pathName, tName, ".bytes");
        }
        for (int i = 0; i < files.Count; ++i)
        {
            BuildTarget tar = ios ? BuildTarget.iPhone : (android ? BuildTarget.Android : BuildTarget.StandaloneWindows);
            BuildPipeline.BuildAssetBundle(files[i], null, pathName, BuildAssetBundleOptions.CollectDependencies, tar);
        }
    }
Exemplo n.º 21
0
    static void CreateAssetBundlesSolo()
    {
        Caching.CleanCache();
        Object[] selectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        string   targetPath    = string.Empty;

        foreach (Object obj in selectedAsset)
        {
            targetPath = Application.dataPath + "/StreamingAssets/" + obj.name + ".assetbundle";

            if (BuildPipeline.BuildAssetBundle(obj, null, targetPath, BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.CollectDependencies))
            {
                Debug.Log(obj.name + "资源打包成功");
            }
            else
            {
                Debug.Log(obj.name + "资源打包失败");
            }
        }

        AssetDatabase.Refresh();
    }
Exemplo n.º 22
0
    public static void ReadCSV()
    {
        Caching.CleanCache();
        Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

        for (int i = 0; i < selection.Length; i++)
        {
            string   path     = Path.Combine(Application.dataPath, "DataParse/Data");
            string   fileName = selection[i].name;
            string   pathTemp = AssetDatabase.GetAssetPath(selection[i]);
            string[] s        = File.ReadAllLines(pathTemp, System.Text.Encoding.UTF8);
            path += "/" + fileName.Split('_')[0] + ".txt";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            Debug.LogWarning(path);
            File.WriteAllLines(path, s, System.Text.Encoding.UTF8);
        }

        AssetDatabase.Refresh();
    }
Exemplo n.º 23
0
 public override void DeInitialize()
 {
     IsAdmin = false;
     Enabled = false;
     RustBuster2016.API.Hooks.OnRustBusterClientPluginsLoaded -= Loaded;
     RustBuster2016.API.Hooks.OnRustBusterClientChat          -= OnRustBusterClientChat;
     foreach (var x in AllSpawnedObjects)
     {
         if (x.ObjectInstantiate != null)
         {
             UnityEngine.Object.Destroy(x.ObjectInstantiate);
         }
     }
     UnityEngine.Object.Destroy(MainHolder);
     AllSpawnedObjects.Clear();
     if (LoadingHandler.bundle != null)
     {
         LoadingHandler.bundle.Unload(true); // Unload all objects from the bundle.
     }
     Caching.expirationDelay = 1;
     Caching.CleanCache();
 }
Exemplo n.º 24
0
 public void OnPointerClick(PointerEventData data)
 {
     // if clicked at button
     // if (EventSystem.current.currentSelectedGameObject.GetComponent<Button>() != null)
     if (gameObject.tag == "b")
     {
         // clean cache before quit, make sure we can download it next time; for convenience of new Assetbunld
         if (Caching.CleanCache())
         {
             Debug.Log("Successfully cleaned the cache.");
         }
         else
         {
             Debug.Log("Cache is being used.");
         }
         #if UNITY_EDITOR
         UnityEditor.EditorApplication.isPlaying = false;
         #else
         Application.Quit();
         #endif
     }
 }
Exemplo n.º 25
0
        //初始化资源 切换android文件 获得不同的依赖
        IEnumerator InitRes(string assetbundleType, Action callback)
        {
            _isSwithingRes = true;

            yield return(StartCoroutine(Initialize(assetbundleType)));

            //强制清除缓存
            Caching.CleanCache();

            AssetBundleManager.Variants = new[] { ActiveVariants };

            Debug.Log(assetbundleType + "资源初始化完成!" + Time.time);

            Messenger.Broadcast(XEvent.FinishLoadAssetBundle, assetbundleType);

            _isSwithingRes = false;

            if (callback != null)
            {
                callback();
            }
        }
 public static void CreatAssetBundleToServer()
 {
     Caching.CleanCache();
     Object[] selectedAssets = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
     foreach (Object obj in selectedAssets)
     {
         AssetBundleBuild[] buildMap = new AssetBundleBuild[1];
         buildMap[0].assetBundleName = obj.name;
         //string[] assetsName = new string[1];
         string[] assetsName = { "Assets/Prefabs/" + obj.name.ToString() + ".prefab" };
         buildMap[0].assetNames = assetsName;
         if (BuildPipeline.BuildAssetBundles("Assets/Server", buildMap, BuildAssetBundleOptions.DeterministicAssetBundle))
         {
             Debug.Log("打包成功!");
         }
         else
         {
             Debug.Log("打包失败!");
         }
     }
     AssetDatabase.Refresh();
 }
Exemplo n.º 27
0
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Asset Bundle Output Path");
        filePath = EditorGUILayout.TextField(filePath);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        targetPlatform = (BuildTarget)EditorGUILayout.EnumPopup(targetPlatform);
        if (GUILayout.Button("BuildAssetBundles"))
        {
            BuildPipeline.BuildAssetBundles(filePath, BuildAssetBundleOptions.None, targetPlatform);
        }
        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("Clear Asset Budles From Cahe"))
        {
            Caching.CleanCache();
        }

        EndWindows();
    }
Exemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        if (cleanCacheOnStart)
        {
#if UNITY_2017_1_OR_NEWER
            Caching.ClearCache();
#else
            Caching.CleanCache();
#endif
        }

        foreach (var asset in assets)
        {
            if (!asset.IsFlagedForUpload)
            {
                continue;
            }

            StartCoroutine(GetFilePath(asset));
            GetContentUploadURL(asset);
        }
    }
Exemplo n.º 29
0
    /// <summary>
    /// Builds the asset bundles.
    /// </summary>
    /// <param name="buildTarget">Build target.</param>
    /// <param name="platform">Platform.</param>

    static void BuildAssetBundles(BuildTarget buildTarget, string platform)
    {
        Caching.CleanCache();
        string targetPath = TARGET_DIR + Path.DirectorySeparatorChar + platform;

        Debug.Log(targetPath);
        if (!File.Exists(targetPath))
        {
            Directory.CreateDirectory(targetPath);
        }
        // Put the bundles in a folder called "ABs" within the Assets folder.
        BuildPipeline.BuildAssetBundles(targetPath,
                                        BuildAssetBundleOptions.CollectDependencies |
                                        BuildAssetBundleOptions.CompleteAssets |
                                        BuildAssetBundleOptions.DisableWriteTypeTree |
                                        BuildAssetBundleOptions.DeterministicAssetBundle |
                                        BuildAssetBundleOptions.ForceRebuildAssetBundle |
                                        BuildAssetBundleOptions.ChunkBasedCompression

                                        , buildTarget);
        AssetDatabase.Refresh();
    }
Exemplo n.º 30
0
    static void ExportResource()
    {
        // 打开保存面板,获取用户选择的路径
        //string path = EditorUtility.SaveFilePanel("Save Resource", "", "New Resource", "assetbundle");

        Caching.CleanCache();

        // 选择的要保存的对象
        UnityEngine.Object[] selection = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets);
        if (selection.Length <= 0)
        {
            Debug.Log("请选择被创建的物体");
            return;
        }
        for (int i = 0; i < selection.Length; i++)
        {
            string targetPath = ToolScript.WindowsAssetBundelPath;
            targetPath += "/" + selection[i].name + ".assetbundle";
            Debug.Log(targetPath);
            // LZ4格式打包

            if (BuildPipeline.BuildAssetBundle(selection[0], selection, targetPath,
                                               BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows))
            {
                Debug.Log(selection[i].name + "Windows资源打包成功");
            }
            else
            {
                Debug.Log(selection[i].name + "Windows资源打包失败");
            }
        }

        //	BuildPipeline.BuildAssetBundles(path,BuildAssetBundleOptions.None,BuildTarget.StandaloneWindows);



        Debug.Log("build success");
    }