docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ReloadAttribute

    The ReloadAttribute attribute specifies paths for loading or reloading resources and has no direct action. Used with the ResourceReloader to define where to load data for null fields.

    Inheritance
    object
    Attribute
    ReloadAttribute
    Inherited Members
    Attribute.Equals(object)
    Attribute.GetCustomAttribute(Assembly, Type)
    Attribute.GetCustomAttribute(Assembly, Type, bool)
    Attribute.GetCustomAttribute(MemberInfo, Type)
    Attribute.GetCustomAttribute(MemberInfo, Type, bool)
    Attribute.GetCustomAttribute(Module, Type)
    Attribute.GetCustomAttribute(Module, Type, bool)
    Attribute.GetCustomAttribute(ParameterInfo, Type)
    Attribute.GetCustomAttribute(ParameterInfo, Type, bool)
    Attribute.GetCustomAttributes(Assembly)
    Attribute.GetCustomAttributes(Assembly, bool)
    Attribute.GetCustomAttributes(Assembly, Type)
    Attribute.GetCustomAttributes(Assembly, Type, bool)
    Attribute.GetCustomAttributes(MemberInfo)
    Attribute.GetCustomAttributes(MemberInfo, bool)
    Attribute.GetCustomAttributes(MemberInfo, Type)
    Attribute.GetCustomAttributes(MemberInfo, Type, bool)
    Attribute.GetCustomAttributes(Module)
    Attribute.GetCustomAttributes(Module, bool)
    Attribute.GetCustomAttributes(Module, Type)
    Attribute.GetCustomAttributes(Module, Type, bool)
    Attribute.GetCustomAttributes(ParameterInfo)
    Attribute.GetCustomAttributes(ParameterInfo, bool)
    Attribute.GetCustomAttributes(ParameterInfo, Type)
    Attribute.GetCustomAttributes(ParameterInfo, Type, bool)
    Attribute.GetHashCode()
    Attribute.IsDefaultAttribute()
    Attribute.IsDefined(Assembly, Type)
    Attribute.IsDefined(Assembly, Type, bool)
    Attribute.IsDefined(MemberInfo, Type)
    Attribute.IsDefined(MemberInfo, Type, bool)
    Attribute.IsDefined(Module, Type)
    Attribute.IsDefined(Module, Type, bool)
    Attribute.IsDefined(ParameterInfo, Type)
    Attribute.IsDefined(ParameterInfo, Type, bool)
    Attribute.Match(object)
    Attribute.TypeId
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Rendering
    Assembly: Unity.RenderPipelines.Core.Runtime.dll
    Syntax
    [AttributeUsage(AttributeTargets.Field)]
    public sealed class ReloadAttribute : Attribute
    Remarks

    This attribute is designed for use in the Unity Editor and has no effect at runtime.

    UnityEngine.Rendering.IRenderPipelineResources have their own attribute ResourcePathAttribute to do this. When using them, resource reloading is handled automatically by the engine and does not require calling ResourceReloader.

    While ResourceReloader was originally created for handling Scriptable Render Pipeline (SRP) resources, it has been replaced by UnityEngine.Rendering.IRenderPipelineResources. The ResourceReloader, ResourceReloader and ReloadGroupAttribute remain available for for user-defined assets.

    Examples

    This shows how to use the attribute in the expected scenario. This is particularly useful for content creators. Adding a new field to a class that defines an asset results in null values for existing instances missing the field in their serialized data. Therefore, when a new field is added, a system for reloading null values may be necessary.

    using UnityEngine;
    using UnityEditor;
    

    public class MyResourcesAsset : ScriptableObject { [Reload("Shaders/Blit.shader")] public Shader blit;

    // Added in version 2
    [Reload("Shaders/betterBlit.shader")]
    public Shader betterBlit;
    

    }

    public static class MyResourceHandler { public static MyResourcesAsset GetAndReload() { var resources = AssetDatabase.LoadAssetAtPath<MyResourcesAsset>("MyResources.asset");

        // Ensure that update of the data layout of MyResourcesAsset
        // will not result in null value for asset already existing.
        // (e.g.: added betterBlit in the case above)
        ResourceReloader.ReloadAllNullIn(resources, "Packages/com.my-custom-package/");
        return resources;
    }
    

    }

    Constructors

    ReloadAttribute(string, int, int, Package)

    Creates a new ReloadAttribute for an array using automatic path name numbering.

    Declaration
    public ReloadAttribute(string pathFormat, int rangeMin, int rangeMax, ReloadAttribute.Package package = Package.Root)
    Parameters
    Type Name Description
    string pathFormat

    The format used for the path

    int rangeMin

    The array start index (inclusive)

    int rangeMax

    The array end index (exclusive)

    ReloadAttribute.Package package

    The lookup method

    Examples

    This example demonstrates handling arrays with resource paths that share a common format, differing only by an index.

    using UnityEngine;
    

    public class MyResourcesAsset : ScriptableObject { // The following will seek for resources: // - Texture/FilmGrain/Thin1.png // - Texture/FilmGrain/Thin2.png // - Texture/FilmGrain/Thin3.png [ResourcePaths("Texture/FilmGrain/Thin{0}.png", 1, 4)] public Texture[] thinGrains; }

    See Also
    ResourceReloader
    ReloadGroupAttribute

    ReloadAttribute(string, Package)

    Creates a new ReloadAttribute for a single resource.

    Declaration
    public ReloadAttribute(string path, ReloadAttribute.Package package = Package.Root)
    Parameters
    Type Name Description
    string path

    Search path

    ReloadAttribute.Package package

    The lookup method

    Examples

    This example shows how to directly specify the path of an asset.

    using UnityEngine;
    

    public class MyResourcesAsset : ScriptableObject { [Reload("Shaders/Blit.shader")] public Shader blit; }

    See Also
    ResourceReloader
    ReloadGroupAttribute

    ReloadAttribute(string[], Package)

    Creates a new ReloadAttribute for an array by specifying each resource path individually.

    Declaration
    public ReloadAttribute(string[] paths, ReloadAttribute.Package package = Package.Root)
    Parameters
    Type Name Description
    string[] paths

    Search paths

    ReloadAttribute.Package package

    The lookup method

    Examples

    This example demonstrates how to handle arrays with different resource paths.

    using UnityEngine;
    

    public class MyResourcesAsset : ScriptableObject { [ResourcePaths(new[] { "Texture/FilmGrain/Thin.png", "Texture/FilmGrain/Medium.png", "Texture/FilmGrain/Large.png", })] public Texture[] filmGrains; }

    See Also
    ResourceReloader
    ReloadGroupAttribute

    Fields

    package

    The lookup method.

    Declaration
    public readonly ReloadAttribute.Package package
    Field Value
    Type Description
    ReloadAttribute.Package
    See Also
    ResourceReloader
    ReloadGroupAttribute

    paths

    Search paths.

    Declaration
    public readonly string[] paths
    Field Value
    Type Description
    string[]
    See Also
    ResourceReloader
    ReloadGroupAttribute

    Extension Methods

    ReflectionUtils.GetField(object, string)
    ReflectionUtils.GetFields(object)
    ReflectionUtils.Invoke(object, string, params object[])
    ReflectionUtils.SetField(object, string, object)
    AnalyticsUtils.ToNestedColumnWithDefault<T>(T, T, bool)
    AnalyticsUtils.ToNestedColumn<T>(T, T)

    See Also

    ResourceReloader
    ReloadGroupAttribute
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)