apple ii 平台游戏

编程入门 行业动态 更新时间:2024-10-28 04:30:11

apple ii <a href=https://www.elefans.com/category/jswz/34/1769748.html style=平台游戏"/>

apple ii 平台游戏

apple ii 平台游戏

On-demand resources is a new iOS feature available since iOS and tvOS version 9.0. Its purpose is to reduce the size of the main application bundle, so that developers can separate certain resources from the main application bundle, host them on App Store infrastructure and download them on-demand.

按需资源是自iOS和tvOS 9.0版以来可用的新iOS功能。 其目的是减小主应用程序包的大小,以便开发人员可以从主应用程序包中分离某些资源,将其托管在App Store基础结构上并按需下载。

This is very important on the new AppleTV platform where the main application bundle is limited to 200MB. Therefore, most developers will need to use dynamically loaded resources one way or another. To make developer lives easier, Unity provides an on-demand resources API wrapper which has been shipped in Unity 5.2.0 patch 1.

这在新的AppleTV平台上非常重要,新的AppleTV平台的主要应用程序捆绑包限制为200MB。 因此,大多数开发人员将需要以一种或另一种方式使用动态加载的资源。 为了使开发人员的生活更轻松,Unity提供了按需资源API包装器,该包装器已在Unity 5.2.0补丁1中提供。

You can use on-demand resources to both reduce initial application download sizes and reduce the device storage usage by removing no longer needed assets. Generally, any resource that is not strictly needed to launch an app is a candidate for being loaded or unloaded on-demand. For example, consider a level-based game: the application does not need level 10 when the user is still playing level 3. On the other hand, the first levels may be safely unloaded when the user plays level 16.

您可以使用 按需资源 来减少初始应用程序的下载大小并通过删除不再需要的资产来减少设备存储使用量。 通常,不需要严格启动应用程序的任何资源都是按需加载或卸载的候选对象。 例如,考虑一个基于关卡的游戏:当用户仍在玩关卡3时,应用程序不需要关卡10。另一方面,当用户玩关卡16时,可以安全地卸载第一个关卡。

The most convenient way of taking advantage of on-demand resources is via asset bundles. Asset bundles solve many remaining problems in dynamic asset loading, such as memory and CPU efficiency, dependency tracking and optimization for target platform. Once asset bundles are configured, you need very few additional changes to use on-demand resources, as shown in the code examples below. In this blog post we won’t cover asset bundles. If this is the first time you hear about them, this resource will help you.

利用按需资源的最便捷方法是通过资产捆绑包。 资产捆绑包解决了动态资产加载中的许多剩余问题,例如内存和CPU效率,依赖项跟踪以及目标平台的优化。 配置资产捆绑包后,只需很少的其他更改即可使用按需资源,如下面的代码示例所示。 在此博客文章中,我们将不介绍资产捆绑包。 如果这是您第一次听说它们,那么本 资源 将为您提供帮助。

In order to use on-demand resources, the developer needs to perform two actions: assign some identifier, called tag, to each resource during build process and request the resources using the assigned tag during app runtime when needed. In vanilla iOS app development, the first step is done by assigning tags to resources in Xcode, whereas resources are requested using NSBundleResourceRequest API. In Unity, both tag assignment and resource retrieval are performed via code: the former via UnityEditor.iOS.BuildPipeline.collectResources event API, and the latter via UnityEngine.iOS.OnDemandResources.PreloadAsync API.

为了使用按需资源,开发人员需要执行两个操作: 在构建过程中为每个资源 分配一些名为 tag的 标识符, 并在需要时在应用运行时使用分配的标签来请求资源。 在原始的iOS应用程序开发中,第一步是通过向Xcode中的资源分配标签来完成,而资源是使用NSBundleResourceRequest API请求的。 在Unity中,标签分配和资源检索都是通过代码执行的:前者通过UnityEditor.iOS.BuildPipeline.collectResources事件API,后者通过UnityEngine.iOS.OnDemandResources.PreloadAsync API。

While the current on-demand resources API does not constrain tag names in any way, there are several guidelines that simplify development. It’s best to assign each asset bundle a unique tag which is derived from asset bundle name. This offers most flexibility and it’s also the simplest approach. In this case, the developer will be able to set priority of each individual download and also retrieve progress of each of them. Also, remember that Apple recommends that all the resources which are assigned the same tag have a cumulative size no larger than 64MB for a good balance between download speed and storage space availability.

尽管当前的按需资源API不会以任何方式限制标记名称,但是有一些准则可以简化开发。 最好为每个资产束分配一个唯一的标记,该标记是从资产束名称派生的。 这提供了最大的灵活性,也是最简单的方法。 在这种情况下,开发人员将能够设置每个单独下载的优先级,并且还可以检索每个下载的进度。 另外,请记住,Apple建议分配有相同标签的所有资源的累积大小不大于64MB,以便在下载速度和存储空间可用性之间取得良好的平衡。

The following two code examples demonstrate the essence of using on demand resources:

以下两个代码示例演示了按需使用资源的本质:

Editor script to assign identifiers to resources:

用于将标识符分配给资源的编辑器脚本:

1

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
using UnityEditor.iOS; #if ENABLE_IOS_ON_DEMAND_RESOURCES public class BuildResources { [InitializeOnLoadMethod] static void SetupResourcesBuild() { UnityEditor.iOS.BuildPipeline.collectResources += CollectResources; } static UnityEditor.iOS.Resource[] CollectResources() { return new Resource[] { new Resource("asset-bundle-name", "path/to/asset-bundle").AddOnDemandResourceTags("asset-bundle-name-tag"), }; } }

1

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
using UnityEditor . iOS ; #if ENABLE_IOS_ON_DEMAND_RESOURCES public class BuildResources { [ InitializeOnLoadMethod ] static void SetupResourcesBuild ( ) { UnityEditor . iOS . BuildPipeline . collectResources += CollectResources ; } static UnityEditor . iOS . Resource [ ] CollectResources ( ) { return new Resource [ ] { new Resource ( "asset-bundle-name" , "path/to/asset-bundle" ) . AddOnDemandResourceTags ( "asset-bundle-name-tag" ) , } ; } }

Resource retrieval during runtime:

运行时的资源检索:

1

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
using UnityEngine.iOS; // We can execute the following function as a coroutine, like this: // StartCoroutine(LoadAsset("asset-bundle-name", "asset-bundle-name-tag")); public static IEnumerator LoadAsset(string resourceName, string odrTag) { // Create the request var request = OnDemandResources.PreloadAsync(new string[] { odrTag } ); // Wait until request is completed yield return request; // Check for errors if (request.error != null) throw new Exception("ODR request failed: " + request.error); // Now we can use the resource, for example, by loading an asset bundle like this: // var bundle = AssetBundle.CreateFromFile("res://" + resourceName); // ... // We need to call Dispose() when resource is no longer needed. // request.Dispose(); }

1

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
using UnityEngine . iOS ; // We can execute the following function as a coroutine, like this: // StartCoroutine(LoadAsset("asset-bundle-name", "asset-bundle-name-tag")); public static IEnumerator LoadAsset ( string resourceName , string odrTag ) { // Create the request var request = OnDemandResources . PreloadAsync ( new string [ ] { odrTag } ) ; // Wait until request is completed yield return request ; // Check for errors if ( request . error != null ) throw new Exception ( "ODR request failed: " + request . error ) ; // Now we can use the resource, for example, by loading an asset bundle like this: // var bundle = AssetBundle.CreateFromFile("res://" + resourceName); // ... // We need to call Dispose() when resource is no longer needed. // request.Dispose(); }

The easiest way to start exploring asset bundles and on-demand resources is to use our Asset Bundle Manager demo project, which is available on BitBucket. The landing page offers a comprehensible description of how to use and tweak the demo.

开始探索资产捆绑和按需资源的最简单方法是使用我们的Asset Bundle Manager演示项目,该项目可在BitBucket上获得 。 登陆页面提供了有关如何使用和调整演示的全面描述。

Several Unity games utilizing on-demand resources have been already shipped on Apple TV. These include Breakneck and Bruce Lee: Enter the Game – Unchained Edition.

Apple TV已经提供了一些利用按需资源的Unity游戏。 其中包括Breakneck和Bruce Lee:《进入游戏-无锁版》 。

翻译自: /

apple ii 平台游戏

更多推荐

apple ii 平台游戏

本文发布于:2024-03-06 10:40:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1715112.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:平台   游戏   apple   ii

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!