当前位置:网站首页>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.
边栏推荐
- Minesweeper game - C language
- Open Source Database Innovation in the Digital Economy Era | 2022 Open Atom Global Open Source Summit Database Sub-Forum Successfully Held
- PCL calculates the point cloud coordinate maximum and its index
- 简易网络文件拷贝的C实现
- .NET-9. A mess of theoretical notes (concepts, ideas)
- Minesweeper game (written in c language)
- 数字经济时代的开源数据库创新 | 2022开放原子全球开源峰会数据库分论坛圆满召开
- 行业落地呈现新进展 | 2022开放原子全球开源峰会OpenAtom OpenHarmony分论坛圆满召开
- 【wpf】wpf中的那些模板之深度解析
- [Detailed explanation of ORACLE Explain]
猜你喜欢
centos7安装mysql5.7
Three oj questions on leetcode
centos7安装mysql5.7步骤(图解版)
重磅 | 基金会为白金、黄金、白银捐赠人授牌
Two address pools r2 are responsible for managing the address pool r1 is responsible for managing dhcp relays
npm、nrm两种方式查看源和切换镜像
重磅 | 开放原子校源行活动正式启动
[Linear Neural Network] softmax regression
开源汇智创未来 | 2022开放原子全球开源峰会OpenAtom openEuler分论坛圆满召开
PWN ROP
随机推荐
DVWA之SQL注入
12个MySQL慢查询的原因分析
[debug highlights] Expected input batch_size (1) to match target batch_size (0)
MySQL transaction (transaction) (this is enough..)
Lua,ILRuntime, HybridCLR(wolong)/huatuo热更新对比分析
Unity URP渲染管线摄像机核心机制剖析
DVWA安装教程(懂你的不懂·详细)
【R语言】【3】apply,tapply,lapply,sapply,mapply与par函数相关参数
STM32 - DMA
STM32——DMA
30 Years of Open Source Community | 2022 Open Atom Global Open Source Summit 30 Years of Open Source Community Special Event Held Successfully
ERROR 2003 (HY000) Can't connect to MySQL server on 'localhost3306' (10061)
DVWA shooting range environment construction
Hand in hand to realize the picture preview plug-in (3)
.NET-9.乱七八糟的理论笔记(概念,思想)
Gaussian distribution and its maximum likelihood estimation
Unity shader forge和自带的shader graph,有哪些优缺点?
参考代码系列_1.各种语言的Hello World
CentOS7 —— yum安装mysql
开放原子开源基金会秘书长孙文龙 | 凝心聚力,共拓开源