当前位置:网站首页>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.
边栏推荐
- SQL行列转换
- .NET-9. A mess of theoretical notes (concepts, ideas)
- mysql使用on duplicate key update批量更新数据
- 【R语言】【3】apply,tapply,lapply,sapply,mapply与par函数相关参数
- MySQL database installation (detailed)
- MySQL优化:从十几秒优化到三百毫秒
- Duplicate entry 'XXX' for key 'XXX.PRIMARY' solution.
- 扫雷小游戏——C语言
- ERROR 1819 (HY000) Your password does not satisfy the current policy requirements
- Error EPERM operation not permitted, mkdir 'Dsoftwarenodejsnode_cache_cacach Two solutions
猜你喜欢
30 Years of Open Source Community | 2022 Open Atom Global Open Source Summit 30 Years of Open Source Community Special Event Held Successfully
城市内涝及桥洞隧道积水在线监测系统
12 reasons for MySQL slow query
MySQL database installation (detailed)
Minesweeper game - C language
STM32 - DMA
Musk talks to the "virtual version" of Musk, how far is the brain-computer interaction technology from us
MySQL transaction isolation level, rounding
开放原子开源基金会秘书长孙文龙 | 凝心聚力,共拓开源
Unity Fighter
随机推荐
MySQL optimization: from ten seconds to three hundred milliseconds
[Detailed explanation of ORACLE Explain]
Gaussian distribution and its maximum likelihood estimation
PWN ROP
Musk talks to the "virtual version" of Musk, how far is the brain-computer interaction technology from us
[py script] batch binarization processing images
Unity Fighter
MySQL transaction isolation level, rounding
Visual studio shortcuts that improve efficiency, summary (updated from time to time)
From scratch, a mirror to the end, a pure system builds a grasscutter (Grasscutter)
Unity手机游戏性能优化系列:针对CPU端的性能调优
Vue项目通过node连接MySQL数据库并实现增删改查操作
Mysql应用安装后找不到my.ini文件
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
Lua,ILRuntime, HybridCLR(wolong)/huatuo热更新对比分析
centos7安装mysql5.7步骤(图解版)
.NET-6.WinForm2.NanUI学习和总结
WPF WPF 】 【 the depth resolution of the template
打造基于ILRuntime热更新的组件化开发
STM32HAL库修改Hal_Delay为us级延时