Version: 2021.2
言語: 日本語

OnDemandResourcesRequest

class in UnityEngine.iOS

/

継承:AsyncOperation

マニュアルに切り替える

説明

On Demand Resources (ODR) のリクエストオブジェクト。AsyncOperation なのでコルーチンで使用することができます。

注意: 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 .

using UnityEngine;
using UnityEngine.iOS;
using System;
using System.Collections;

public 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); Debug.Log(path);

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

変数

error操作が完了した後のエラー
loadingPriorityリクエストの優先度

Public 関数

DisposeDemand Resources (ODR) リクエストで保持していたすべてのリソースを解放します
GetResourcePathOn Demand Resources (ODR) リクエストで利用可能なリソースへのファイルシステムのパスを取得します

継承メンバー

変数

allowSceneActivationAllow Scenes to be activated as soon as it is ready.
isDone動作が終了したか確認します(読み取り専用)
priority非同期で読み込む際の優先順位を設定します。
progress進捗状況を表示します(読み取り専用)

Events

completedEvent that is invoked upon operation completion. An event handler that is registered in the same frame as the call that creates it will be invoked next frame, even if the operation is able to complete synchronously. If a handler is registered after the operation has completed and has already invoked the complete event, the handler will be called synchronously.