最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

Unity_Addressable_概述

2023-03-28 17:28 作者:unity_某某師_高錦錦  | 我要投稿

Addressables provides a system that can grow with your project. You can start with a simple setup and then reorganize as your project grows in complexity and your team grows in size, and you can do this all with minimal code changes.

譯:Addressables提供了一個可以隨項目一起成長的系統(tǒng)。您可以從一個簡單的設(shè)置開始,然后隨著項目的復(fù)雜性和團隊規(guī)模的增長而重新組織,并且您可以通過最小的代碼更改來完成這一切。

For example, you could start with a single group of Addressable assets, which Unity loads as a set. Then, as you add more content, you could split your assets into multiple groups so that you can load only the ones you need at a given time. As your team grows in size, you could make separate Unity Projects for developing different types of assets. These auxiliary Projects can produce their own Addressables content builds that you load from the main Project (again with minimal code changes).

譯:例如,你可以從一組可尋址資產(chǎn)開始,Unity將其作為一個集合加載。然后,當(dāng)您添加更多內(nèi)容時,您可以將資產(chǎn)分成多個組,以便在給定時間只加載您需要的內(nèi)容。隨著團隊規(guī)模的擴大,你可以創(chuàng)建獨立的Unity項目來開發(fā)不同類型的資產(chǎn)。這些輔助項目可以生成自己的Addressables內(nèi)容構(gòu)建,您可以從主項目加載這些內(nèi)容(同樣需要進行最小的代碼更改)。

This overview discusses the following concepts to help you understand how to manage and use your assets with the Addressables system:

譯:本概述討論以下概念,以幫助您了解如何管理和使用Addressables系統(tǒng)的資產(chǎn):

  • Asset address: a string ID that identifies an Addressable asset. You can use an address as a key to load the asset.譯:Asset address標(biāo)識可尋址資產(chǎn)的字符串ID。您可以使用地址作為鍵來加載資產(chǎn)

  • AssetReferences: a type you can use to support the assignment of Addressable assets to fields in an Inspector window. You can use an AssetReference instance as a key to load the asset. The?AssetReference?class also provides its own loading methods.譯:AssetReferences:一種可以用來支持將可尋址資產(chǎn)分配到檢查器窗口中的字段的類型。您可以使用一個AssetReference實例作為加載資產(chǎn)的鍵。AssetReference類還提供了自己的加載方法。

  • Label: a tag that you can assign to multiple assets and use to load related assets together as a group. You can use a label as a key to load the asset.譯:Label:一個可以分配給多個資產(chǎn)并用于將相關(guān)資產(chǎn)作為一個組加載在一起的標(biāo)記。您可以使用標(biāo)簽作為鍵來加載資產(chǎn)

  • Asset location: a runtime object that describes how to load an asset and its dependencies. You can use a location object as a key to load the asset.譯:Asset location:描述如何加載資產(chǎn)及其依賴項的運行時對象。您可以使用本地對象作為加載資產(chǎn)的鍵

  • Key: an object that identifies one ore more Addressables. Keys include addresses, labels, AssetReference instances and location objects.譯:Key:標(biāo)識一個或多個Addressables的對象。鍵包括地址、標(biāo)簽、AssetReference實例和本地對象

  • Asset loading and unloading: the Addressables API provides its own functions to load and release Assets at runtime.譯:Asset loading and unloading:Addressables API提供了它自己的函數(shù)來在運行時加載和釋放資產(chǎn)

  • Dependencies: An asset dependency is one asset used by another, such as a Prefab used in a Scene asset or a Material used in a Prefab asset.譯:Dependencies:資產(chǎn)依賴是一個資產(chǎn)被另一個資產(chǎn)使用,例如場景資產(chǎn)中使用的Prefab或Prefab資產(chǎn)中使用的Material

  • Dependency and resource management: the Addressables system uses reference counting to track which assets and AssetBundles are in use, including whether the system should load or unload dependencies (other referenced Assets).譯:Dependency and resource management:Addressables系統(tǒng)使用引用計數(shù)來跟蹤哪些資產(chǎn)和AssetBundles正在使用,包括系統(tǒng)是否應(yīng)該加載或卸載依賴項(其他引用的資產(chǎn))。

  • Group: you assign assets to groups in the Editor. The group settings determine how Addressables packages the group assets into AssetBundles and how it loads them at runtime.譯:Group:在編輯器中將資產(chǎn)分配給組。組設(shè)置決定Addressables如何將組資產(chǎn)打包到AssetBundles中,以及如何在運行時加載它們。

  • Content catalogs: Addressables uses catalogs to map your assets to the resources that contain them.譯:Content catalogs:Addressables使用目錄將您的資產(chǎn)映射到包含它們的資源。

  • Content builds: when using Addressables, you make a content build to collate and package your assets as a separate step before you make a player build.譯:Content builds:當(dāng)使用Addressables時,在制作內(nèi)容構(gòu)建之前,你需要制作一個內(nèi)容構(gòu)建來整理和打包你的資產(chǎn)

  • Multiple platform support: the build system separates content built by platform and resolves the correct path at runtime.譯:Multiple platform support:多平臺支持,構(gòu)建系統(tǒng)將根據(jù)平臺構(gòu)建的內(nèi)容分離,并在運行時解析正確的路徑。

  • Addressables tools: the Addressables package contains several windows and tools to organize, build, and optimize your content.譯:Addressables tools:Addressables包包含幾個窗口和工具來組織、構(gòu)建和優(yōu)化您的內(nèi)容

By default, Addressables uses AssetBundles to package your assets. You can also implement your own?IResourceProvider?class to support other ways to access assets.

譯:默認(rèn)情況下,Addressables使用AssetBundles來打包您的資產(chǎn)。您還可以實現(xiàn)自己的IResourceProvider類,以支持以其他方式訪問資產(chǎn)。

Asset addresses

A key feature of the Addressables system is that you assign addresses to your assets and use those addresses to load them at runtime. The Addressables resource manager looks up the address in the content catalog to find out where the asset is stored. (Assets can be built-in to your application, cached locally, or hosted remotely.) The resource manager loads the asset and any dependencies, downloading the content first, if necessary.

譯:Addressables系統(tǒng)的一個關(guān)鍵特性是為資產(chǎn)分配地址,并在運行時使用這些地址來加載它們。Addressables資源管理器在內(nèi)容目錄中查找地址,以找出資產(chǎn)存儲在何處。(資產(chǎn)可以內(nèi)置到應(yīng)用程序中,也可以在本地緩存,或者遠(yuǎn)程托管。)資源管理器加載資產(chǎn)和任何依賴項,如果需要,首先下載內(nèi)容。


Addressables loads Assets by address no matter where they're located

譯:Addressables通過地址加載資產(chǎn),無論它們位于何處

Because an address isn't tied to the physical location of the Asset, you have much more flexibility when managing and optimizing your Assets, both in the Unity Editor and at runtime.?Catalogs?map Addresses to physical locations.

譯:因為地址并不綁定到資產(chǎn)的物理位置,所以你在管理和優(yōu)化資產(chǎn)時擁有更大的靈活性,無論是在Unity Editor中還是在運行時。目錄將地址映射到物理位置。

Although, you should typically assign unique addresses to your assets, an asset address is not required to be unique. You can assign the same address string to more than one asset when useful. For example, if you have variants of an asset, you could assign the same address to all the variants and use labels to distinguish between the variants:

譯:盡管您通常應(yīng)該為您的資產(chǎn)分配唯一的地址,但資產(chǎn)地址不需要是唯一的。如果有用,可以將相同的地址字符串分配給多個資產(chǎn)。例如,如果你有一個資產(chǎn)的變體,你可以給所有的變體分配相同的地址,并使用標(biāo)簽來區(qū)分這些變體:

  • Asset 1: address: "plate_armor_rusty", label: "hd"

  • Asset 2: address: "plate_armor_rusty", label: "sd"

Addressables API functions that only load a single asset, such as?LoadAssetAsync, load the first instance found if you call them with an address assigned to multiple assets. Other functions, like?LoadAssetsAsync, load multiple assets in one operation and load all the assets with the specified address.

譯:只加載單個資產(chǎn)的可尋址API函數(shù),如LoadAssetAsync,如果您使用分配給多個資產(chǎn)的地址調(diào)用它們,則加載找到的第一個實例。其他函數(shù),如LoadAssetsAsync,在一個操作中加載多個資產(chǎn),并使用指定的地址加載所有資產(chǎn)。

TIP

You can use the?MergeMode?parameter of?LoadAssetsAsync?to load the intersection of two keys.

譯:您可以使用LoadAssetsAsync的MergeMode參數(shù)來加載兩個鍵的交集。

In the example above, you could specify the address, "plate_armor_rusty", and the label, "hd", as keys and intersection as the merge mode to load "Asset 1". You could change the label value to "sd" to load "Asset 2".

譯:在上面的例子中,你可以指定地址“plate_armor_rusty”和標(biāo)簽“hd”作為鍵,交集作為合并模式來加載“Asset 1”。您可以將標(biāo)簽值更改為“sd”以加載“Asset 2”。

See?Making an asset Addressable?for how to assign addresses to assets.

譯:有關(guān)如何為資產(chǎn)分配地址,請參見使資產(chǎn)可尋址。

See?Loading assets?for how to load assets by keys, including addresses.

譯:有關(guān)如何按鍵(包括地址)加載資產(chǎn),請參見加載資產(chǎn)。

AssetReference

An AssetReference is a type that you can set to any kind of Addressable asset. Unity does not automatically load the asset assigned to the reference, so you have more control over when to load and unload it.

譯:AssetReference是一種可以設(shè)置為任何類型的可尋址資產(chǎn)的類型。Unity不會自動加載分配給引用的資產(chǎn),所以你可以更好地控制何時加載和卸載它。

Use fields of type AssetReference in your MonoBehaviours and ScriptableObjects to help you specify which Addressable asset to use for that field (instead of using the string that specifies the address). AssetReferences support drag-and-drop and object picker assignment, which can make them more convenient to use in an Editor Inspector.

譯:在monobehaviour和ScriptableObjects中使用AssetReference類型的字段來幫助您指定該字段使用哪個Addressable資產(chǎn)(而不是使用指定地址的字符串)。AssetReferences支持拖放和對象選擇器賦值,這可以使它們在編輯器檢查器中使用更方便。

In addition to the base AssetReference type, Addressables provides a few more specialized types, such as AssetReferenceGameObject and AssetReferenceTexture. You can use these specialized subclasses to eliminate the possiblity of assigning the wrong type of asset to an AssetReference field. In addition, you can use the AssetReferenceUILabelRestriction attribute to limit assignment to Assets with specific labels.

譯:除了基本的AssetReference類型之外,Addressables還提供了一些更專門化的類型,比如AssetReferenceGameObject和AssetReferenceTexture。您可以使用這些專門化的子類來消除將錯誤類型的資產(chǎn)分配給AssetReference字段的可能性。此外,您可以使用AssetReferenceUILabelRestriction屬性來限制具有特定標(biāo)簽的資產(chǎn)的分配。

See?Using AssetReferences?for more information.

譯:有關(guān)更多信息,請參見使用資產(chǎn)引用。

Loading and releasing assets

To load an Addressable asset, you can use its address or other key such as a label or AssetReference. See?Loading Addressable Assets?for more information. You only need to load the main asset; Addressables loads any dependent assets automatically.

譯:要加載可尋址資產(chǎn),您可以使用它的地址或其他鍵,如標(biāo)簽或資產(chǎn)引用。有關(guān)更多信息,請參見加載可尋址資產(chǎn)。你只需要加載主資產(chǎn);Addressables自動加載任何依賴的資產(chǎn)。

When your application no longer needs access to an Addressable asset at runtime, you must release it so that Addressables can free the associated memory. The Addressables system keeps a reference count of loaded assets. It doesn't unload an asset until the reference count returns to zero. Thus, you don't need to keep track of whether an asset or its dependencies are still in use; you only need to make sure that anytime you explicitly load an asset, you release it when your application no longer needs that instance. See?Releasing Addressable assets?for more information.

譯:當(dāng)應(yīng)用程序在運行時不再需要訪問Addressable資產(chǎn)時,必須釋放它,以便Addressables可以釋放相關(guān)的內(nèi)存。Addressables系統(tǒng)保持已加載資產(chǎn)的引用計數(shù)。直到引用計數(shù)返回零,它才卸載資產(chǎn)。因此,您不需要跟蹤資產(chǎn)或其依賴項是否仍在使用;您只需要確保在任何時候顯式加載資產(chǎn)時,當(dāng)應(yīng)用程序不再需要該實例時釋放它。有關(guān)更多信息,請參見釋放可尋址資產(chǎn)。

Dependency and resource management

One asset in Unity can depend on another. A Scene might reference one or more Prefabs; a Prefab might use one or more Materials. The same Material can be used by more than one Prefab and those Prefabs can exist in different AssetBundles. When you load an Addressable asset, the system automatically finds and loads any dependent assets that it references. When the system unloads an asset, it also unloads its dependencies -- unless they're still being used by a different asset.

譯:Unity中的一個資產(chǎn)可以依賴于另一個資產(chǎn)。一個場景可以引用一個或多個預(yù)制件;預(yù)制構(gòu)件可以使用一種或多種材料。相同的材質(zhì)可以被多個預(yù)制件使用,并且這些預(yù)制件可以存在于不同的資產(chǎn)包中。當(dāng)你加載一個Addressable資產(chǎn)時,系統(tǒng)會自動找到并加載它引用的任何依賴資產(chǎn)。當(dāng)系統(tǒng)卸載一個資產(chǎn)時,它也卸載了它的依賴項——除非它們?nèi)匀槐徊煌馁Y產(chǎn)使用。

As you load and release assets, the Addressables system keeps a reference count for each item. When an asset is no longer referenced, Addressables unloads it. If the asset was in a bundle that no longer contains any assets that are in use, Addressables also unloads the bundle.

譯:當(dāng)你加載和釋放資產(chǎn)時,Addressables系統(tǒng)會為每個項目保留一個引用計數(shù)。當(dāng)一個資產(chǎn)不再被引用時,Addressables會卸載它。如果資產(chǎn)在一個不再包含任何正在使用的資產(chǎn)的包中,Addressables也會卸載這個包。

See?Memory management?for more information.

譯:有關(guān)更多信息,請參閱內(nèi)存管理。

Addressables groups and labels

Use Addressables groups to organize your content. All Addressable Assets belong to a group. If you don't explicitly assign an asset to a group, Addressables adds it to the default group.

譯:使用Addressables組來組織您的內(nèi)容。所有可尋址資產(chǎn)屬于一個組。如果沒有顯式地將資產(chǎn)分配給組,Addressables會將其添加到默認(rèn)組。

You can set the group settings to specify how the Addressables build system should package the assets in a group into bundles. For example, you can choose whether or not all the assets in a group should be packed together in a single AssetBundle file.

譯:您可以設(shè)置組設(shè)置,以指定Addressables構(gòu)建系統(tǒng)應(yīng)該如何將組中的資產(chǎn)打包到包中。例如,您可以選擇是否將組中的所有資產(chǎn)打包到單個AssetBundle文件中。

Use labels to tag content that you want to treat together in some way. For example, if you had labels defined for "red", "hat", and "feather", you could load all red hats with feathers in a single operation, whether or not they are part of the same AssetBundle. In addition, you can use labels to determine how assets in a group are packed into bundles.

譯:使用標(biāo)簽來標(biāo)記您希望以某種方式一起處理的內(nèi)容。例如,如果您定義了“red”、“hat”和“feather”標(biāo)簽,那么您可以在一個操作中加載所有帶有羽毛的紅帽子,無論它們是否是同一個AssetBundle的一部分。此外,您可以使用標(biāo)簽來確定如何將組中的資產(chǎn)打包到包中。

Add an asset to a group and move assets between groups using the?Addressables Groups?window. You can also assign labels to your assets in the Groups window.

譯:向組中添加資產(chǎn),并使用“可尋址組”窗口在組之間移動資產(chǎn)。您還可以在“組”窗口中為資產(chǎn)分配標(biāo)簽。

Group schemas

The schemas assigned to a group define the settings used to build the assets in a group. Different schemas can define different groups of settings. For example, one standard schema defines the settings for how to pack and compress your assets into AssetBundles (among other options). Another standard schema defines which of the categories, "Can Change Post Release" and "Cannot Change Post Release" the assets in the group belong to.

譯:分配給組的模式定義用于在組中構(gòu)建資產(chǎn)的設(shè)置。不同的模式可以定義不同的設(shè)置組。例如,一個標(biāo)準(zhǔn)模式定義了如何將資產(chǎn)打包并壓縮到AssetBundles(以及其他選項)的設(shè)置。另一個標(biāo)準(zhǔn)模式定義了組中的資產(chǎn)屬于哪些類別,“可以更改發(fā)布”和“不能更改發(fā)布”。

You can define your own schemas to use with custom build scripts.

譯:您可以定義自己的模式,以便與自定義構(gòu)建腳本一起使用。

See?Schemas?for more information about group schemas.

譯:有關(guān)組模式的更多信息,請參見模式。

Content catalogs

The Addressables system produces a content catalog file that maps the addresses of your assets to their physical locations. It can also create a hash file containing the hash (a mathematical fingerprint) of the catalog. If you are hosting your Addressable assets remotely, the system uses this hash file to determine if the content catalog has changed and needs to be downloaded. See?Content catalogs?for more information.

譯:Addressables系統(tǒng)生成一個內(nèi)容目錄文件,該文件將資產(chǎn)的地址映射到其物理位置。它還可以創(chuàng)建一個包含目錄的哈希(數(shù)學(xué)指紋)的哈希文件。如果您遠(yuǎn)程托管可尋址資產(chǎn),系統(tǒng)將使用此哈希文件來確定內(nèi)容目錄是否已更改并需要下載。有關(guān)更多信息,請參閱內(nèi)容目錄。

The Profile selected when you perform a content build determines how the addresses in the content catalog map to resource loading paths. See?Profiles?for more information.

譯:執(zhí)行內(nèi)容構(gòu)建時選擇的概要文件決定內(nèi)容目錄中的地址如何映射到資源加載路徑。有關(guān)更多信息,請參閱概要文件。

See?Distributing content remotely?for information about hosting content remotely.

譯:有關(guān)遠(yuǎn)程托管內(nèi)容的信息,請參閱遠(yuǎn)程分發(fā)內(nèi)容。

Content builds

The Addressables system separates the building of Addressable content from the build of your player. A content build produces the content catalog, catalog hash, and the AssetBundles containing your assets.

譯:可尋址系統(tǒng)將可尋址內(nèi)容的構(gòu)建與玩家的構(gòu)建分離開來。內(nèi)容構(gòu)建生成內(nèi)容目錄、目錄散列和包含您的資產(chǎn)的AssetBundles。

Because asset formats are platform-specific, you must make a content build for each platform before building a player.

譯:因為資產(chǎn)格式是特定于平臺的,所以在構(gòu)建播放器之前,你必須為每個平臺制作內(nèi)容。

See?Building Addressable content?for more information.

譯:有關(guān)更多信息,請參見構(gòu)建可尋址內(nèi)容。

Play mode scripts

When you run your game or application in the Editor Play mode, it can be inconvenient and slow to always perform a content build before pressing the Play button. At the same time, you do want to be able to run your game in a state as close to a built player as possible. For flexibility, Addressables provides three options that determine how the Addressables system locates and loads assets in Play mode:

譯:當(dāng)你在編輯器播放模式下運行游戲或應(yīng)用時,總是在按下播放按鈕之前執(zhí)行內(nèi)容構(gòu)建可能會很不方便且緩慢。與此同時,你也希望游戲能夠以一種盡可能接近玩家的狀態(tài)運行。為了靈活性,Addressables提供了三個選項來確定Addressables系統(tǒng)在播放模式下如何定位和加載資產(chǎn):

  • Use the Asset database: Addressables loads Assets directly from the Asset database. This option typically provides the fastest iteration speed if you are making both code and Asset changes, but also least resembles a production build.譯:Use the Asset databaseAddressables直接從資產(chǎn)數(shù)據(jù)庫加載資產(chǎn)。如果您同時更改代碼和資產(chǎn),這個選項通常提供最快的迭代速度,但也最不像產(chǎn)品構(gòu)建。

  • Simulate groups: Addressables loads Assets while simulating groups. This option is helpful if you are working on organizing and optimizing your Addressables groups themselves. It provides Addressables events without requiring a full content rebuild after every change.譯:Simulate groups:Addressables在模擬組時加載資產(chǎn)。如果您正在組織和優(yōu)化Addressables組本身,此選項是有用的。它提供Addressables事件,而不需要在每次更改后重新構(gòu)建完整的內(nèi)容。

  • Use existing build: Addressables loads content from your last content build. This option most resembles a production build and can provide fast iteration turnaround if you aren't changing Assets.譯:Use existing build:Addressables從您的上一個內(nèi)容構(gòu)建加載內(nèi)容。此選項最類似于產(chǎn)品構(gòu)建,如果您不更改資產(chǎn),則可以提供快速迭代周轉(zhuǎn)

See?Play mode Scripts?for more information.

譯:有關(guān)更多信息,請參閱播放模式腳本。

Support for multiple platforms

Addressables supports projects designed for multiple platforms by including the target platform name in the build path and by making sure that it copies the correct platform files to the StreamingAssets folder when you make a player build.

譯:Addressables支持針對多個平臺設(shè)計的項目,方法是在構(gòu)建路徑中包含目標(biāo)平臺名稱,并確保在構(gòu)建時將正確的平臺文件復(fù)制到StreamingAssets文件夾中。

Addressables tools

The Addressables system provides a few tools and windows to help you manage your Addressable assets:

譯:Addressables系統(tǒng)提供了一些工具和窗口來幫助您管理您的Addressable資產(chǎn):

  • Addressable Groups window: The Groups window is the main interface for managing assets, group settings, and making builds..譯:Groups窗口是管理資產(chǎn)、組設(shè)置和構(gòu)建的主要界面

  • Profiles window: helps set up paths used by your builds.譯:幫助設(shè)置構(gòu)建使用的路徑

  • Addressables Event Viewer: monitor and profile runtime events related to your Addressable assets.譯:監(jiān)視和配置與可尋址資產(chǎn)相關(guān)的運行時事件

  • Analyze tool: the Analyze tool runs analysis rules that check whether your Addressables content conforms to the set of rules you have defined. The Addressables system provides some basic rules, such as checking for duplicate assets; you can add your own rules using the?AnalyzeRule?class.譯:Analyze工具運行分析規(guī)則,檢查Addressables內(nèi)容是否符合您定義的規(guī)則集。Addressables系統(tǒng)提供了一些基本規(guī)則,如檢查重復(fù)資產(chǎn);您可以使用AnalyzeRule類添加自己的規(guī)則

  • Hosting tool: the Hosting tool provides a simple asset hosting service that runs from the Unity Editor to aide development and testing of your project.譯:虛擬主機工具提供了一個簡單的資產(chǎn)托管服務(wù),從Unity編輯器運行,以幫助開發(fā)和測試你的項目。

  • Build layout report: describes the AssetBundles produced by a content build.譯:描述由內(nèi)容構(gòu)建生成的資產(chǎn)包




Unity_Addressable_概述的評論 (共 條)

分享到微博請遵守國家法律
罗田县| 定安县| 陆河县| 镇江市| 怀集县| 大洼县| 苍山县| 什邡市| 佛山市| 青龙| 洪泽县| 和林格尔县| 永和县| 介休市| 乐业县| 谷城县| 岱山县| 简阳市| 长寿区| 庆云县| 桦南县| 闽侯县| 南投市| 互助| 常德市| 五大连池市| 漠河县| 七台河市| 林西县| 札达县| 惠安县| 子洲县| 鄂州市| 田东县| 五原县| 闽侯县| 济宁市| 海晏县| 无为县| 什邡市| 新田县|