# ResourcesAPI

> Derive from this base class to provide alternative implementations to the C# behavior of specific Resources methods.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public class ResourcesAPI
```

## Remarks

The example provided logs the time taken to handle slower Resources APIs to the player or editor log.

## Examples

```csharp
using System;
using System.Diagnostics;
using UnityEngine;
using Object = UnityEngine.Object;
using Debug = UnityEngine.Debug;

public class ResourcesPerformanceLogger : ResourcesAPI
{
    [RuntimeInitializeOnLoadMethod]
    static void OnRuntimeMethodLoad()
    {
        ResourcesAPI.overrideAPI = new ResourcesPerformanceLogger();
    }

    protected override Object[] FindObjectsOfTypeAll(Type systemTypeInstance)
    {
        Stopwatch timer = new Stopwatch();
        timer.Start();
        Object[] results = base.FindObjectsOfTypeAll(systemTypeInstance);
        timer.Stop();
        Debug.Log($"FindObjectsOfTypeAll({systemTypeInstance}) Time: {timer.Elapsed}");
        return results;
    }

    protected override Shader FindShaderByName(string name)
    {
        Stopwatch timer = new Stopwatch();
        timer.Start();
        Shader result = base.FindShaderByName(name);
        timer.Stop();
        Debug.Log($"FindShaderByName({name}) Time: {timer.Elapsed}");
        return result;
    }

    protected override Object[] LoadAll(string path, Type systemTypeInstance)
    {
        Stopwatch timer = new Stopwatch();
        timer.Start();
        Object[] results = base.LoadAll(path, systemTypeInstance);
        timer.Stop();
        Debug.Log($"LoadAll({path}, {systemTypeInstance}) Time: {timer.Elapsed}");
        return results;
    }
}
```

## Constructors

| Constructor                                                                        | Description                                                                                                                                                        |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [ResourcesAPI()](/engine/6000.5/script-reference/unityengine/resourcesapi/ctor.md) | Constructor only to be used by deriving classes. Assign to [Api](/engine/6000.5/script-reference/unityengine/resourcesapi.md) to override Resources class methods. |

## Static Properties

| Property                                                                               | Description                                                                                                                                                                                                  |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [overrideAPI](/engine/6000.5/script-reference/unityengine/resourcesapi/overrideapi.md) | The specific [ResourcesAPI](/engine/6000.5/script-reference/unityengine/resourcesapi.md) instance to use to handle overridden [Resources](/engine/6000.5/script-reference/unityengine/resources.md) methods. |

## Methods

| Method                                                                                                   | Description                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [FindObjectsOfTypeAll](/engine/6000.5/script-reference/unityengine/resourcesapi/findobjectsoftypeall.md) | Override for customizing the behavior of the [Resources.FindObjectsOfTypeAll](/engine/6000.5/script-reference/unityengine/resources/findobjectsoftypeall.md) function. |
| [FindShaderByName](/engine/6000.5/script-reference/unityengine/resourcesapi/findshaderbyname.md)         | Override for customizing the behavior of the [Shader.Find](/engine/6000.5/script-reference/unityengine/shader/find.md) function.                                       |
| [Load](/engine/6000.5/script-reference/unityengine/resourcesapi/load.md)                                 | Override for customizing the behavior of the [Resources.Load](/engine/6000.5/script-reference/unityengine/resources/load.md) function.                                 |
| [LoadAll](/engine/6000.5/script-reference/unityengine/resourcesapi/loadall.md)                           | Override for customizing the behavior of the [Resources.LoadAll](/engine/6000.5/script-reference/unityengine/resources/loadall.md) function.                           |
| [LoadAsync](/engine/6000.5/script-reference/unityengine/resourcesapi/loadasync.md)                       | Override for customizing the behavior of the [Resources.LoadAsync](/engine/6000.5/script-reference/unityengine/resources/loadasync.md) function.                       |
| [UnloadAsset](/engine/6000.5/script-reference/unityengine/resourcesapi/unloadasset.md)                   | Override for customizing the behavior of the Unload function.                                                                                                          |
