# RunBeforeClassAttribute

> Add this attribute to a callback method to mark that this callback must be run before any callbacks that are part of the specified class.

## Definition

* **Type:** Constructor
* **Namespace:** [UnityEditor.Callbacks](/engine/6000.6/script-reference/unityeditor/callbacks.md)
* **Assembly:** UnityEditor.CoreModule

## RunBeforeClassAttribute(Type)

Add this attribute to a callback method to mark that this callback must be run before any callbacks that are part of the specified class.

```csharp
public RunBeforeClassAttribute(Type type)
```

### Parameters

**** (\[Type]\(https\://learn.microsoft.com/dotnet/api/system.type)): The class type that should be run after this callback.

### Remarks

To define dependencies for a callback, use the following attributes:

* [RunAfterClassAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterclassattribute.md), [RunBeforeClassAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforeclassattribute.md)
* [RunAfterAssemblyAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterassemblyattribute.md), [RunBeforeAssemblyAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforeassemblyattribute.md)
* [RunAfterPackageAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterpackageattribute.md), [RunBeforePackageAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforepackageattribute.md)

When the callback is invoked, Unity generates a dependency graph and uses topological sorting to ensure that all dependencies are run in sequence based on their dependencies. If callbacks dependencies are not present in the project then the instruction will be ignored during the generation of the dependency graph.

**Note:** Defining callback dependencies is currently only supported by the [AssetPostprocessor.OnPostprocessAllAssets(string\[\], string\[\], string\[\], string\[\], bool)](/engine/6000.6/script-reference/unityeditor/assetpostprocessor/onpostprocessallassets.md) callback.

### Examples

```csharp
using UnityEditor;
using UnityEditor.Callbacks;

class RunFirst : AssetPostprocessor
{
    [RunBeforeClass(typeof(RunNext))]
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}

class RunNext : AssetPostprocessor
{
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}

class RunLast : AssetPostprocessor
{
    [RunAfterClass(typeof(RunNext))]
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}
```

## RunBeforeClassAttribute(string)

Add this attribute to a callback method to mark that this callback must be run before any callbacks that are part of the specified class.

```csharp
public RunBeforeClassAttribute(string assemblyQualifiedName)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The assembly-qualified name of the class type  that should be run after this callback. This dependency attribute will be ignored when the name can not be resolved, such as if the class is not present in the current project.

### Remarks

To define dependencies for a callback, use the following attributes:

* [RunAfterClassAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterclassattribute.md), [RunBeforeClassAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforeclassattribute.md)
* [RunAfterAssemblyAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterassemblyattribute.md), [RunBeforeAssemblyAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforeassemblyattribute.md)
* [RunAfterPackageAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runafterpackageattribute.md), [RunBeforePackageAttribute](/engine/6000.6/script-reference/unityeditor/callbacks/runbeforepackageattribute.md)

When the callback is invoked, Unity generates a dependency graph and uses topological sorting to ensure that all dependencies are run in sequence based on their dependencies. If callbacks dependencies are not present in the project then the instruction will be ignored during the generation of the dependency graph.

**Note:** Defining callback dependencies is currently only supported by the [AssetPostprocessor.OnPostprocessAllAssets(string\[\], string\[\], string\[\], string\[\], bool)](/engine/6000.6/script-reference/unityeditor/assetpostprocessor/onpostprocessallassets.md) callback.

### Examples

```csharp
using UnityEditor;
using UnityEditor.Callbacks;

class RunFirst : AssetPostprocessor
{
    [RunBeforeClass(typeof(RunNext))]
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}

class RunNext : AssetPostprocessor
{
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}

class RunLast : AssetPostprocessor
{
    [RunAfterClass(typeof(RunNext))]
    static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
    }
}
```
