Documentation

Unity Engine

Unity Engine

AssetPostprocessorStaticVariableIgnoreAttribute

Decorate static variables in AssetPostprocessor and ScriptedImporter classes that should be ignored by the static variable warning system in the Import Activity window.
Read time 4 minutesLast updated 15 days ago

Definition

[AttributeUsage(AttributeTargets.Field)]public class AssetPostprocessorStaticVariableIgnoreAttribute : Attribute

Remarks

Decorate static variables in PostProcessors and ScriptedImporters to prevent warnings about the usage of static variables.
Each asset import worker runs in its own process, separate from the Unity Editor, so static variable values aren't shared between them. If you modify a static variable in the Editor, the value in the worker isn't updated, which might lead to unexpected behavior. Use this attribute to reduce the warnings generated in situations where static variables are intentional.
The static variable warnings are accessible through the Analyze Import Process button in the Import Activity Window.

Examples

using UnityEditor;public class PostProcessorWithStaticVariable : AssetPostprocessor{ // Increment the version number, when the AssetPostprocessors code/behavior is changed static readonly uint k_Version = 0; public override uint GetVersion() { return k_Version; } [AssetPostprocessorStaticVariableIgnore] public static bool enabled = false; static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths, bool didDomainReload) { if(enabled == false) return; //do something else }}

Inheritance

Inherited Members