当前位置:网站首页>[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 ...
边栏推荐
- Unity notes_ SQL Function
- Error about the new version of UE4: unavigationsystemv1:: simplemovetoactor has been deprecated
- Force buckle 27 Removing Elements
- Unity profiler performance analysis
- Network communication problem locating steps
- Under what conditions does the Z-index attribute expire?
- 003-JS-DOM-Attr-innerText
- MinGW-w64下载文件失败the file has been downloaded incorrectly!
- PWN入门(2)栈溢出基础
- Unit screenshot saved on the phone
猜你喜欢
On mask culling of unity
Meet in Bangkok for a romantic trip on Valentine's Day
MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
Records of problems encountered in unity + hololens development
MinGW-w64下载文件失败the file has been downloaded incorrectly!
Network communication problem locating steps
PWN入门(2)栈溢出基础
Unity lens making
Unreal 4 learning notes - data storage using blueprints
Force buckle 59 Spiral matrix II
随机推荐
东塔攻防世界—xss绕过安全狗
Photon pun refresh hall room list
Force buckle 59 Spiral matrix II
产生 BUG 测试人员需要自己去分析原因吗?
Parkour demo
ParticleSystem in the official Manual of unity_ Collision module
SCM learning notes: interrupt learning
力扣704. 二分查找
JS 数组的排序 sort方法详解
C # Foundation
Pycharm database tool
Unity3d lookat parameter description
Leetcode 180 Consecutive numbers (2022.06.29)
MySQL query gadget (I) replace a property value of the object in the JSON array in the JSON format string field
003-JS-DOM-Attr-innerText
Unity supports the platform # define instruction of script
How does unity use mapbox to implement real maps in games?
C # equipment synthesis
How can the international trading platform for frying US crude oil guarantee capital security?
Malignant bug: 1252 of unit MySQL export