U3D-Assetbundle加载
首先 写个打包成Assetbundle的脚本 放在Editor下
using UnityEngine; using System.Collections; using UnityEditor;public class NewBehaviourScript :ScriptableObject {[MenuItem("chen/create assetbundle main")]static void cam(){ object[] selected = Selection.GetFiltered(typeof(object), SelectionMode.DeepAssets);foreach (Object obj in selected){ string source = AssetDatabase.GetAssetPath(obj);string target = Application.dataPath + "/chensiyang/" + obj.name + ".assetbundle";if (BuildPipeline.BuildAssetBundle(obj, null, target, BuildAssetBundleOptions.CollectDependencies))Debug.Log("yes");elseDebug.Log("wrong");}}[MenuItem("chen/create assetbundle all")]static void caa(){ Object[] selectedall = Selection.GetFiltered(typeof(object),SelectionMode.DeepAssets);string aim = Application.dataPath + "/chensiyang/all.assetbundle";if (BuildPipeline.BuildAssetBundle(null, selectedall, aim, BuildAssetBundleOptions.CollectDependencies))Debug.Log("all");else Debug.Log("wrong");}}
然后加载包
using UnityEngine; using System.Collections; using System.IO;public class NewBehaviourScript2 : MonoBehaviour {private static string path ="file://"+Application.dataPath+"/chensiyang/";// Use this for initializationvoid Start () {print(Application.dataPath);StartCoroutine(load(path + "all.assetbundle"));}// Update is called once per framevoid Update () {//if(Input.GetMouseButtonDown(0)) }private IEnumerator load(string str){ WWW data = new WWW(str);yield return data;Instantiate(data.assetBundle.Load("tv"));data.assetBundle.Unload(false);} }
还有一种加载方式,避免重复下载
private IEnumerator load(string str){//WWW data = new WWW(str);//yield return data;//Instantiate(data.assetBundle.Load("tv"));//data.assetBundle.Unload(false);WWW data = WWW.LoadFromCacheOrDownload(str, 5);yield return data;yield return Instantiate(data.assetBundle.Load("tv"));data.assetBundle.Unload(false);} }
转载于:https://www.cnblogs.com/mukeyang/p/4522679.html
U3D-Assetbundle加载相关推荐
- U3D assetbundle加载与卸载的深入理解
U3D assetbundle加载与卸载的深入理解 using UnityEngine; using System.Collections; using System;public class tes ...
- U3D assetbundle加载
U3D assetbundle加载 1 using UnityEngine; 2 using System.Collections; 3 public class testLoadFromAB : M ...
- 关于unity 中使用AssetBundle加载资源,shader偶尔会丢失的问题解决办法
问题描述: 因为项目中要进行热更新设计,所以用unity官方推荐的打包方式assetbundle进行打包,打包好了以后再电脑上运行正常,但是当发布到android上后发现偶尔场景背景会出现空白,多方查 ...
- 正确使用AssetBundle加载和卸载
在使用Unity开发项目时,AssetBundle是必须使用的,对资源进行打包加载,因为移动端游戏包体的大小对用户体验非常重要,对内存的使用更加重要,下面我们就介绍一下关于AssetBundlle的使 ...
- AssetBundle加载和卸载
https://blog.csdn.net/qq_33337811/article/details/73849019 转载 Unity5的AssetBundle管理(加载.卸载) 一.获取AssetB ...
- 小功能⭐️U3D异步加载功能
文章目录 假设当前场景为A,我们要切换到下一场景B,如果使用正常加载方式,Unity会在切换场景时加载场景B的所有内容(Hierarchy面板内容)到内存中,由于加载场景B是同步执行的,所以当场景B较 ...
- 游戏资源差异化热更新及加密全攻略(Assetbundle 打包 AssetBundle 加载 AssetBundle 加密)
游戏热更新资源加密的必要性 unity中资源热更新还是Assetbundle为主,资源使用越来越广泛,ab包里可以包含图片.视频或者脚本,都是游戏的知识财产,如果被破解者或者竞争对手解开,拿到里面的内 ...
- unity 异步加载网络图片_一个非常好用的AssetBundle资源加载器
Loxodon Framework Bundle是一个非常好用的AssetBundle加载器,也是一个AssetBundle冗余分析工具.它能够自动管理AssetBundle之间复杂的依赖关系,它通过 ...
- Unity AssetBundle的打包 发布 下载与加载
码字不易,转载请注明出处哦 https://blog.csdn.net/newchenxf/article/details/124738469 1 前文 都2022了,为什么还讨论AB包?不是有Add ...
- AssetBundle异步加载被中断的问题
1)AssetBundle异步加载被中断的问题 2)LuaDLL.lua_pcall()自身产生开销问题 3)法线在手机渲染时出现的错误问题 4)UNITY_MATRIX_I_V 和Camera.m ...
最新文章
- python开发环境和运行环境的区别_Django 开发环境与生产环境的区分详解
- android application常见错误
- Keras【Deep Learning With Python】Autoencoder 自编码(看不懂你打我系列!)
- rust种的南瓜为什么老是消失_农村大集会消失吗?为什么农村大集这么受欢迎?说说我的真实感受...
- Spring Boot 中如何实现 HTTP 认证?
- S6 文件备份与压缩命令
- OSI七层模型的作用
- ecshop商品属性价不打折
- 银行剧震!国内第一家无人银行来了...
- win10 uwp 渲染原理 DirectComposition 渲染
- Android adb重启手机
- ipad air1 12.5.5 checkra1n 越狱+绕过ID
- 【Scratch】《零基础入门学习Scratch》(小甲鱼)笔记一
- “深度学习”和“多层神经网络”的区别
- 在html怎么使用jq插件,jQuery标签输入插件
- catalina 无法验证macos_macOS 10.15 Catalina无法打开app,提示“因为无法确认开发者身份”问题的解决方法......
- 阿里云进入Iot Studio
- 如何把程序员从久坐颈椎病中拯救出来?我为程序员做了这个救命APP
- POE电源模块详解及设计参考-MQ7801/MQ7802
- 如何将360流量监控数据清零 解决方法