当前位置:网站首页>[learning notes] AssetBundle, xlua, hot update (use steps)
[learning notes] AssetBundle, xlua, hot update (use steps)
2022-06-30 05:07:00 【zjh_ three hundred and sixty-eight】
One 、AssetBundle
1、 pack AssetBundle package
① Take the model as an example , Drag the model into a prefab
② Set the preset resource ab Package name and suffix ( Suffix customization has the effect of confusing the public ); File name plus “/” It can be directly managed as a folder , such as scene/sphere, This will generate a folder after packaging scene There is sphere package

③ Create packaging ab Bag Editor Script ( This script must be placed in Editor In the folder )
using UnityEditor;
using System.IO;
public class CaretAssetBundle {
[MenuItem("Assets/Build AssetBundles")]
static void BuildAssetBundles()
{
string dir = "AssetBundles";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
BuildPipeline.BuildAssetBundles(dir, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
}
④ Then in the menu bar Assets/Build AssetBundles Click next to generate ab package .
2、 load AssetBundle package
Local loading mode : Create a script in the scene , The runtime loads the following code , Can be loaded locally ab Package resources , Asynchronous
void Start () {
AssetBundle ab = AssetBundle.LoadFromFile("AssetBundles/cube.unity3d");
GameObject obj = ab.LoadAsset<GameObject>("Plane");//Plane by cube.unity3d One of the objects in it
Instantiate(obj);
// Record all objects in the package
//object[] objs = ab.LoadAllAssets();
//foreach (Object item in objs)
//{
// Instantiate(item);
//}
}
Server loading mode :UnityWebRequest The method applies to 5.x Later versions , yes WWW An upgraded version of
IEnumerator WebLoadAB(){
// Server load : Use UnityWebRequest
string url = @"http://localhost/AssetBundles/cube.unity3d";
UnityWebRequest request = UnityWebRequest.GetAssetBundle(url);
yield return request.Send();
AssetBundle ab = (request.downloadHandler as DownloadHandlerAssetBundle).assetBundle;
//GameObject obj = ab.LoadAsset<GameObject>("Plane");
//Instantiate(obj);
object[] objs = ab.LoadAllAssets();
foreach (Object item in objs)
{
Instantiate(item);
}
}
manifest File loading mode : All packages can be loaded , You can also get package dependencies

manifest In the document CRC, It is judged when the corresponding network is abnormal , If CRC If the code is not correct, the download is not completed , The file is missing and needs to be downloaded again .
3、AssetBundle Grouping and packaging policy

① Rely on packaging : For multiple models sharing maps 、 Of material assets , Reduce ab Packet size is very effective ; The method is to separate the models 、 Material maps are packaged separately , Such as the A Model 、B Model , Sharing the C Texture mapping , Then give them separately ABC Pack separately , A total of 3 individual assetbundle package , After loading and running ,AB The model is automatically associated C resources . Here's the picture , The bottom three on the right are dependency packaging , The cumulative size of the packages on the left that are not shared with mapped materials will be larger .

4、AssetBundle The uninstall
Resources need to be unloaded when they are not in use , To free up memory

Two 、xLua
To be changed ...
3、 ... and 、 Hot update
To be changed ...
边栏推荐
- Create a simple battle game with photon pun
- Pit of smoothstep node in shadergraph
- Using the command line to convert JSON to dart file in fluent
- 力扣(LeetCode)180. 连续出现的数字(2022.06.29)
- OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
- Unity + hololens publishing settings
- Chapter 7 vertex processing and drawing commands of OpenGL super classic (7th Edition)
- Sourcetree usage
- Output directory of log files after unity3d packaging
- 一条命令运行rancher
猜你喜欢

Pit of smoothstep node in shadergraph

中文版PyCharm改为英文版PyCharm

Writing unityshader with sublimetext

Unreal 4 learning notes - data storage using blueprints

Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor

LxC and LXD container summary

Unity3d Google Earth

Deep learning ----- different methods to realize inception-10

力扣27. 移除元素

Force buckle 977 Square of ordered array
随机推荐
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
Unity profiler performance analysis
Unreal 4 learning notes - Animated Montage
Solution to the 292 week match of Li Kou
【VCS+Verdi联合仿真】~ 以计数器为例
JS 数组的排序 sort方法详解
003-JS-DOM-Attr-innerText
[recruitment] UE4 Development Engineer
Postman 做测试的 6 个常见问题
虚析构和纯虚析构
Unity multiple UI page turning left and right
Singapore must visit these scenic spots during the Spring Festival
Solution to 293 problems in the week of Li Kou
Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)
力扣59. 螺旋矩阵 II
Win10 vs2015 compiling curaengine
Unity supports the platform # define instruction of script
产生 BUG 测试人员需要自己去分析原因吗?
Unrealeengine4 - about uobject's giant pit that is automatically GC garbage collected
Unity + hololens2 performance test