private static void Init() { var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); // for the case when files were changed and user just alt+tab to unity to make update, we want to fire CsprojAssetPostprocessor.OnGeneratedCSProjectFiles(); Log.DefaultFactory = new RiderLoggerFactory(); var lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); Debug.Log($"Rider plugin initialized. Logs are in: {LogPath}. Current Logging Level {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider."); try { var riderProtocolController = new RiderProtocolController(MainThreadDispatcher.Instance, lifetime); var serializers = new Serializers(); var identities = new Identities(IdKind.Server); MainThreadDispatcher.AssertThread(); riderProtocolController.Wire.Connected.View(lifetime, (lt, connected) => { if (connected) { var protocol = new Protocol(serializers, identities, MainThreadDispatcher.Instance, riderProtocolController.Wire); ourLogger.Log(LoggingLevel.VERBOSE, "Create UnityModel and advise for new sessions..."); ourModel.Value = CreateModel(protocol, lt); } else { ourModel.Value = null; } }); } catch (Exception ex) { ourLogger.Error("Init Rider Plugin " + ex); } ourAssetHandler = new OnOpenAssetHandler(ourModel, ourRiderPathLocator, ourPluginSettings, SlnFile); ourInitialized = true; }
public static void Init() { if (ourInitialized) { return; } var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); var lifetimeDefinition = Lifetime.Define(Lifetime.Eternal); Lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); #if !UNITY_4_7 && !UNITY_5_5 && !UNITY_5_6 EditorApplication.playModeStateChanged += state => { if (state == PlayModeStateChange.EnteredPlayMode) { var time = DateTime.UtcNow.Ticks.ToString(); SessionState.SetString("Rider_EnterPlayMode_DateTime", time); } }; #endif if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { var executingAssembly = Assembly.GetExecutingAssembly(); var location = executingAssembly.Location; Debug.Log($"Rider plugin \"{executingAssembly.GetName().Name}\" initialized{(string.IsNullOrEmpty(location)? "" : " from: " + location )}. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } var protocolInstanceJsonPath = Path.GetFullPath("Library/ProtocolInstance.json"); InitializeProtocol(Lifetime, protocolInstanceJsonPath); OpenAssetHandler = new OnOpenAssetHandler(ourRiderPathProvider, ourPluginSettings, SlnFile); ourLogger.Verbose("Writing Library/ProtocolInstance.json"); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { ourLogger.Verbose("Deleting Library/ProtocolInstance.json"); File.Delete(protocolInstanceJsonPath); }; PlayModeSavedState = GetPlayModeState(); ourInitialized = true; }
public static void Init() { if (ourInitialized) { return; } var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); var lifetimeDefinition = Lifetime.Define(Lifetime.Eternal); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { var executingAssembly = Assembly.GetExecutingAssembly(); var location = executingAssembly.Location; Debug.Log($"Rider plugin \"{executingAssembly.GetName().Name}\" initialized{(string.IsNullOrEmpty(location)? "" : " from: " + location )}. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } var list = new List <ProtocolInstance>(); CreateProtocolAndAdvise(lifetime, list, new DirectoryInfo(Directory.GetCurrentDirectory()).Name); // list all sln files in CurrentDirectory, except main one and create server protocol for each of them var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory()); var solutionFiles = currentDir.GetFiles("*.sln", SearchOption.TopDirectoryOnly); foreach (var solutionFile in solutionFiles) { if (Path.GetFileNameWithoutExtension(solutionFile.FullName) != currentDir.Name) { CreateProtocolAndAdvise(lifetime, list, Path.GetFileNameWithoutExtension(solutionFile.FullName)); } } OpenAssetHandler = new OnOpenAssetHandler(ourRiderPathProvider, ourPluginSettings, SlnFile); ourLogger.Verbose("Writing Library/ProtocolInstance.json"); var protocolInstanceJsonPath = Path.GetFullPath("Library/ProtocolInstance.json"); File.WriteAllText(protocolInstanceJsonPath, ProtocolInstance.ToJson(list)); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { ourLogger.Verbose("Deleting Library/ProtocolInstance.json"); File.Delete(protocolInstanceJsonPath); }; PlayModeSavedState = GetPlayModeState(); ourInitialized = true; }
private static void Init() { var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); ResetDefaultFileExtensions(); // process csproj files once per Unity process if (!RiderScriptableSingleton.Instance.CsprojProcessedOnce) { EditorApplication.update += SyncSolutionOnceCallBack; } var lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { Debug.Log($"Rider plugin initialized. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } var list = new List <ProtocolInstance>(); CreateProtocolAndAdvise(lifetime, list, new DirectoryInfo(Directory.GetCurrentDirectory()).Name); // list all sln files in CurrentDirectory, except main one and create server protocol for each of them var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory()); var solutionFiles = currentDir.GetFiles("*.sln", SearchOption.TopDirectoryOnly); foreach (var solutionFile in solutionFiles) { if (Path.GetFileNameWithoutExtension(solutionFile.FullName) != currentDir.Name) { CreateProtocolAndAdvise(lifetime, list, Path.GetFileNameWithoutExtension(solutionFile.FullName)); } } ourOpenAssetHandler = new OnOpenAssetHandler(ourRiderPathLocator, ourPluginSettings, SlnFile); ourLogger.Verbose("Writing Library/ProtocolInstance.json"); var protocolInstanceJsonPath = Path.GetFullPath("Library/ProtocolInstance.json"); File.WriteAllText(protocolInstanceJsonPath, ProtocolInstance.ToJson(list)); AppDomain.CurrentDomain.DomainUnload += (sender, args) => { ourLogger.Verbose("Deleting Library/ProtocolInstance.json"); File.Delete(protocolInstanceJsonPath); }; PlayModeSavedState = GetEditorState(); SetupAssemblyReloadEvents(); ourInitialized = true; }
private static void Init() { var projectDirectory = Directory.GetParent(Application.dataPath).FullName; var projectName = Path.GetFileName(projectDirectory); SlnFile = Path.GetFullPath($"{projectName}.sln"); InitializeEditorInstanceJson(); // process csproj files once per Unity process if (!RiderScriptableSingleton.Instance.CsprojProcessedOnce) { ourLogger.Verbose("Call OnGeneratedCSProjectFiles once per Unity process."); CsprojAssetPostprocessor.OnGeneratedCSProjectFiles(); RiderScriptableSingleton.Instance.CsprojProcessedOnce = true; } Log.DefaultFactory = new RiderLoggerFactory(); var lifetimeDefinition = Lifetimes.Define(EternalLifetime.Instance); var lifetime = lifetimeDefinition.Lifetime; AppDomain.CurrentDomain.DomainUnload += (EventHandler)((_, __) => { ourLogger.Verbose("lifetimeDefinition.Terminate"); lifetimeDefinition.Terminate(); }); if (PluginSettings.SelectedLoggingLevel >= LoggingLevel.VERBOSE) { Debug.Log($"Rider plugin initialized. LoggingLevel: {PluginSettings.SelectedLoggingLevel}. Change it in Unity Preferences -> Rider. Logs path: {LogPath}."); } try { var riderProtocolController = new RiderProtocolController(MainThreadDispatcher.Instance, lifetime); var serializers = new Serializers(); var identities = new Identities(IdKind.Server); MainThreadDispatcher.AssertThread(); riderProtocolController.Wire.Connected.WhenTrue(lifetime, connectionLifetime => { var protocol = new Protocol("UnityEditorPlugin", serializers, identities, MainThreadDispatcher.Instance, riderProtocolController.Wire); ourLogger.Log(LoggingLevel.VERBOSE, "Create UnityModel and advise for new sessions..."); var model = new EditorPluginModel(connectionLifetime, protocol); AdviseUnityActions(model, connectionLifetime); AdviseModel(model); OnModelInitialization(new UnityModelAndLifetime(model, connectionLifetime)); AdviseRefresh(model); model.FullPluginPath.Advise(connectionLifetime, AdditionalPluginsInstaller.UpdateSelf); model.ApplicationVersion.SetValue(UnityUtils.UnityVersion.ToString()); model.ScriptingRuntime.SetValue(UnityUtils.ScriptingRuntime); ourLogger.Verbose("UnityModel initialized."); UnityModel.SetValue(model); new UnityEventLogSender(ourLogEventCollector, connectionLifetime); }); } catch (Exception ex) { ourLogger.Error("Init Rider Plugin " + ex); } ourOpenAssetHandler = new OnOpenAssetHandler(UnityModel, ourRiderPathLocator, ourPluginSettings, SlnFile); ourInitialized = true; }