Skip to content

Instantly share code, notes, and snippets.

@Hafune
Last active July 25, 2025 11:48
Show Gist options
  • Save Hafune/7fefaa5cbeab0b900fa7c67a022b9542 to your computer and use it in GitHub Desktop.
Save Hafune/7fefaa5cbeab0b900fa7c67a022b9542 to your computer and use it in GitHub Desktop.
#if UNITY_EDITOR
using System;
using UnityEditor;
using UnityEngine;
namespace Core
{
public class PathReferencePrefabPostprocessor : AssetPostprocessor
{
public static Action<GameObject> callback;
static void OnPostprocessAllAssets(string[] importedAssets,
string[] deletedAssets,
string[] movedAssets,
string[] movedFromAssetPaths)
{
foreach (string path in importedAssets)
{
if (!path.EndsWith(".prefab"))
continue;
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(path);
if (prefab is not null && !prefab)
return;
callback?.Invoke(prefab);
}
}
}
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment