コード例 #1
0
    public OpenAssetIdea GetIdea(string path)
    {
        OpenAssetExtension ext = GetExtension(path);

        if (ext == null)
        {
            return(null);
        }

        switch (ext.idea)
        {
        case OpenAssetIdeaType.Sublime:
            return(ideaSumlime);

        case OpenAssetIdeaType.IntelliJ:
            return(ideaIntelliJ);

        case OpenAssetIdeaType.Excel:
            return(ideaExcel);
        }
        return(null);
    }
コード例 #2
0
    public bool Open(string path, int line = 1)
    {
#if UNITY_EDITOR
        OpenAssetExtension ext = GetExtension(path);
        if (ext == null)
        {
            return(false);
        }
        if (ext.idea == OpenAssetIdeaType.InternalEditor)
        {
            InternalEditorUtility.OpenFileAtLineExternal(path, line);
            return(true);
        }

        OpenAssetIdea idea = GetIdea(path);

        if (idea == null)
        {
            return(false);
        }

        if (!File.Exists(idea.appPath))
        {
            return(false);
        }



        if (!path.StartsWith(Application.dataPath))
        {
            path = Application.dataPath.Replace("Assets", "/") + path;
        }

        path = path.Replace("//", "/");

        System.Diagnostics.Process          process   = new System.Diagnostics.Process();
        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
        //startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
        startInfo.FileName = idea.appPath;
        switch (idea.type)
        {
        case OpenAssetIdeaType.Sublime:
            startInfo.Arguments = string.Format("{0}:{1}:0", path, line);
            break;

        case OpenAssetIdeaType.IntelliJ:
            startInfo.Arguments = string.Format("{0} --line {1} {2}", "", line, path);
            break;

        default:
            startInfo.Arguments = string.Format("{0}", path);;
            break;
        }
        process.StartInfo = startInfo;

        if (process.Start())
        {
            SetForegroundWindow(process.Handle);
            SetActiveWindow(process.Handle);
            SetFocus(process.Handle);
        }

        return(true);
#else
        return(false);
#endif
    }