{!See https://docs.google.com/document/d/1takg_GmIBBKKTj-GHZCwzxohpQz7Bhekivkk72kYMtE/edit for reference implementation of OneTrust, dataLayer and GTM} {!OneTrust Cookies Consent} {!OneTrust Cookies Consent end} {!dataLayer initialization push} {!dataLayer initialization push end} {!Google Tag Manager} {!Google Tag Manager end} 에셋 번들 로드 | Addressables | 1.21.17
docs.unity3d.com
"{0}"의 검색 결과

    목차 표시/숨기기

    에셋 번들 로드

    어드레서블 시스템은 에셋을 에셋 번들로 패킹하고 개별 에셋을 로드할 때 이러한 번들을 로드합니다. BundledAssetGroupSchema 클래스에 표시되는 에셋 번들의 로드 방법을 제어할 수 있습니다. 이러한 옵션은 스크립팅 API를 통해 설정하거나 AddressablesAssetGroup 인스펙터의 Advanced 옵션에서 설정할 수 있습니다.

    UnityWebRequestForLocalBundles

    어드레서블은 두 가지의 엔진 API인 UnityWebRequest.GetAssetBundle 및 AssetBundle.LoadFromFileAsync를 통해 에셋 번들을 로드할 수 있습니다. 기본 동작은 에셋 번들이 로컬 스토리지에 있는 경우 AssetBundle.LoadFromFileAsync를 사용하고, 에셋 번들 경로가 URL인 경우 UnityWebRequest를 사용하는 것입니다.

    이 동작을 오버라이드하여 로컬 에셋 번들에 대해 UnityWebRequest를 사용하려면 BundledAssetGroupSchema.UseUnityWebRequestForLocalBundles를 true로 설정하면 됩니다. BundledAssetGroupSchema GUI를 통해서도 설정할 수 있습니다.

    다음과 같은 몇 가지 상황이 있을 수 있습니다.

    • 제공되는 게임 패키지를 최대한 작게 만들고 싶어서 LZMA 압축을 사용하는 로컬 에셋 번들을 제공하는 경우. 이 경우 UnityWebRequest를 사용하여 해당 에셋 번들 LZ4를 로컬 디스크 캐시에 다시 압축할 수 있습니다.
    • Android 게임을 제공할 때 APK에 기본 APK 압축으로 압축된 에셋 번들이 포함되어 있는 경우
    • 디스크 검색을 피하기 위해 전체 로컬 에셋 번들을 메모리에 로드하려는 경우 UnityWebRequest를 사용하면서 캐싱을 비활성화하면 전체 에셋 번들 파일이 메모리 캐시에 로드됩니다. 이렇게 하면 런타임 메모리 사용량이 증가하지만, 최초 에셋 번들 로드 후 디스크를 찾을 필요가 없으므로 로딩 성능이 향상될 수 있습니다.

    위의 처음 두 상황에서는 플레이어 기기에 에셋 번들이 두 번(원본과 캐시된 버전) 존재하게 됩니다. 이는 최초 로드(압축 해제 및 캐시에 복사)가 후속 로드(캐시에서 로드)보다 느리다는 의미입니다.

    다운로드 오류 처리

    다운로드가 실패하면 RemoteProviderException에는 오류가 포함되며, 이를 고려하여 장애 처리 방법을 결정할 수 있습니다. RemoteProviderException은 AsyncOperationHandle.OperationException이거나 내부 예외입니다. 다음과 같습니다.

    
    using UnityEngine;
    using UnityEngine.AddressableAssets;
    using UnityEngine.ResourceManagement.AsyncOperations;
    using UnityEngine.ResourceManagement.Exceptions;
    
    internal class HandleDownloadError : MonoBehaviour
    {
        private AsyncOperationHandle m_Handle;
    
        void LoadAsset()
        {
            m_Handle = Addressables.LoadAssetAsync<GameObject>("addressKey");
            m_Handle.Completed += handle =>
            {
                string dlError = GetDownloadError(m_Handle);
                if (!string.IsNullOrEmpty(dlError))
                {
                    // handle what error
                }
            };
        }
    
        string GetDownloadError(AsyncOperationHandle fromHandle)
        {
            if (fromHandle.Status != AsyncOperationStatus.Failed)
                return null;
    
            RemoteProviderException remoteException;
            System.Exception e = fromHandle.OperationException;
            while (e != null)
            {
                remoteException = e as RemoteProviderException;
                if (remoteException != null)
                    return remoteException.WebRequestResult.Error;
                e = e.InnerException;
            }
    
            return null;
        }
    }
    
    

    발생할 수 있는 오류 문자열은 다음과 같습니다.

    • "Request aborted"
    • "Unable to write data"
    • "Malformed URL"
    • "Out of memory"
    • "No Internet Connection"
    • "Encountered invalid redirect (missing Location header?)"
    • "Cannot modify request at this time"
    • "Unsupported Protocol"
    • "Destination host has an erroneous SSL certificate"
    • "Unable to load SSL Cipher for verification"
    • "SSL CA certificate error"
    • "Unrecognized content-encoding"
    • "Request already transmitted"
    • "Invalid HTTP Method"
    • "Header name contains invalid characters"
    • "Header value contains invalid characters"
    • "Cannot override system-specified headers"
    • "Backend Initialization Error"
    • "Cannot resolve proxy"
    • "Cannot resolve destination host"
    • "Cannot connect to destination host"
    • "Access denied"
    • "Generic/unknown HTTP error"
    • "Unable to read data"
    • "Request timeout"
    • "Error during HTTP POST transmission"
    • "Unable to complete SSL connection"
    • "Redirect limit exceeded"
    • "Received no data in response"
    • "Destination host does not support SSL"
    • "Failed to transmit data"
    • "Failed to receive data"
    • "Login failed"
    • "SSL shutdown failed"
    • "Redirect limit is invalid"
    • "Not implemented"
    • "Data Processing Error, see Download Handler error"
    • "Unknown Error"
    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)