Advertisement
Guest User

Untitled

a guest
May 1st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. [InitializeOnLoadMethod]
  2. public static void RefreshItemAssetPath() {
  3.  
  4. EditorApplication.projectWindowChanged += () => {
  5. foreach (string guid in AssetDatabase.FindAssets("t:Item")) {
  6. string path = AssetDatabase.GUIDToAssetPath(guid);
  7. Item item = AssetDatabase.LoadAssetAtPath<Item>(path);
  8. Match match = new Regex(@"Assets\/Resources\/(?<resource_path>.*)\.asset").Match(path);
  9. if (!match.Success) {
  10. Debug.Log("Cannot extract resource Path. : " + path);
  11. return;
  12. }
  13. string resourcePath = match.Groups["resource_path"].Value;
  14. item.assetPath = resourcePath;
  15. }
  16. AssetDatabase.SaveAssets();
  17. };
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement