Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [InitializeOnLoadMethod]
- public static void RefreshItemAssetPath() {
- EditorApplication.projectWindowChanged += () => {
- foreach (string guid in AssetDatabase.FindAssets("t:Item")) {
- string path = AssetDatabase.GUIDToAssetPath(guid);
- Item item = AssetDatabase.LoadAssetAtPath<Item>(path);
- Match match = new Regex(@"Assets\/Resources\/(?<resource_path>.*)\.asset").Match(path);
- if (!match.Success) {
- Debug.Log("Cannot extract resource Path. : " + path);
- return;
- }
- string resourcePath = match.Groups["resource_path"].Value;
- item.assetPath = resourcePath;
- }
- AssetDatabase.SaveAssets();
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement