static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { /*foreach (string str in importedAssets) * { * Debug.Log("Reimported Asset: " + str); * } * foreach (string str in deletedAssets) * { * Debug.Log("Deleted Asset: " + str); * } * * foreach (string str in movedAssets) { * DLog.Log("Moved asset: " + str); * } * * foreach (string str in movedFromAssetPaths) { * DLog.Log("Moved from asset path: " + str); * }*/ List <MovedAsset> moved = new List <MovedAsset>(); for (int kIndex = 0; kIndex < movedAssets.Length; kIndex++) { string movedFromAssetPath = movedFromAssetPaths[kIndex]; try { if (movedFromAssetPath.EndsWith(".mat") || movedFromAssetPath.EndsWith(".prefab")) { string movedFromResourcePath = new AssetFile(movedFromAssetPath).ShowResourcePath(); string movedToResourcePath = new AssetFile(movedAssets[kIndex]).ShowResourcePath(); string movedFromParentFolder = movedFromResourcePath.Substring(0, movedFromResourcePath.LastIndexOf("/")); string movedToParentFolder = movedToResourcePath.Substring(0, movedToResourcePath.LastIndexOf("/")); /*bool isRename = movedFromParentFolder.Equals(movedToParentFolder); * if (isRename) { * DLog.Log("SSARAssetPostprocessor: Renaming detected, skip processing for asset: " + movedFromResourcePath); * continue; * }*/ moved.Add(new MovedAsset( movedFromResourcePath, movedToResourcePath )); if (movedAssets[kIndex].EndsWith(".asset")) { ScriptableObject so = Resources.Load <ScriptableObject>(moved[kIndex].newPath); if (so is SkillFrameConfig) { DLog.Log("Rename skill config, skip detection"); return; } } } } catch (Exception e) { DLog.LogException(new Exception(movedFromAssetPath, e)); } } ContextMenuExtension.MoveOrRenameAsset(moved); var editors = Resources.FindObjectsOfTypeAll <DungeonSpawnConfigEditor>(); foreach (string importedAsset in importedAssets) { /*if (importedAsset.EndsWith(".prefab")) { * GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(importedAsset); * DungeonSpawnConfig dungeonSpawnConfig = prefab.GetComponent<DungeonSpawnConfig>(); * if (!dungeonSpawnConfig) continue; * * string join = string.Join("", dungeonSpawnConfig.config); * dungeonSpawnConfig.configObjectForEditor = new JsonDeserializationOperation(join).Act<DungeonSpawnConfig.Config>(); * /*foreach (DungeonSpawnConfigEditor editor in editors) { * var prefabRoot = PrefabUtility.FindPrefabRoot(((DungeonSpawnConfig)editor.target).gameObject); * var prefabParent = PrefabUtility.GetPrefabParent(prefabRoot); * string prefabPath = AssetDatabase.GetAssetPath(prefabParent); * if (string.IsNullOrEmpty(prefabPath)) { * prefabPath = AssetDatabase.GetAssetPath(prefabRoot); * } * if(!prefabPath.Equals(importedAsset)) continue; * * DLog.Log("PopulateUsingDataReadFromDisk for asset " + importedAsset); * editor.PopulateUsingDataReadFromDisk(dungeonSpawnConfig.config, dungeonSpawnConfig.configObjectForEditor); * }#1# * * foreach (GameObject go in GameObject.FindObjectsOfType<GameObject>()) { * DungeonSpawnConfig otherDsc = go.GetComponent<DungeonSpawnConfig>(); * if (!otherDsc) continue; * var prefabRoot = PrefabUtility.FindPrefabRoot(otherDsc.gameObject); * var prefabParent = PrefabUtility.GetPrefabParent(prefabRoot); * string prefabPath = AssetDatabase.GetAssetPath(prefabParent); * if (string.IsNullOrEmpty(prefabPath)) { * prefabPath = AssetDatabase.GetAssetPath(prefabRoot); * } * if(!prefabPath.Equals(importedAsset)) continue; * * // DLog.Log("PopulateUsingDataReadFromDisk for asset " + importedAsset); * // otherDsc.PopulateUsingDataReadFromDisk(dungeonSpawnConfig.config, dungeonSpawnConfig.configObjectForEditor); * otherDsc.config = dungeonSpawnConfig.config; * otherDsc.configObjectForEditor = dungeonSpawnConfig.configObjectForEditor; * } * }*/ } }