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

    목차 표시/숨기기

    Property InstanceProvider

    InstanceProvider

    The Instance Provider used by the Addressables System.

    선언
    public static IInstanceProvider InstanceProvider { get; }
    프로퍼티 값
    타입 설명
    IInstanceProvider

    The IInstanceProvider object used to create instances of GameObjects.

    참고

    Retrieves the interface used by the Addressables Asset System to create instances of Addressable GameObjects.

    예

    The example below instantiates a GameObject using ProvideInstance.

    public AssetReferenceGameObject asset; // Identify the asset
    AsyncOperationHandle<GameObject> instHandle;
    AsyncOperationHandle<IList<IResourceLocation>> locHandle;
    
    void UsingInstanceProviderSample()
    {
        locHandle = Addressables.LoadResourceLocationsAsync(asset, typeof(GameObject));
        locHandle.Completed += OnLoadComplete;
    }
    
    void OnLoadComplete(AsyncOperationHandle<IList<IResourceLocation>> handle)
    {
        if (handle.Status == AsyncOperationStatus.Succeeded)
        {
            Debug.Log($"Successfully loaded resource locations");
            foreach (IResourceLocation location in handle.Result)
            {
                ResourceManager rm = Addressables.ResourceManager;
                IInstanceProvider provider = Addressables.InstanceProvider;
                instHandle = rm.ProvideInstance(provider, location, default(InstantiationParameters));
                instHandle.Completed += OnProvideInstanceComplete;
            }
        }
    }
    
    void OnProvideInstanceComplete(AsyncOperationHandle<GameObject> handle)
    {
        if (handle.Status == AsyncOperationStatus.Succeeded)
        {
            Debug.Log($"Successfully instantiated GameObject named '{handle.Result.name}'");
        }
    }
    
    void ReleaseResources()
    {
        Addressables.Release(locHandle);
        Addressables.Release(instHandle);
    }
    
    // When ready to release the asset, call ReleaseResources().
    // For example during OnDestroy().
    // void OnDestroy()
    // {
    //     ReleaseResources();
    // }
    문서 개요
    맨 위로
    Copyright © 2023 Unity Technologies — 상표 및 이용약관
    • 법률정보
    • 개인정보처리방침
    • 쿠키
    • 내 개인정보 판매 금지
    • Your Privacy Choices (Cookie Settings)