-
Notifications
You must be signed in to change notification settings - Fork 548
Resource Management
Framework unified resource management to the Explorer Explorer open: Window -> 打包设置管理器(Package Settings Manager)
Click "自动添加 Resources 目录下的资源并保存"(Resources automatically added Resources directory and save) Resources will automatically generate Resources Resources directory under a ResourcesManifest
At the same time will generate a Version file stored in the Resources directory, this file is used to determine the version of the heat update.
Tip: Whenever a new file is added to Resources, remember to click the button again
All resources are loaded from the ResourceManager class
Load resources ** only need name, do not need to pass the path **
So this requires the name of all the files in the project ** Do not repeat **
static string ReadTextFile (string textName)
reads a text file and returns its contents
static object Load (string name)
Load a resource
static T Load (T) (string name) where T: UnityEngine.Object
Load a resource of type T
static void LoadAsync (string name, LoadCallBack callBack)
Asynchronously load a resource
static void UnLoad (string name)
Uninstalling a resource (only works in Bundle mode)
void Update ()
{
if (Input.GetKey (KeyCode.A))
{
GameObject cube = (GameObject) ResourceManager.Load ("Cube");
Instantiate (cube);
}
}
If you want to use AssetsBundle, you need to first package your assets into AssetsBundle
the specific method is in Window->打包设置编辑器 (package settings editor) ->自动添加Resource目录下的资源并保存 (automatically add resources under the Resource directory and save) ->打包 (package)
Then check the UseAssetsBundle in the Application
After you update your resources, remember to re-package your AssetsBundle, If you think the whole package time is too long, you can individually package a resource
I recommend using Resource mode during development and AssetsBundle mode at release time
Bundle resource duplication can be avoided by setting reasonable dependencies.
Set the method in the Dependencies tab, click Add a dependency package, modify the name of the dependent package, and add dependencies to the package's resources.
After you have set up your dependencies, the newly added resources automatically detect the dependencies.
Only supports up to 32 dependent packages.
Bundle packing is required for hot updates
Hot Update using Hot Update Manager
First of all need to click on the package update button in the package settings editor to create a hot update configuration
Select HotUpdateConfig in the configuration editor, fill in DownLoadPath and save it.
Upload all the files in the StreamingAssets directory to the hot update download directory, the format of which is DownLoadPath \ platform \ version number
Hot Update Rules:
First download the Version file, compare the version number, (in the package manager can configure the version number)
If the server version of the larger version, the direct prompt to update the entire package
If the major version numbers are consistent and the minor version number on the server is large, download the ResourcesManifest file, compare the file differences, and begin to download the difference file.
If they are the same, go straight to the game
example:
Suppose DownLoadPath = http://127.0.0.1
Project version number is 1.0.1 (consistent with ProjectSetting)
Platform for Android
Upload the hot update file to http://127.0.0.1/Android/1.0.1
Platform has Win / Android / IOS
HotUpdateManager
static void StartHotUpdate (HotUpdateCallBack CallBack)
Start the thermal update
public class HotUpdateStatus: IApplicationStatus
{
public override void OnEnterStatus ()
{
HotUpdateManager.StartHotUpdate (HotUpdate);
}
private void HotUpdate (HotUpdateStatusInfo info)
{
Debug.Log ("HotUpdate status" + info.m_status + "progress" + info.m_loadState.progress);
if (info.isFailed)
{
Debug.LogError ("HotUpdate isFailed ==>" + info.m_status);
return;
}
if (info.m_status == HotUpdateStatusEnum.UpdateSuccess)
{
ApplicationStatusManager.EnterStatus <LoginStatus> ();
}
}
}