示例#1
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(ModelName.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);
        }