Legacy Documentation: Version 5.6 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

OnDemandResourcesRequest

class in UnityEngine.iOS

/

Inherits from:AsyncOperation

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Represents a request for On Demand Resources (ODR). It's an AsyncOperation and can be yielded in a coroutine.

NOTE: only available on iOS.

Creating an OnDemandResourcesRequest is equivalent to calling NSBundleResourceRequest.beginAccessingResourcesWithCompletionHandler. The request will keep the on demand resource alive until either Dispose() is called or the request object is collected by a garbage collector, which is the equivalent of calling NSBundleResourceRequest.endAccessingResources class.

no example available in JavaScript
static class Loader
{
    public static IEnumerator LoadAsset(string resourceName)
    {
        // Create the request
        var request = OnDemandResources.PreloadAsync(new string[] { "Asset's ODR tag" });

// Wait until request is completed yield return request;

// Check for errors if (request.error != null) throw new Exception("ODR request failed: " + request.error);

// Get path to the resource and use it var path = request.GetResourcePath(resourceName);

// Call Dispose() when resource is no longer needed. request.Dispose(); } }

Variables

errorReturns an error after operation is complete.
loadingPrioritySets the priority for request.

Public Functions

DisposeRelease all resources kept alive by On Demand Resources (ODR) request.
GetResourcePathGets file system's path to the resource available in On Demand Resources (ODR) request.

Inherited members

Variables

allowSceneActivationAllow scenes to be activated as soon as it is ready.
isDoneHas the operation finished? (Read Only)
priorityPriority lets you tweak in which order async operation calls will be performed.
progressWhat's the operation's progress. (Read Only)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961