コード例 #1
0
ファイル: RiderPlugin.cs プロジェクト: ptlive360/test1
        static bool OnOpenedAsset(int instanceID, int line)
        {
            if (Enabled)
            {
                if (!Initialized)
                {
                    // make sure the plugin was initialized first.
                    // this can happen in case "Rider" was set as the default scripting app only after this plugin was imported.
                    InitRiderPlugin();
                    RiderAssetPostprocessor.OnGeneratedCSProjectFiles();
                }

                string appPath = Path.GetDirectoryName(Application.dataPath);

                // determine asset that has been double clicked in the project view
                var selected = EditorUtility.InstanceIDToObject(instanceID);

                if (selected.GetType().ToString() == "UnityEditor.MonoScript" ||
                    selected.GetType().ToString() == "UnityEngine.Shader")
                {
                    SyncSolution(); // added to handle opening file, which was just recently created.
                    var assetFilePath = Path.Combine(appPath, AssetDatabase.GetAssetPath(selected));
                    if (!CallUDPRider(line, SlnFile, assetFilePath))
                    {
                        var args = string.Format("{0}{1}{0} -l {2} {0}{3}{0}", "\"", SlnFile, line, assetFilePath);
                        CallRider(DefaultApp, args);
                    }
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        private static void InitRiderPlugin()
        {
            var projectDirectory = Directory.GetParent(Application.dataPath).FullName;

            var projectName = Path.GetFileName(projectDirectory);

            SlnFile = Path.Combine(projectDirectory, string.Format("{0}.sln", projectName));

            InitializeEditorInstanceJson(projectDirectory);

            RiderAssetPostprocessor.OnGeneratedCSProjectFiles();

            Log(LoggingLevel.Info, "Rider plugin initialized. You may change the amount of Rider Debug output via Edit -> Preferences -> Rider -> Logging Level");
            Initialized = true;
        }
コード例 #3
0
        static bool OnOpenedAsset(int instanceID, int line)
        {
            if (Enabled)
            {
                if (!Initialized)
                {
                    // make sure the plugin was initialized first.
                    // this can happen in case "Rider" was set as the default scripting app only after this plugin was imported.
                    InitRiderPlugin();
                    RiderAssetPostprocessor.OnGeneratedCSProjectFiles();
                }

                string appPath = Path.GetDirectoryName(Application.dataPath);

                // determine asset that has been double clicked in the project view
                var selected = EditorUtility.InstanceIDToObject(instanceID);

                var assetFilePath = Path.Combine(appPath, 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);
                }

                SyncSolution(); // added to handle opening file, which was just recently created.
                if (!DetectPortAndOpenFile(line, assetFilePath,
                                           SystemInfoRiderPlugin.operatingSystemFamily == OperatingSystemFamily.Windows))
                {
                    var args = string.Format("{0}{1}{0} --line {2} {0}{3}{0}", "\"", SlnFile, line, assetFilePath);
                    return(CallRider(args));
                }
                return(true);
            }

            return(false);
        }