public static void MenuOpenProject() { // Force the project files to be sync UnityUtils.SyncSolution(); // Load Project PluginEntryPoint.CallRider(string.Format("{0}{1}{0}", "\"", PluginEntryPoint.SlnFile)); }
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.IsProtocolConnected()) { 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)); }
static bool OnOpenedAsset(int instanceID, int line) { if (!PluginEntryPoint.IsRiderDefaultEditor()) { return(false); } // if (UnityUtils.UnityVersion >= new Version(2019, 2) // return false; return(OpenAssetHandler.OnOpenedAsset(instanceID, line, 0)); }
/// <summary> /// Called when Unity is about to open an asset. This method is new for 2019.2 /// </summary> //[OnOpenAsset] // todo: restore, when we move this code to package, otherwise when OnOpenedAsset is called, there is a LogError in older Unity static bool OnOpenedAsset(int instanceID, int line, int column) { if (!PluginEntryPoint.IsRiderDefaultEditor()) { return(false); } if (UnityUtils.UnityVersion < new Version(2019, 2)) { return(false); } return(OpenAssetHandler.OnOpenedAsset(instanceID, line, column)); }
public static void MenuOpenProject() { // method can be called via commandline if (!PluginEntryPoint.Enabled) { return; } // Force the project files to be sync UnityUtils.SyncSolution(); // Load Project PluginEntryPoint.CallRider(string.Format("{0}{1}{0}", "\"", PluginEntryPoint.SlnFile)); }
[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)); }
public static void UpdateSelf(string fullPluginPath) { if (string.IsNullOrEmpty(fullPluginPath)) { return; } if (!PluginEntryPoint.IsLoadedFromAssets()) { ourLogger.Verbose($"AdditionalPluginsInstaller disabled. Plugin was not loaded from Assets."); return; } ourLogger.Verbose($"UnityUtils.UnityVersion: {UnityUtils.UnityVersion}"); if (UnityUtils.UnityVersion >= new Version(5, 6)) { var fullPluginFileInfo = new FileInfo(fullPluginPath); if (!fullPluginFileInfo.Exists) { ourLogger.Verbose($"Plugin {fullPluginPath} doesn't exist."); return; } ourLogger.Verbose($"ourTarget: {ourTarget}"); if (File.Exists(ourTarget)) { var targetVersionInfo = FileVersionInfo.GetVersionInfo(ourTarget); var originVersionInfo = FileVersionInfo.GetVersionInfo(fullPluginFileInfo.FullName); ourLogger.Verbose($"{targetVersionInfo.FileVersion} {originVersionInfo.FileVersion} {targetVersionInfo.InternalName} {originVersionInfo.InternalName}"); if (targetVersionInfo.FileVersion != originVersionInfo.FileVersion || targetVersionInfo.InternalName != originVersionInfo.InternalName) { ourLogger.Verbose($"Coping ${fullPluginFileInfo} -> ${ourTarget}."); File.Delete(ourTarget); File.Delete(ourTarget + ".meta"); fullPluginFileInfo.CopyTo(ourTarget, true); AssetDatabase.Refresh(); return; } } ourLogger.Verbose($"Plugin {ourTarget} was not updated by {fullPluginPath}."); } }
[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)); }