SampleImportEventData
struct in
UnityEditor.PackageManager.UI
Suggest a change
Success!
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close
Submission failed
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close
Switch to Manual
A list of SampleImportEventData is passed to subscribers of Sample.OnBeforeImportFinish, with one entry per sample imported in the originating call to Sample.Import. Use the data to react to imports for example, by logging the destination path or chaining additional setup work before the Asset Database refresh runs.
using UnityEditor;
using UnityEditor.PackageManager.UI;
using UnityEngine;
public static class SampleImportLogger
{
[InitializeOnLoadMethod]
static void Subscribe()
{
Sample.OnBeforeImportFinish += data =>
{
foreach (var entry in data)
Debug.Log($"{entry.packageTechnicalName}: {entry.sampleDisplayName} -> {entry.newImportPath}");
};
}
}
Properties
| Property |
Description |
| newImportPath | The full path the sample was imported to, under the project's Assets folder. |
| oldImportPath | The path of a previous import of this sample, or `null` if the sample had not been imported before. |
| packageTechnicalName | The technical name (ID) of the package the sample belongs to. |
| sampleDisplayName | The display name of the imported sample. |