当前位置:网站首页>Unity resources management series: Unity framework how to resource management
Unity resources management series: Unity framework how to resource management
2022-07-31 04:56:00 【Clank's Game Stack】
Unity Resource Management Requirements Analysis
As an architect, before you start, you must first analyze the requirements clearly, and then you can design a reasonable solution. Let's analyze the requirements of Unity resource management. After thinking about the requirements clearly, the design is a natural thing.
There is a Game Development Exchange Group
a> Everyone can learn and communicate togetherMain requirements for Unity resource management:
1: Provides loading/unloading of resources for development and production;
2: It is convenient to update resources remotely.
3: It is very convenient to publish game packs with and without resources.
4: Do a good job in resource management of versions, platforms and channels.
Technical solutions for Unity resource management
Let's review some of Unity's resource management solutions and analyze their advantages and disadvantages.
(1): The traditional Resources scheme is eliminated.
This solution satisfies the loading and unloading of code resources, but it is inconvenient to update resources. AssetsBundle must be used to update resources. Combining the two sets of things is also very troublesome.Moreover, it is inconvenient to open empty packages. Resources requires all resources to be placed in the Resources folder, and the resources in the Resources folder will be packaged, so it is inconvenient to open empty packages. Generally, Resource solutions are no longer used in enterprises.
(2) Scheme based on pure AssetsBundle.
Now more and more games use pure AssetsBundle for resource management, let's take a look at how to use pure AssetsBundle for resource management.
A: How the code loads resources
Load AssetsBundle first, and then read resources from AssetsBundle.This method can indeed read resources, but there is a very serious problem, that is, when developing, you need to make ab package for resources every time, and every time you add one more resource, you need to make ab package once more. In this way,In fact, it is inconvenient to use.So we thought of a way to add a predefined switch through conditional compilation. If it is in editor debugging mode, then we directly use AssetsDataBase.load to load resources without using the ab package. If it is in release mode, only from the Ab package.Read the resource.In this way, you don't need to care about the ab package when developing, and you can make the ab package when you package and release it.
B: Where are the AssetsBundle resource bundles placed?
AssetsBundle resource bundle is very flexible, it can be placed on both remote servers and local. Next, let's take a look at how AssetsBundle resource bundles are stored and updated.
When packaging, if you want to enter the installation package, then we can put the Ab resource package in the StreammingAssets directory and package it.When loading, use UnityWebRequest to load the ab package in the StreammingAssets directory.If you type an empty package, then StreammingAssets will be fine without any resource package.When the AssetsBundle is updated, first judge the version according to the version, and download the latest AssetsBundle to the private writable directory (each application has its own writable private directory on the operating system).
C: How to use Update AssetsBundle
After downloading the AssetsBundle to the app's private directory, write an interface for loading the AssetsBundle. In this function, first go to the private directory to find out if there is a corresponding AssetsBundle. If so, load it from the private directory. If not, load it from the local directory.Loaded under the StreammingAssets path.This ensures that the AssetsBundle resource package is loaded from the private download directory first.
D: The resource package should be divided into platforms and channels.
We know that different platforms (win64, x86, Mac, iOS and Android) require different resource bundles, so we generally extend the editor and unify one window to manage and package AssetsBundle resource bundles.Packaging interface, as shown in the figure:

Every time you pack, you know which platform you are playing on, which channel and which version of the resource pack, and the output is also divided into platforms and channels.
E: It is very convenient to specify which resources to import into which ab package.
After we have sorted the resources, when creating the ab package, we need to create a new name for the ab package and specify which resources to enter into the ab package. This process, if done manually, will definitely be troublesome and error-prone.Let's summarize, generally our resources are logically and categorized, so the resources of a folder or subfolder can be typed into an ab package. After we have these, we will make an automatic designated resource package.Editor extension.For the file or folder to be packaged, create a database file. When packaging, traverse these database files, and enter the resources under the path into the resource package according to the file path.As shown:


3 Addressable-based resource management.
Unity has launched Addressable-based resource management, which is essentially similar to our AssetsBundle system above. Interested students can pay attention to the development of resource management in this mode.
Resource management and updating are the top priorities of Unity architects, I hope everyone can gain something.
边栏推荐
- ERP生产作业控制 金蝶
- sql statement - how to query data in another table based on the data in one table
- ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost3306' (10061)
- PCL 计算点云坐标最值及其索引
- 聚变云原生,赋能新里程 | 2022开放原子全球开源峰会云原生分论坛圆满召开
- 产学研用 共建开源人才生态 | 2022开放原子全球开源峰会教育分论坛圆满召开
- 扫雷小游戏——C语言
- 开源汇智创未来 | 2022开放原子全球开源峰会OpenAtom openEuler分论坛圆满召开
- .NET-6.WinForm2.NanUI学习和总结
- The idea project obviously has dependencies, but the file is not displayed, Cannot resolve symbol 'XXX'
猜你喜欢

Puzzle Game Level Design: Reverse Method--Explaining Puzzle Game Level Design

MySQL忘记密码怎么办

The input input box displays the precision of two decimal places

STM32——DMA

Heavyweight | The Open Atomic School Source Line activity was officially launched

【R语言】【3】apply,tapply,lapply,sapply,mapply与par函数相关参数

CentOS7 install MySQL graphic detailed tutorial

DVWA shooting range environment construction

VScode+ESP32 quickly install ESP-IDF plugin

The idea project obviously has dependencies, but the file is not displayed, Cannot resolve symbol 'XXX'
随机推荐
专访 | 阿里巴巴首席技术官程立:云+开源共同形成数字世界的可信基础
ERP生产作业控制 金蝶
【云原生】DevOps(五):集成Harbor
[Linear Neural Network] softmax regression
Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
高斯分布及其极大似然估计
Interview | Cheng Li, CTO of Alibaba: Cloud + open source together form a credible foundation for the digital world
12 reasons for MySQL slow query
centos7安装mysql5.7
SQL语句中对时间字段进行区间查询
[Detailed explanation of ORACLE Explain]
WPF WPF 】 【 the depth resolution of the template
ERP Production Operation Control Kingdee
MySQL优化之慢日志查询
Doris学习笔记之监控
Hand in hand to realize the picture preview plug-in (3)
重磅 | 基金会为白金、黄金、白银捐赠人授牌
Minesweeper game - C language
C Implementation of Simple Network File Copy
XSS靶场(三)prompt to win