Search Unity

JetBrains の Rider で C# スクリプティングを高速化しよう

, 8月 13, 2019

Unity では時々、アセットストアのパートナーが制作したツールの中で、多くの Unity デベロッパーの皆様にとって特に有益と思われるものをピックアップしてご紹介しています。本記事では、JetBrains の開発した C# スクリプトエディター「Rider」にスポットライトを当ててお届けします。

Rider には、アセットとパッケージの閲覧機能、ソース管理の統合された充実したコードエディター、インスペクション機能、コードの自動補完(オートコンプリート)機能が搭載されています。

C# の作業を高速化する

開発者の皆様なら、お使いのスクリプトエディターと Unity とを何度も行ったり来たりしなから行う作業の煩わしさをお分かりのことと思います。できるならコードの泥沼にはまって行き詰まることなく、ゲーム自体に集中したいと感じられることでしょう。JetBrains が開発した統合開発環境(IDE)「Rider」は、ファイルを探す作業や手間のかかる細かな作業を自動化することで、C# プログラマーの皆様の時間を節約し、より快適な Unity のナビゲーションをサポートします。以下にご紹介する各種機能を皆様のワークフローの効率性と生産性の向上にどのように活かせるか、ぜひご検討ください。

必要なものを素早く見つける

キーボードショートカット「Shift+Shift」でアクティベートされる「Search Everywhere」機能で、プロジェクトのナビゲーションが大幅に効率化されます。Shift+Shift を押してから入力を開始すると、クラスやファイルやシンボルを簡単に見付けることができます。Rider は「スマートな」アルゴリズムを使用しているので、クラス名やメソッド名に含まれる複数の単語の頭文字を使った検索も可能です。

Search Everywhere ダイアログでは、プロジェクトのクラスやファイル、シンボルだけでなく、エディター自体の中にあるメニューアイテムや環境設定項目も素早く検索することができます。

コードをより素早く記述する

Rider は、Unity クラスのすべてのイベント関数の候補表示と自動補完もしてくれるので、コードをより素早く記述することができます。このアプリケーションには、Unity バージョン 5.0 から 2019.2 までの Unity API の情報が全て含まれています。

Unity イベント関数の入力を開始すると、Rider がコード自動補完リスト内にすべての関数を表示し、選択されたメソッドを生成してくれます。

スクリプト内の問題の検知

いくらコードを速く記述しても、それが機能しなければ意味がありません。Rider は、あなたがコードを記述するそばから解析を行って一般的な問題を発見してくれます。Null Reference Exception の可能性から、新しい C# 言語の関数(C# 7 に移行される方はいらっしゃいますか?)の提案まで、この IDE は、コード内に発見されたすべての問題をハイライト表示してくれます。Alt+Enter を押すと、コードを自動的に安全に再記述して問題を即座に修正(クイックフィックス)することができます。Rider には、コードの品質を高めるための 2,200 種以上のインスペクション、450 種のクイックフィックス、50 種以上のリファクタリング(名前の変更やクラスの抽出など)が搭載されています。

Rider のインスペクション機能によって、コードの中で改善の余地がある箇所がハイライト表示されます。Alt+Enter を押すとクイックフィックスのメニューが表示され、コードを自動的に記述し直すことができます。

Unity に関連して起こる問題を事前に発見する

この IDE は、C# だけでなく Unity に関する深い理解も備えています。スクリプトのコンポーネントやシリアライズされたフィールド、さらにはエディター内でシーンやプレハブに登録されたイベントハンドラーまでハイライト表示が可能です。(そしてもちろん、C# でイベントハンドラーの名前を変更すれば、シーンやプレハブ内にも更新が反映されます。)

さらに注目に値するのは、Unity に関連した問題を、入力するそばからハイライト表示してくれるので、時間が節約できることです。通常であればランタイムでしか(つまり Unity に戻って再生モードを開始し、ゲームを該当箇所までプレイすることでしか)発見できない問題を発見し、自動的に修正することができます。

例えば以下のような問題を発見できます。

  • Invoke や StartCoroutine の文字列リテラル引数のタイプミス

  • Unity の属性でマークされたメソッドの署名の間違い

  • (C# 6 で)Null 合体演算子や条件付きアクセス演算子が明示的 Null チェックと一致しない場合に発生する、下層オブジェクトのライフタイムチェックの意図せぬ迂回

  • SerializeField 属性を適用した時にスクリプトがシリアライズしない理由 ― (例)プロパティに適用してしまった場合(通常は見逃されやすい)

Rider は、Unity がコードを使用する仕組みを理解しており、ランタイムで問題を発見することになる前に、エディター内で警告を表示してくれます。

より高速な C# を記述する

この IDE は、コードの記述作業を高速化するだけでなく、より高速なコードを記述するためにも役立ちます。

Rider のインスペクション機能には、パフォーマンスに関する Unity のベストプラクティスの多くが組み込まれています。例えば以下のような場合に役立ちます。

 

Rider はパフォーマンスに関する Unity のベストプラクティスを直接エディター内でハイライト表示します。ショートカットキー「Alt+Enter」でアクティベートされるクイックフィックス機能でコードを自動的に記述し直すことができます。

すべてのインスペクションにシンプルな修正候補が用意されており、「Alt+Enter」のショートカットキーを使用して素早くコードを再記述して修正できます。

Rider は、簡単には発見しづらい一部の問題にも役立ちます。このソフトウェアは、Unity がコードを呼び出す仕組みを把握しています。そして 頻繁に(基本的に毎フレーム)Update メソッドが呼び出され、その最適化が必要であることを把握しています。エディターは、このメソッドと、Unity のベストプラクティスに基づいてその中で作成された時間の掛かる API 呼び出し([例]GetComponent や SendMessage への呼び出しなど)のすべてに、インジケーターを追加します。このインジケーターは、こうした呼び出しは負荷が高いため慎重に使用すべきであることを知らせるためのものですが、それらを使用することが間違っているというわけではありません。

例えば、Update の中での GetComponent の呼び出しは高負荷な操作であり、通常はこの呼び出しを Start あるいは Awake に移動させるのが最善です ― これを、このソフトウェアによって自動化できます。また、SendMessage への呼び出しもリソースを大きく消費し、その修正には相当の作業を要します ― Rider はこれを警告としては表示しませんが、インジケーターを使用して、このメソッドのプロファイリングが推奨されることを知らせます。

Update メソッドが「パフォーマンスに重大な影響を与えるコンテキスト」(Performance critical context)としてマークされ、既知の高負荷なメソッドを回避するための更なるインスペクションとハイライト表示が可能になります。

Rider には組み込みのコードプロファイラーが搭載されています。これを Unity エディターに添付してプロファイリング結果を表示することが可能です。コードの記述に使用している同じエディター内で、コードが実際にどのように実行されるかを正確に確認することができます。

コードに焦点を当てたプロファイリングによって、各メソッドにどれだけの時間が費やされているかを確認できます。

JetBrains の提供する Rider は、Unity スクリプティングのためのスマートな C# エディターです。このソフトウェアは、開発の生産性やコードのパフォーマンスを向上させるための様々な機能を提供します。こちらの動画で、その仕組みをご紹介しています。Rider は Unity アセットストアからご購入いただけます。本ソフトウェアについてさらに詳しくお知りになりたい方は、JetBrains のウェブサイトをご覧ください。JetBrains のブログで、最新の機能に関する情報をご確認いただけます。

43 コメント

コメントの配信登録

返信する

これらの HTML タグや属性を使用できます: <a href=""> <b> <code> <pre>

  1. @Claudia L, is there a reason for Unity Technologies to turn to a non free IDE? Do you plan on discarding Visual Studio in the near future?

  2. Rider is on a class of its own to be completely honest. I have yet to see an IDE that match 10% of the functionality Rider offers. It is by far the most feature rich IDE and one of the fastests if not THE fastest.

  3. DIEGO GABRIEL RUIZ

    8月 21, 2019 9:52 pm 返信

    Rider is the best IDE for C# / Unity I’ve ever used on Mac. Better than Visual Studio, VS Code, MonoDevelop, Xamarin. Great integration.

  4. The comments comparing Rider to VS Code are not very helpful as it is the traditional debate of IDE vs Text Editor. Rider is a good IDE (and a no-brainer on Mac), but of course if you love text editors you will probably dislike Rider as it is particularly “bloated” with lots of features, warnings, and so on, but it is what some people are looking for.

  5. Meh.

    OK, I tried using it, on both PC and Mac, for a couple of weeks. No problem paying if it was improving my workflow, but then left at end of trial. As a solo developer, I don’t understand why it’s better than VSCode. Maybe it’s just my use case. It seemed to have a lot more features. And they seemed to make it a better code editing environment for a solo unity developer in much the same way as Microsoft Word would be a better environment to compose text messages.

    The code hinting would be nice if you were on a larger team and trying to enforce more coding style consistency, but it’s unbelievably chatty. If I cared about half of its software engineering and performance suggestions, I wouldn’t be using Unity in the first place. I mean, with Monobehaviour you live in a world where parameterized constructors don’t exist, so my bar for “potential coding style issues” that should be flagged has moved somewhat from the past.

    The debugger would be nice if anyone still believed in coding workflow based around stepping in debuggers. (Remember when stepping through every line of code you wrote was standard practice?)

    Auto-decompilation is good (hello, Unity UI), but not something I use often enough to influence my choice of editor.

    The overall IDE felt, I dunno. Like some massive Java environment tweaked to fit Unity, whereas VSCode feels like a text editor beefed up into a coding environment.

    It’s definitely better than VS/rebranded-Monodevelop on a Mac, but who uses that?

  6. jetbrains can’t even do a proper scrollmap bar like visual studio..bug tracker for it has been around for yonks.. .let alone improve tab support options.. no way I’d subscribe such little done to improve things in those areas… company has to buy an ultimate license because of some features for other things that are locked behind it, but that’s java, for c# I’d just use visual studio… much better, actual decent scrollmap view and debugging… shame vscode is still a bit rubbish for c# really

    1. Matt Ellis (JetBrains)

      8月 22, 2019 10:48 am 返信

      Have you tried the CodeGlance plugin? That adds a nice scrollbar minimap in the text editor.

      And can you provide some more details about what you mean by “tab support”?

  7. I use Rider daily at work. It is very heavy app consuming a lot of PC resources. Debugging on devices may be pain. Sometimes i need to File->Clean cache and restart because of glitches. Some hints it gives are false positives. Still, it is better than VS it terms of code writing, navigation and refactoring, all other features are the same. Ultimately Rider is IDEA IDE + ReSharper VS plugin. The company developing it MAY release that said plugin for Visual Studio Code but they DO NOT WANT to because Rider sales will go definitely down. That’s why I won’t by rider licence for home use and stick with other code editor.

    1. Matt Ellis (JetBrains)

      8月 22, 2019 10:43 am 返信

      There are no plans to release ReSharper for Visual Studio Code – the extensibility support in VSCode isn’t flexible enough to handle everything that ReSharper can do. With Rider, JetBrains maintains the entire IDE, and can introduce new and truly useful features such as Local History in a way that is just not possible as a plugin.

      I’d be very interested to hear some details about glitches or reasons for cleaning caches. And we’d love to fix any false positives. Please can you raise an issue with some details? https://youtrack.jetbrains.com/newIssue?project=RIDER

  8. AnomalousUnderdog

    8月 15, 2019 1:07 am 返信

    I used to run Rider (and my Unity project) on a laptop with a traditional hard drive. It was slow. I’ve since upgraded to a desktop with an NVMe SSD, and realized it was my hard drive that was holding it back. So anyone saying it’s slow, you might want to check your hardware.

  9. After VS, Rider has a lot of features but perhaps a step too far – I find myself trying to work out how to turn off half the warnings, underlines, usage statistics, param name hints (?!) etc. It is too busy out of the box, but no doubt is closer to Unity with the work gone into that side.

    1. It is remarkably easy to turn off any feature that annoys you via the Alt-Enter menu. Some are obnoxious to many users, but disabling any of them is simple.

  10. Im not actually sure spotlights for partners on your blog works very well for the partners, as in there always seems to be about 50-50 split of positive and negative comments on these posts and I feel it may actually do more harm than good sometimes, expecially for the image of unity in peoples minds.

    People just dont like being advertised to if they can help it.

    I appreciate that you have partnerships and helping feature partners is important, but as you can see people are reading it as “extra costs for unity” which means people are getting a bad image of unity, at the cost of putting a brief spotlight on a partner.

    Everytime you do one of these people get impression that there are additional costs to using unity in the most efficient way and that without these tools they cant get 100% from unity, which ofcourse is an incorrect assessment but it does not help the fact that it is what people are taking away from this.

    Probably best to weigh up whether increasing sales of rider at cost of losing some potential unity plus or pro converts down the line is actually worthit.

    Anyway, anyone reading this should know that Rider is amazing, I hate being advertised to as well but this is the truth: I really believe this tool is better than VS, cheaper, and necessary for ANY c# development, not just unity. Itll save you time and make you code better, and even teach you things along the way.

  11. Those Russian guys make the best IDEs. Used their PyCharm for my python scripting for years and have never seen anything better.
    Rider is the best expierence I ever had with C# and Unity Integration is awesome!

  12. Is it better than Code VisualStudio?

    1. They have different strengths. VS Code is lightweight (at least as far as startup time and features go). It’s simple and fast. Rider is more heavy-duty, slower to start up, but it also has a ton of features. Where Rider really wins is the code completion, quick fixes and automatic refactoring. And they really went all-in with Unity support over the last 1-2 years.

  13. Cannot recommend another product as much as I do Rider. It’s everything one could want in an IDE

  14. Does the built-in code profiler that can be attached to the Unity Editor slow down the editor as much as the deep profiling in Unity? How good are the time measurements?
    Because of the performance hit of deep profiling in Unity, and how it hits (calls have a somewhat constant cost for the profiler, and because there isn’t any inlining during the profiling, It’s easy that a function is shown to be slower than another one when in fact it isn’t) deep profiling timings can’t be trusted to perform comparisons, and sometimes don’t show what is slow or not, so I want to know if the profiler used by Jetbrains suffer from the same problem, or it uses, for example, sampling profiling.

    Thank you.

    1. Matt Ellis (JetBrains)

      8月 15, 2019 10:51 pm 返信

      We haven’t done any specific measurements, but it should have less impact on the Editor. Rider’s profiler is a sampling profiler that also collects events from the Mono runtime (exceptions, contentions, allocations, GC and so on). It doesn’t look at frames or rendering or other Unity specific stuff, but only at the performance of your C# code.

  15. I’m on Mac and used to rely on Visual Studio in a parallels VM, mainly so I could use resharper. About 6 months ago I switched to Rider on Mac and it’s been great. After using resharper the switch was pretty much seamless and everything runs much quicker.

    It’s not free, but if you’re a professional developer $139 isn’t much if it’s your IDE you’re using every day. Discounts are available for startups.

    Support has been pretty good when I reported a minor bug to them, and unity debugging integration works very smoothly.

    All in all I wouldn’t go back!

  16. Google suggested this post on my Chrome, got interested and now regret it. Can’t say in name of Mac users who are questionable IT anyway, but VS has no drawbacks. GL to JetBrains guys, but no thanks. Plus, as being really honest evangelist of Unity and seeing ‘professional tools’ shit pricing rise up, I am deeply starting to regret my attitude.

  17. The amount of essential features that are needed for efficient Unity development, that are not part of Unity itself and need to be purchased is stacking up. Unity is really behind and needs to catch up with essential features! Odin, Behavior Trees, advanced Terrain System, GPU Instancing and many more and now the IDE?! Yes, Unity is slowly catching up with TextMeshPro and ProBuilder, but competitors are way ahead! Unity is a very big indie engine and it shouldn’t require to spend multiple hundred of Euros for basic functionality like a IDE that is properly integrated.

    Yes, I know VS Code is free and I’m using it, but there are issues that requires restarting VS Code till it recognized all Classes and it is too slow in my opinion. Features like this in those GIFs from JetBrains Rider are not available in VS Code and Unity should prioritize getting such effective time savers out there for anyone for free.

    1. Except that nothing you have mentioned is required for hobbyist unity development. Most proffesionals wont be using those asset store tools you mentioned, in fact most professionals dont use the asset store except for dire circumstances, and even then try to decouple themselves from bought assets the moment they are able.

      I cant remember the last time in any studio I worked that we used the asset store for things like anything you mentioned.

      The only one that comes close to being ok to buy in a professional setting is Odin, but lets be honest it is not hard to write a custom inspector, editor window or property drawer not is it difficult to make these things generic so you can reuse said code once built. Most professional studios have this sort of toolchain already.

      So lets make a distinction, none of this is required, it will just make life easier and save time.

      All professional software has extensions and plugins including all autodesk, adobe, even visual studio.

      Prior to rider many studios bought resharper which is basically rider for VS, which was far more expensive.

      It is not down to a game engine to provide an IDE, very few do and those that do are awful with most users still resorting to professional IDEs. You have a free IDE, and as you said there are issues. If you dont like those issues, then pay for a professional IDE like the rest of us because you get what you pay for.

      At the end of the day if your a professional then spending money on advanced tools is not a probem. If you are not a professional, then I am not sure why you expect to get these sorts of tools for free when the paying indie business community doesnt.

      Also I pay for a personal rider license at home alongside my work license and lets be honest, £10 a month is not a lot of money.

  18. VScode is awesome and is free.

  19. Jashan Chittesh

    8月 13, 2019 10:55 pm 返信

    After reading a tweet by Kirill from JetBrains about two weeks ago, I gave Rider a try and have to say that I like everything about both the product and the company that’s building that product. Of course, moving from one IDE that is pretty good … and free (Visual Studio Community Edition), to another one that requires a subscription is not a decision easily made – but IMHO, the subscription model they have at JetBrains is really fair (also includes a perpetual fallback license if you stop the subscription after one year, and subscription prices go down after one and two years).

    I also wrote a little article about my experiences during those first two weeks: https://medium.com/@jashan/using-jetbrains-rider-with-unity-ab6c4c33c3e?source=friends_link&sk=8acb66b45fd8f98b5b4aa2226a8f70d8

    In a nutshell: There are a few things that I will miss from Visual Studio – but even though I never liked ReSharper, there are already more things from Rider that I would miss in Visual Studio if I went back.

    Also, I haven’t noticed the performance issues that some of the other commenters talked about – but I do have a 9900K and fast SSD, so that might make the difference. Also, Rider does start up very slowly, and analyzes the Unity project the first time it starts up. But that’s not an issue when actually working with Unity / Rider (unlike Visual Studio which has been causing a lot of problems while working with it and Unity for me).

    That’s on Windows 10, though. I’m only using my Mac for Mail now, and for doing iOS builds ;-)

  20. I echo Mahdi comments about CPU usage. I _wanted_ to like and use Rider but it felt like such a hog that after the trial I went back to vscode. Np shelling out the money if it worked better but I actually prefer the free option of vscode for general coding – so much more responsive.

    Also there were numerous UX issues on mac. One of many examples is the scroll speed, it’s sluggish and too slow by default. There is no option to change it. I ended up having to install plugins… the first didn’t work and the second only worked when a key was held down. I’m not willing to invest the time to learn how to and write my own plugin for such a basic thing when vscode is fine.

    I ended up occasionally launching my trial Rider to debug and step through something in Unity (which it does excellently compared to vscode which breaks constantly in the debugger with DOTs) or as a static analyser to launch once in a while and review code with.

    It’s too heavy weight and sluggish for quick typing/coding away on a MacBook Pro though.

    I actually kept a log of usage notes which I will now send to Rider as feedback…

    1. Sounds like you need a faster computer…. Ive been a VS code user for the past 2 years and ive been on Rider for one month now, and besides loading time, its just as quick and has alot less problems. Its ability to rename a script and traverse all scenes and prefabs updating them is worth the money alone if your a full time Unity developer.

    2. Matt Ellis (JetBrains)

      8月 15, 2019 3:57 pm 返信

      As I replied to Mahdi below, there is some processing that happens the first time a project is loaded, but once this completes, it shouldn’t be causing CPU issues. If you’re still seeing them, please let us know at support@jetbrains.com, as we definitely want to address any performance issues.

    3. Matt Ellis (JetBrains)

      8月 15, 2019 4:03 pm 返信

      As I mentioned in my reply to Mahdi, there are a couple of processes that run the first time you open a project, but once these complete, there shouldn’t be any other CPU issues. We don’t have any reports of sluggish scrolling, please could you get in touch with support@jetbrains.com to provide some more details? This isn’t the performance we see when using the tool ourselves, so we’d very much like to understand what’s happening here.

    4. Matt Ellis (JetBrains)

      8月 15, 2019 4:04 pm 返信

      Ah, the old “looks like you’ve just lost your reply, but really it’s just delayed” double post :)

  21. Looks like it has a couple good features. $139 seemed a bit steep but I was considering giving it a shot, but then I saw $139 per year? No thanks. Subscription model is quickly becoming a cancer in the software industry.

    1. Jashan Chittesh

      8月 13, 2019 10:56 pm 返信

      It’s actually $139 for the *first* year. Then:
      €111.00/2nd year
      €83.00/3rd year onwards

      Plus, after one year you get a perpetual fallback license … and depending on what you do, there are also free and discounted options.

  22. JetBrains have a licensing policy where if you buy an annual subscription and don’t interrupt the license, you get consecutive year discounts. This makes Rider €83.00 / year from the 3rd year onwards. Not sure if the unity asset version of rider has the same advantage. See the license prices here: https://www.jetbrains.com/store/?fromNavMenu#personal?billing=yearly

    There should be no difference between the official rider and the asset store rider. I have a jetbrains license for all products and the Unity plugin works just like described in the article.

    1. Matt Ellis (JetBrains)

      8月 15, 2019 3:32 pm 返信

      Hi Alex. You’re correct, there’s no difference between getting Rider from the Asset Store or through the JetBrains site. Yearly discounts apply just the same.

  23. I watched the 28 minutes “Faster C# Scripting in Unity with JetBrains Rider! – Overview” video on your youtube channel. There is some pretty cool stuff in Rider, many useful features, I can see me having fun with it.

    Unfortunately, I wasn’t able to find a “Community” or “Free” edition. Is there really no free Rider version or is my google-fu just not on point?

    1. Nope, there is no community license. But they can give you free version of the Rider if your are creating an open-source project. Guys from UnityStation, for example, had Rider license for free.

    2. Jashan Chittesh

      8月 13, 2019 10:36 pm 返信

      They do have a few free options and discounts, if you look under “Special Offers”: https://www.jetbrains.com/rider/buy/#discounts?billing=yearly

  24. Unpaid shill time:
    Been using Rider for Unity dev for over 2 years now on macOS — it’s a phenomenal improvement over the free options. Obviously, a paid version SHOULD be better, but this one is well worth it if you or your company can afford it. In my case, it has paid for itself in productivity gains.

    Also worth noting that they treat Unity support as a primary feature — the 3 or so bugs I’ve filed has been responded to within 24 hours and then ultimately fixed.

  25. I started using Rider 2 months ago and It’s the best ide for Unity I’ve ever tried. It has tons of features customized just for Unity editor, it inspects some of unity settings and suggets improvements, scans assets for events that are calling methods and shows that in the ide, when you use color in code it visually shows the color and lots of other utilities like that, it is really amazing and you should try it.

  26. Looks awesome but expensive :(

  27. Looks really nice. Unfortunately the demo version that I tried recently had huge CPU usage in the background while I was working and would make the whole system (8700K) unresponsive at some point. Maybe I’ll give it another chance if they do some optimizations to make the situation a little bit better.

    1. Matt Ellis (JetBrains)

      8月 15, 2019 3:53 pm 返信

      Hi Mahdi. This CPU usage is likely initial indexing and processing, which can take a little while for larger projects, but will settle down once complete. There are actually two processes happening by default – an initial index is built for navigation and caching some useful data (Rider 2019.2 will show the values assigned to serialised fields in your prefabs and scenes), and then a more detailed solution wide analysis.

      The initial index shouldn’t take too long to complete, even for large projects. It usually completes in seconds, but should be no more than a minute or so for a massive project. This index is created once and stored to disk, which makes opening the project much faster in future.

      The solution wide analysis is a deeper scan of your files, which finds more issues than just analysing files individually, and allows seeing all errors in a project without having to compile it first. This initial scan can take a while to complete on larger projects, but once it is complete, it is kept up to date incrementally, which is much more lightweight, and won’t visibly affect CPU. This process can also be disabled from the progress icon in the status bar.

      Normal usage shouldn’t cause excessive CPU usage once these initial processes are complete. If you’re still seeing issues, please let us know (support@jetbrains.com), as we’d love to address this – Rider 2019.2, which was just released had some significant performance improvements scanning Unity prefabs and scenes, for example.