Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


RegisterCustomDependency(string, Hash128)

Allows you to register a custom dependency that Assets can be dependent on. If you register a custom dependency, and specify that an Asset is dependent on it, then the Asset will get re-imported if the custom dependency changes.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor
public static void RegisterCustomDependency(string dependency, Hash128 hashOfValue)

Parameters

dependency

Name of dependency. You can use any name you like, but because these names are global across all your Assets, it can be useful to use a naming convention (eg a path-based naming system) to avoid clashes with other custom dependency names.

hashOfValue

A Hash128 value of the dependency.

Remarks

If an asset has a dependency to a custom dependency and the hash value of the custom dependency is changed, then the asset will get reimported. You can change the hash by calling RegisterCustomDependency again, and passing the same name, and a new value for the hash.
The reimport happens when either AssetDatabase.Refresh is called or it imported using AssetDatabase.ImportAsset().
For an example for how to use custom dependencies goto AssetImportContext.DependsOnCustomDependency
Exception
You should not call RegisterCustomDependency from any code that is executed during the Asset import process. If you do, this method will throw an exception.