The on-demand download feature introduced by Apple in iOS 9 and tvOS has officially become available to developers working on projects in Unity.

В Unity появилась поддержка загрузки контента по запросу

According to the official Unity blog, to simplify the life of developers, the first patch for Unity 5.2.0 was recently released, which included an API wrapper for creating resources “on demand”.

Recall that the function of uploading content “on demand” is a new feature of iOS 9 and tvOS. Its task is to reduce the size of the distribution on the device by transferring part of its content to the cloud. It is assumed that as soon as the user has a need for this new content, it is loaded instead of the one that is no longer used.

As an example, the Unity blog provides the following situation: there is a game with several levels. When a player is at the third level, he does not need the tenth level. The player also has no urgent need for the first levels when passing level 16.

In fact, the story is controversial. And, first of all, due to Apple’s desire to reduce costs for the production of new Apple TV.

Be that as it may, developers today are forced to take into account the changed reality and adapt their solutions to the leading markets.

To use resources “on demand”, the developer must perform two actions,” they write in the Unity blog. First, bind the identifier (tag) to each resource during the build. Secondly, request a resource using the assigned tag during the run at the right moment.

Without a wrapper, the first step is done in Xcode, and requests are made via the NSBundleResourceRequest API. In Unity, this procedure is now carried out through the code (the first step is UnityEditor.iOS.BuildPipeline.collectResources event API, the second step is UnityEngine.iOS.OnDemandResources.PreloadAsync API).

Apple recommends that the downloaded packages weigh no more than 64 MB.

A source: http://blogs.unity3d.com

Tags: