OnBeforeImportFinish
Raised after files are imported into the project, but before the Asset Database refreshes.
Read time 1 minuteLast updated 12 days ago
Definition
- Type: Event
- Namespace: UnityEditor.PackageManager.UI
- Assembly: UnityEditor.CoreModule
public static event Action<IReadOnlyList<SampleImportEventData>> OnBeforeImportFinish
Remarks
Subscribe to this event to react to imported samples — for example, by importing dependent samples or packages — before the Asset Database refresh picks up the new files. The event is invoked with a list of SampleImportEventData describing each imported sample. The event fires once per call to Sample.Import, regardless of how many samples were imported in that call.
Subscribers are responsible for unsubscribing when they are no longer needed.
using System.Collections.Generic;using UnityEditor;using UnityEditor.PackageManager.UI;using UnityEngine;public static class SampleImportLogger{ [InitializeOnLoadMethod] static void Subscribe() { Sample.OnBeforeImportFinish += OnSamplesImported; } static void OnSamplesImported(IReadOnlyList<SampleImportEventData> events) { foreach (var data in events) Debug.Log($"Imported {data.sampleDisplayName} from {data.packageTechnicalName} to {data.newImportPath}"); }}
Additional Resources: SampleImportEventData, Sample.Import