Class CachedProvider | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class CachedProvider

    Provider that can wrap other IResourceProviders and add caching and reference counting of objects.

    Inheritance
    System.Object
    CachedProvider
    Namespace: UnityEngine.ResourceManagement.ResourceProviders
    Syntax
    public class CachedProvider : IResourceProvider, IInitializableObject, IUpdateReceiver

    Constructors

    CachedProvider()

    Construct a new CachedProvider object. Initialize should be called after construction.

    Declaration
    public CachedProvider()

    CachedProvider(IResourceProvider, String, Int32, Single)

    Construct a new CachedProvider object.

    Declaration
    public CachedProvider(IResourceProvider provider, string providerId, int maxCacheItemCount = 0, float maxCacheItemAge = 0F)
    Parameters
    Type Name Description
    IResourceProvider provider

    The internal provider that will handle the loading and releasing of the objects.

    System.String providerId
    System.Int32 maxCacheItemCount

    How many items to keep in the cache. If set to 0, items are not cached.

    System.Single maxCacheItemAge

    How long to keep items in the cache. If set to 0, cached items are kept indefinitely.

    Properties

    BehaviourFlags

    Declaration
    public ProviderBehaviourFlags BehaviourFlags { get; }
    Property Value
    Type Description
    ProviderBehaviourFlags
    Implements
    IResourceProvider.BehaviourFlags

    ProviderId

    Unique identifier for this provider, used by Resource Locations to find a suitable Provider

    Declaration
    public string ProviderId { get; }
    Property Value
    Type Description
    System.String

    The provider identifier.

    Implements
    IResourceProvider.ProviderId

    Methods

    CanProvide<TObject>(IResourceLocation)

    Evaluate whether or not the provider can load the given location.

    Declaration
    public bool CanProvide<TObject>(IResourceLocation location)
        where TObject : class
    Parameters
    Type Name Description
    IResourceLocation location

    Location to evaluate.

    Returns
    Type Description
    System.Boolean

    true, if provide can load the location. false otherwise.

    Type Parameters
    Name Description
    TObject

    The object type for the given location.

    Implements
    IResourceProvider.CanProvide<TObject>(IResourceLocation)

    Initialize(String, String)

    Initialize this instance.

    Declaration
    public bool Initialize(string id, string data)
    Parameters
    Type Name Description
    System.String id

    The provider id.

    System.String data

    Serialized data. This can be generated by calling CreateInitializationData.

    Returns
    Type Description
    System.Boolean
    Implements
    IInitializableObject.Initialize(String, String)

    Provide<TObject>(IResourceLocation, IList<Object>)

    Provide the requested object. The cache will be checked first for existing objects. If not found, the internal IResourceProvider will be used to provide the object. The reference count for the asset will be incremented.

    Declaration
    public IAsyncOperation<TObject> Provide<TObject>(IResourceLocation location, IList<object> deps)
        where TObject : class
    Parameters
    Type Name Description
    IResourceLocation location
    System.Collections.Generic.IList<System.Object> deps
    Returns
    Type Description
    IAsyncOperation<TObject>
    Type Parameters
    Name Description
    TObject
    Implements
    IResourceProvider.Provide<TObject>(IResourceLocation, IList<Object>)

    Release(IResourceLocation, Object)

    Releasing an object to a CachedProvider will decrease it reference count, which may result in the object getting actually released. Released objects are added to an in memory cache.

    Declaration
    public bool Release(IResourceLocation location, object asset)
    Parameters
    Type Name Description
    IResourceLocation location

    The location of the object.

    System.Object asset

    The object to release.

    Returns
    Type Description
    System.Boolean

    True if the reference count reaches 0 and the asset is released.

    Implements
    IResourceProvider.Release(IResourceLocation, Object)

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Explicit Interface Implementations

    IUpdateReceiver.NeedsUpdate

    Declaration
    bool IUpdateReceiver.NeedsUpdate { get; }
    Returns
    Type Description
    System.Boolean
    Implements
    IUpdateReceiver.NeedsUpdate

    IUpdateReceiver.Update(Single)

    Declaration
    void IUpdateReceiver.Update(float deltaTime)
    Parameters
    Type Name Description
    System.Single deltaTime
    Implements
    IUpdateReceiver.Update(Single)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023