Last active
July 25, 2025 11:48
-
-
Save Hafune/7fefaa5cbeab0b900fa7c67a022b9542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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