{!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} Method AddResourceLocator | Addressables | 1.21.17
docs.unity3d.com
"{0}"의 검색 결과

    목차 표시/숨기기

    Method AddResourceLocator

    AddResourceLocator(IResourceLocator, string, IResourceLocation)

    Adds a ResourceLocator to the Addressables runtime.

    선언
    public static void AddResourceLocator(IResourceLocator locator, string localCatalogHash = null, IResourceLocation remoteCatalogLocation = null)
    파라미터
    타입 이름 설명
    IResourceLocator locator

    The locator object.

    string localCatalogHash

    The hash of the local catalog. This can be null if the catalog cannot be updated.

    IResourceLocation remoteCatalogLocation

    The location of the remote catalog. This can be null if the catalog cannot be updated.

    참고

    Adds a ResourceLocator to the Addressables runtime.

    After adding the resource locator to Addressables it can then be used to locate Locations via Addressables loading APIs.

    Adding new resource locators can be used to add locations and manage asset files outside of the Addressables build system.

    In the following example we have a folder in the root folder called "dataFiles" containing some json files.

    These json files are then loaded using TextDataProvider, which is a ResourceProvider used to load text files.

    예

    This example code creates ResourceLocationBase and adds it to the locator for each file.

    private string m_SourceFolder = "dataFiles";
    
    public void AddFileLocatorToAddressables()
    {
    	if (!Directory.Exists(m_SourceFolder))
    		return;
    
    	ResourceLocationMap locator = new ResourceLocationMap(m_SourceFolder + "_FilesLocator", 12);
    	string providerId = typeof(TextDataProvider).ToString();
    
    	string[] files = Directory.GetFiles(m_SourceFolder);
    	foreach (string filePath in files)
    	{
    		if (!filePath.EndsWith(".json"))
    			continue;
    		string keyForLoading = Path.GetFileNameWithoutExtension(filePath);
    		locator.Add(keyForLoading, new ResourceLocationBase(keyForLoading, filePath, providerId, typeof(string)));
    	}
    	Addressables.AddResourceLocator(locator);
    }

    Using Addressables API to load "dataFiles/settings.json" after adding the locator:

    private string m_DataFileName = "settings";
    
    public IEnumerator LoadDataUsingAddedLocator()
    {
    	var loadingHandle = Addressables.LoadAssetAsync<string>(m_DataFileName);
    	yield return loadingHandle;
    	Debug.Log("Load completed " + loadingHandle.Status + (loadingHandle.Status == AsyncOperationStatus.Succeeded ? ", with result " + loadingHandle.Result : ""));
    }
    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)