private static bool OnOpenAsset(int instanceId, int line) { for (int i = LogEditorConst.LogEditorConfigs.Length - 1; i >= 0; --i) { LogEditorConfig configTmp = LogEditorConst.LogEditorConfigs[i]; UpdateLogInstanceId(configTmp); if (instanceId == configTmp._instanceId) { string statckTrack = GetStackTrace(); if (!string.IsNullOrEmpty(statckTrack)) { string[] fileNames = statckTrack.Split('\n'); string fileName = GetCurrentFullFileName(fileNames); int fileLine = LogFileNameToFileLine(fileName); fileName = GetRealFileName(fileName); AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(fileName), fileLine); return(true); } break; } } return(false); }
private static void UpdateLogInstanceId(LogEditorConfig config) { if (config._instanceId > 0) { return; } var assetLoadTmp = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(config.LogScriptPath); if (null == assetLoadTmp) { throw new Exception("not find asset by path=" + config.LogScriptPath); } config._instanceId = assetLoadTmp.GetInstanceID(); }