Search Unity

Utilities Script Inspector 3

Discussion in 'Tools In Progress' started by Flipbookee, Aug 10, 2013.

  1. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Si3 doesn't need or use any external software. It relies on Unity's CompilationPipeline API for discovering what script goes into which assembly.
     
  2. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    27
    Wellll... there's always a little something, like the C# 8.0 switch expressions ( as described in https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8#switch-expressions ) that currently result in a cascade of red line, unfortunately also wrecking all syntax analysis for rest of the file. Below is a picture of the Tuple version from Microsoft's page, but the single parameter version fails the same way.

    A colleague loves using the new syntax all over the place, and I'd love my Script Inspector to keep working... is this something I could easily patch up by myself? :)

    upload_2022-6-21_3-6-41.png
     
    Flipbookee likes this.
  3. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Right, those red lines are not good there. I'll fix them, hopefully with the first next release. It won't be something trivial you could do in your local copy. I'll have to add all the grammar rules and the semantic analysis code for switch expressions.
     
    Jouni-Mannonen likes this.
  4. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Just FYI info@flipbookgames.com doesn't work, I've been trying to contact you for a week. Always returns

    This is an automatically generated Delivery Status Notification.

    Delivery to the following recipients failed permanently:

    * info@flipbookgames.com

    Reason: There was an error while attempting to deliver your message with [Subject: "Re: Script Inspector Error"] to info@flipbookgames.com. MTA p3plibsmtp02-01.prod.phx3.secureserver.net received this response from the destination host IP - DNSFAIL - ?? , ??.
     
    Flipbookee likes this.
  5. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    In Unity 2021.3.4 and SI v3.0.33, when switching between Windows standalone and WebGL platforms, I get a console error which prevents builds from working until editor restart. Any advice? Thanks!

    The asset at Assets/Plugins/Editor/ScriptInspector3/EditorResources/Smooth Fonts/Inconsolata.otf has been scheduled for reimport during the Refresh loop and Loading of it has been attempted.
    Doing this can lead to the AssetDatabase returning two versions of the same asset.
    Please ensure that code which attempts to reimport this asset does not run while the editor is Refreshing.
    You can do so by checking the value of EditorApplication.isUpdating
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
     
    Flipbookee likes this.
  6. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Thanks! I asked my friend to check what broke that (I have no idea how to fix that).

    This has been reported earlier but without repro steps. Thanks so much, this should help me track down the issue...
     
    Graham-B likes this.
  7. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Okay, so I did quite some progress on code folding, but it's a complex feature and it needs to be done very carefully. It also requires a lot of strong willpower to stay focused on that only...

    And my willpower was challenged by some little things in Si3 that I didn't like, like those few seconds it takes to reinitialize itself on reloading the assemblies.

    So I started doing some profiling again and optimizations in that area of the code... but... Using the Unity Profiler window wasn't really fun...

    So I decided to make profiling in Unity a little more fun and enjoyable, and this is what I got :)

    Profiler-to-Si3.gif

    I got tired of finding the methods listed in the profiler and decided to "fix" that - now I can simply double-click on a method name in the Profiler and Si3 goes straight to it :cool:

    What do you think? Shall I keep this for myself only or release it and share it with everyone else?
     
  8. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527

    This is too much power for its mere mortals ... keep it for yourself!
    haha

    Kidding aside, this actually looks really useful !
     
    Flipbookee likes this.
  9. VEWO

    VEWO

    Joined:
    Sep 30, 2014
    Posts:
    8
    The editor seems unable to resolve the types of implicit delegate parameters. For example (using EventBasedNetListener from LiteNetLib)

    Code (CSharp):
    1. var udpListener = new EventBasedNetListener();
    2. udpListener.ConnectionRequestEvent += (request) => request.Reject();
    The editor won't recognize .Reject() unless you explicitly supply the type:

    Code (CSharp):
    1. var udpListener = new EventBasedNetListener();
    2. udpListener.ConnectionRequestEvent += (ConnectionRequest request) => request.Reject();
    However, the editor should be aware of the type, because when you hover the mouse over .ConnectionRequestEvent you can see a popup with the parameter info.
     
    Flipbookee likes this.
  10. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Okay, I see... That used to work fine, but it seems like it stopped for some reason. Thanks for reporting, I'll fix that!
     
  11. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Right, that was an easy fix, but not trivial enough to allow me to post the fix here. So I'll try to release this ASAP.

    Thanks again for reporting the issue!
     
    VEWO likes this.
  12. JVemon

    JVemon

    Joined:
    Jul 30, 2017
    Posts:
    18
    Just a few nitpicks:

    1. It would seem the editor doesn't immediately consume the indentation level after single-statement conditionals:



    However it corrects itself as soon as you type anything. I think it'd be more intuitive if it immediately dropped.

    2. The same more or less occurs with switch cases, except that it does consume the indentation level (when it shouldn't):



    3. Speaking of switches, it seems the editor's enforced format is as follows:



    Which is fine, as I recall Visual Studio doing that like a decade ago. However, nowadays I think by default it actually indents the cases as such:



    Is there a setting to change how indentation works for cases like that?

    4. In the Visual Studio screenshot I posted above, those dotted lines are rather helpful to identify blocks. I think that could be a nice addition to this editor.

    Thanks for the good work.
     
    Flipbookee likes this.
  13. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Thank you for all these good suggestions!

    The dotted lines were suggested recently and I tried to add them thinking it must be a trivial task, but quickly I realized I was wrong. But it will be much easier to add these lines once the code folding feature is implemented. And I started working on code folding recently, so the lines should code with that at the same time.

    Improving the auto-indent feature is another task that’s been near the top of my to-do list, and your notes above will come very handy when I do that. :)
     
  14. JVemon

    JVemon

    Joined:
    Jul 30, 2017
    Posts:
    18
    Ah. It seems the editor is keeping files in memory even after closing their tabs.

    I was working on a file with SI3, then needed to edit that file in Visual Studio for a moment (I wanted to use their automatic interface implementation feature for a rather large interface). When I came back to SI3, the file was not updating with the changes. Closing the tab and re-opening didn't reflect the changes either, so I had to restart Unity.

    Is there a setting to change this behaviour, so that opening a script is done directly from the file instead of using whatever is cached in memory? Or maybe a feature to refresh the tab.
     
    Flipbookee likes this.
  15. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    That sounds like a bug, and I suspect the same happened to me yesterday. I'm quite sure this used to work fine in older versions of Unity - Si3 detects the changes made externally and it auto-refreshes its content if there are no changes made in Si3 and Unity, or when there are such changes it asks which version to keep, that in memory or to refresh it from the file.

    My version of Unity was 2021.3.1, what is yours? I'll check what has changed and I'll fix this.
     
  16. JVemon

    JVemon

    Joined:
    Jul 30, 2017
    Posts:
    18
    Ah, sorry; I forgot I always disable auto-refresh, so the solution is to cmd+R.
     
    Flipbookee likes this.
  17. d3eds

    d3eds

    Joined:
    Jul 17, 2022
    Posts:
    53
    Just share it with me. Not even you deserve this kind of power ;)
     
    Flipbookee likes this.
  18. JVemon

    JVemon

    Joined:
    Jul 30, 2017
    Posts:
    18
    It seems there is no autocompletion when using null conditionals, e.g.



    Unity 2022.1.7f1.
     
    Flipbookee likes this.
  19. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Whoops, sorry about that. :oops: I’ll fix it!
     
  20. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Haha that’s a good one!

    This is now my favorite feature in Si3. It’s also too addictive, and I hooked up to it. I’ve been optimizing Si3 code and the iterations are so quick now. As a result, some parts of the Si3 code are now 20 times faster (yeah, 20, not a typo) and in general I managed to reduce some long operations to 40% of the time they needed to complete before. Memory consumption also went down by more than 50%…

    I don’t even know how I lived without this by now :cool:
     
    d3eds likes this.
  21. d3eds

    d3eds

    Joined:
    Jul 17, 2022
    Posts:
    53
    I'll happily let you be my dealer of this new drug. Addict me!
     
    Flipbookee likes this.
  22. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Hello, I got this question asked on VS many times, about "Miscellaneous Files", so how to resolve that in this tool ?
     
  23. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    I’m confused… What is the question exactly?
     
  24. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    I deleted the error causing script and everything works now.
    But I find it hard to switch from Visual studio, in that tool everytime I press F12 to go to script file, it is instantly, but Script inspector show this for like 10 secs each time I do that, which is too slow.
    upload_2022-9-4_16-30-3.png
     
  25. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    this only happen the first time for every class to find, I guess the SI3 need to find the cs script in the project.
     
  26. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Yes, it needs to find the script and then parse it, only the first time. That's because Si3 loads and parses scripts only when it has to do that, while VS does that for all scripts on loading a project and keeps doing that in the background until it does that with all the source code files.

    But I agree, 10 seconds is way too long! It shouldn't be that long, and I'm quite sure I've improved that tremendously with my recent optimizations which I'm preparing for the next release. With these changes, Si3 will be at least 4 times faster and use about 5 times less memory. Go to Definition with F12 performs several chained and some nested lengthy operations, so the speed improvement there will be even more than 4 times faster, I believe.
     
  27. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Hi a suggestion : instead of parse it every first time we hit F12, instead do it in the background for all the class in a currently inspected script ?
     
    Flipbookee likes this.
  28. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Right, that could be a solution. But I’ll first check what I can do for its current implementation - I’m doing that right now, actually.
     
    Spikebor likes this.
  29. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Thanks, looking forward for next update :p
     
    Flipbookee likes this.
  30. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    hi @Flipbookee , one of the most used feature when I'm coding is "Find all references". This does not work right in SI3. Like for example I make a unique public void Update(Vector3 position, Quaternion rotation) function, but when using "Find all references" the tool will try to find all the Update functions in project, like Update() (without any params). It's not correct and slow.
     
    Flipbookee likes this.
  31. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    @Spikebor, yes. If it isn’t a private method, it has to first find all the Update words in all scripts that may call that method. Then it resolves each of those words to see whether they reference the same Update method or something else. If it’s referencing something else then that instance of the word gets discarded, and otherwise it will be kept and shown in the list.

    Now yes, the list shows references to overloaded methods as well, and if it is a virtual method also the overridden and overriding methods. There are toolbar buttons in the list to filter those out if you don’t need them…

    So you see, all instances of the word Update need to be found and then resolved to decide whether that’s a reference to the same method or not. Resolving the symbol is the most expensive operation there as to do that a bunch of other symbols within the same script need to be resolved as well. And that’s the part I said I optimized and it’s at least 4 times faster in my work-in-progress version, so that’s going to be much faster in the next release.

    After you reported this, I also optimized the word-searching part and it’s about 3 times faster now.

    Anyway, thanks for the feedback! It’s very useful for me to know what you like or don’t like, as that’s the only way to make this better.

    I have a longer-term plan how to make find all references work instantly, so yeah, for now these optimizations will be good enough, I hope.
     
  32. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,442
    I took some time away from Unity but now upon returning, I am looking for a quick way to highlighting and opening the first non-LogType.Log entry.

    I didn't see one, so I sketched up this extra method in FGConsole:


    Before I dive in and try to figure out how to achieve the two highlighted lines, I wanted to see if I was missing something that already existed.
     
    Flipbookee likes this.
  33. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    281
    Thanks for listening to feedbacks, you're awesome.
     
    Flipbookee likes this.
  34. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    That would be a super-nice feature to have!

    No, there’s nothing like that in Si3, and I think not even in Unity API, so we’d have to use Reflection to achieve that.
     
  35. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    :rolleyes:
     
  36. Lemexis

    Lemexis

    Joined:
    Apr 14, 2014
    Posts:
    3
    Hello,

    I just started using Script Inspector 3 and it's really awesome, thanks a lot for what you did!

    I just had a few question about the features, hopefully I won't phrase them too poorly, I'm still new to this whole programming thing:

    - Is there a way to rename all references to a variable at the same time, like "rename symbol" in VS Code ?
    - Is there a way to make it so that pressing "Tab" while inside quotes, brackets, etc... lets you "get out" of that?
    So, if I write Debug.Log("test"); and the cursor is between " and ) then pressing tab once would put it between ) and ; pressing a second time would be it after ;
    If that's unclear, there is an extension in VS Code that does exactly that : "TabOut"

    If they're not there already, I feel like these two options would make it a much smoother experience.
     
    Flipbookee likes this.
  37. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    :rolleyes:

    Currently no, but that's being worked on. There is a command to find all references and a command to replace all occurrences of some text, so I have to combine these two into one command called Rename Symbol.

    That sounds interesting, I'll check that out. Thanks for sharing this suggestion!
     
    Lemexis likes this.
  38. FcsVorfeed

    FcsVorfeed

    Joined:
    Aug 15, 2014
    Posts:
    50
    hi!when I use F12(Go To Definition) is very very slow!!!
    It alway need to wait about 10 sec time

    [Waiting for unity's code in UnityEditor.CoreModule.dll to finish executing]
     
    Flipbookee likes this.
  39. nitz

    nitz

    Joined:
    May 4, 2011
    Posts:
    54
    Hi Flipbookee, I know you added support for C# 8 in 3.0, but was curious as to when you may be looking at adding support for some newer features. For example, I have C# 9 record types, and the record keyword or positional properties causes cascading parsing errors.

    I was also curious as if you've got some sort of publicly available tracker (trello board, github issues, etc.) for things that are on your list/aware of? I read through the most recent posts here but didn't dig considerably far back to see if my question had already been asked.

    Cheers
     
    Flipbookee likes this.
  40. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Yes, I know about that, but it isn't "always". It may be slow the first time you go to the definition of certain symbols because Si3 doesn't load and parse all the code on loading as for example VS would do that. That's one of the reasons why Si3 lets us edit the code immediately, but the drawback is that it will spend some time finding the definition when we use that command for the first time... This will be much, much faster in the next release as I have optimized a lot of the code related to finding definitions and finding references to a symbol.
     
  41. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Uh, record types are not supported yet. C# 8.0 is not fully supported yet as well, only some parts of it are, and more will be supported with the next release. Record types might the next thing I could look at after that, or at least I could do something to eliminate the cascading errors until they are fully supported.

    I don't have a public issue tracker, only my internal simple to-do list ordered by priority. ¯\_(ツ)_/¯
     
  42. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,442
    Now add breakpoints and single-stepping! ;)
     
    Flipbookee likes this.
  43. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,442
    Actually, more seriously, where would be the best place to inject some kind of hook which can revise code on Load and just before Save ?

    For a load hook, I would like to convert tabs to spaces on every line.
    For a save hook, I would like to remove any trailing whitespace on every line.

    Those using good version control software can do that with pre-commit scripts, but I think it would be nice to have such features in the editor itself. It's pretty convenient to do that sort of thing in Sublime Text or Emacs, for example.
     
    Flipbookee likes this.
  44. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Ah right, that would be a really useful feature! Let me see what I can do, it should be easy enough…

    I can’t do that now. I started adding code folding and it turned out to be a really complicated feature. I have it mostly working now, only some details are still missing, but it took me a lot of time to get here. I think I could have added debugging much faster than implementing this.
     
  45. Minzie

    Minzie

    Joined:
    Jul 26, 2019
    Posts:
    77
    Hi @Flipbookee. When I tried to use cinemachine namespace, there's error to it. Could you please check if this is a bug?
    upload_2022-10-24_0-6-57.png
    upload_2022-10-24_0-7-46.png
     
    Flipbookee likes this.
  46. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    Thanks for reporting this issue! I’ll check…

    Can you just tell me did the issue go away after compiling or it’s still there?
     
  47. Minzie

    Minzie

    Joined:
    Jul 26, 2019
    Posts:
    77
    No, it's still there.. I've deleted Library, restart Unity Editor & even my laptop. Also tick all "generate all csproj" from the preference->external tool tab.. All still same.. I also have same issue with VS code community 2022.. :(
     
    Flipbookee likes this.
  48. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    I see… Thanks for the info - I’ll check this ASAP!
     
    Minzie likes this.
  49. Minzie

    Minzie

    Joined:
    Jul 26, 2019
    Posts:
    77
    I've been uninstalling & reinstalling VS community 2022 and also SI3 from package manager but the issue still persists. Whenever I amend the current script, Cinemachine is not recognized. However, it works if I create new script. I don't know why.. sigh.. Currently, I'm gonna use new script as the workaround..

    Btw, I'm new in coding & I really like SI3, but it sometimes quite slow in compiling. Hope you can improve this :) I hope I can uninstall VS in future cos it's eating too much of my disk space :confused:. Thanks for your checking anyway
     
    Flipbookee likes this.
  50. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,796
    @Minzie, I cannot reproduce this issue. It works fine for me. I created a new project, imported Si3 into it, and then I installed the Cinemachine package using the Package Manager. After that, I added a new script and tried to use some of the types from the Cinemachine namespace - all works fine for me. What else should I try to do to break it?

    Does your project compile without errors even though Si3 is showing errors related to Cinemachine in those scripts?

    Could you send me your project or another new almost empty project where this error appears? I'd really have to make the issue happen on my computer to be able to fix it if this is a bug in Si3. There's no other way to fix something like that, so I'd appreciate very much your help with this.