public bool OnOpenedAsset(int instanceID, int line) { // determine asset that has been double clicked in the project view var selected = EditorUtility.InstanceIDToObject(instanceID); var assetFilePath = Path.GetFullPath(AssetDatabase.GetAssetPath(selected)); if (!(selected.GetType().ToString() == "UnityEditor.MonoScript" || selected.GetType().ToString() == "UnityEngine.Shader" || (selected.GetType().ToString() == "UnityEngine.TextAsset" && //#if UNITY_5 || UNITY_5_5_OR_NEWER // EditorSettings.projectGenerationUserExtensions.Contains(Path.GetExtension(assetFilePath).Substring(1)) //#else EditorSettings.externalVersionControl.Contains(Path.GetExtension(assetFilePath).Substring(1)) //#endif ))) { return(false); } var modifiedSource = EditorPrefs.GetBool(ModificationPostProcessor.ModifiedSource, false); myLogger.Verbose("ModifiedSource: {0} EditorApplication.isPlaying: {1} EditorPrefsWrapper.AutoRefresh: {2}", modifiedSource, EditorApplication.isPlaying, EditorPrefsWrapper.AutoRefresh); if (modifiedSource && !EditorApplication.isPlaying && EditorPrefsWrapper.AutoRefresh) { UnityUtils.SyncSolution(); // added to handle opening file, which was just recently created. EditorPrefs.SetBool(ModificationPostProcessor.ModifiedSource, false); } var model = myModel.Maybe.ValueOrDefault; if (model != null) { if (PluginEntryPoint.CheckConnectedToBackendSync()) { const int column = 0; myLogger.Verbose("Calling OpenFileLineCol: {0}, {1}, {2}", assetFilePath, line, column); model.OpenFileLineCol.Start(new RdOpenFileArgs(assetFilePath, line, column)); if (model.RiderProcessId.HasValue()) { ActivateWindow(model.RiderProcessId.Value); } else { ActivateWindow(); } // todo: maybe fallback to CallRider, if returns false return(true); } } var args = string.Format("{0}{1}{0} --line {2} {0}{3}{0}", "\"", mySlnFile, line, assetFilePath); return(CallRider(args)); }
[UsedImplicitly] // https://github.com/JetBrains/resharper-unity/issues/475 public bool OnOpenedAsset(string assetFilePath, int line, int column = 0) { var modifiedSource = EditorPrefs.GetBool(ModificationPostProcessor.ModifiedSource, false); myLogger.Verbose("ModifiedSource: {0} EditorApplication.isPlaying: {1} EditorPrefsWrapper.AutoRefresh: {2}", modifiedSource, EditorApplication.isPlaying, EditorPrefsWrapper.AutoRefresh); if (modifiedSource && !EditorApplication.isPlaying && EditorPrefsWrapper.AutoRefresh || !File.Exists(PluginEntryPoint.SlnFile)) { UnityUtils.SyncSolution(); // added to handle opening file, which was just recently created. EditorPrefs.SetBool(ModificationPostProcessor.ModifiedSource, false); } var models = PluginEntryPoint.UnityModels.Where(a => a.Lifetime.IsAlive).ToArray(); if (models.Any()) { var modelLifetime = models.First(); var model = modelLifetime.Model; if (PluginEntryPoint.CheckConnectedToBackendSync(model)) { myLogger.Verbose("Calling OpenFileLineCol: {0}, {1}, {2}", assetFilePath, line, column); if (model.RiderProcessId.HasValue()) { AllowSetForegroundWindow(model.RiderProcessId.Value); } else { AllowSetForegroundWindow(); } model.OpenFileLineCol.Start(modelLifetime.Lifetime, new RdOpenFileArgs(assetFilePath, line, column)); // todo: maybe fallback to CallRider, if returns false return(true); } } var argsString = assetFilePath == "" ? "" : $" --line {line} --column {column} \"{assetFilePath}\""; // on mac empty string in quotes is causing additional solution to be opened https://github.cds.internal.unity3d.com/unity/com.unity.ide.rider/issues/21 var args = string.Format("{0}{1}{0}{2}", "\"", mySlnFile, argsString); return(CallRider(args)); }
[UsedImplicitly] // https://github.com/JetBrains/resharper-unity/issues/475 public bool OnOpenedAsset(string assetFilePath, int line) { var modifiedSource = EditorPrefs.GetBool(ModificationPostProcessor.ModifiedSource, false); myLogger.Verbose("ModifiedSource: {0} EditorApplication.isPlaying: {1} EditorPrefsWrapper.AutoRefresh: {2}", modifiedSource, EditorApplication.isPlaying, EditorPrefsWrapper.AutoRefresh); if (modifiedSource && !EditorApplication.isPlaying && EditorPrefsWrapper.AutoRefresh || !File.Exists(PluginEntryPoint.SlnFile)) { UnityUtils.SyncSolution(); // added to handle opening file, which was just recently created. EditorPrefs.SetBool(ModificationPostProcessor.ModifiedSource, false); } var models = PluginEntryPoint.UnityModels.Where(a => !a.Lifetime.IsTerminated).ToArray(); if (models.Any()) { var model = models.First().Model; if (PluginEntryPoint.CheckConnectedToBackendSync(model)) { const int column = 0; myLogger.Verbose("Calling OpenFileLineCol: {0}, {1}, {2}", assetFilePath, line, column); if (model.RiderProcessId.HasValue()) { ActivateWindow(model.RiderProcessId.Value); } else { ActivateWindow(); } model.OpenFileLineCol.Start(new RdOpenFileArgs(assetFilePath, line, column)); // todo: maybe fallback to CallRider, if returns false return(true); } } var args = string.Format("{0}{1}{0} --line {2} {0}{3}{0}", "\"", mySlnFile, line, assetFilePath); return(CallRider(args)); }