Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Utilities Script Inspector 3

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

  1. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    That sounds like Si3 didn't install at all which can happen if there were compile errors before importing Si3. Please check your console for compile errors and fix them. Once that's fixed Unity will compile the scripts and Si3 will start working. Then the whole content of the readme file will be visible in the Inspector or you can double-click it and it will open in a new Si3 tab, with word-wrap, of course, so you can read it without scrolling left and right as in MonoDevelop. ;)
     
  2. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
  3. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    851
    I imported SI3 into another project, and it is working as intended so far.

    I do have Console Enhanced. Is there a known conflict?

    In any event, so far so good. I'll let you know if I have any problems.

    Thanks for the excellent customer service.
     
    Flipbookee likes this.
  4. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @wood333 Great then! :)

    I don't know if there's any conflict with Console Enhanced (I don't have that extension). But that's easy to check, just import it along with Si3 in a single project and check the Console for errors. If you see any error then please copy/paste it here and it will be easy for me to fix that.
     
  5. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi,
    through about to buy :)

    1) Would it be possible to change syntax highlighting colors and line spacing? (I need a more clear view and less colors on white back ground)

    Untitled-1.gif

    2) Is a quick format (eg. after code insertion) available?
    3) I'm doing lot of Shader stuff. Would be great to have a script format here too.
    4) I love the feature from VS - Peek Definition ALT+F12. Makes it so easy to access any classes or function from same or another script directly without poor searching. Unbeatable for larger projects. This is the main reason I do not wana change from VS first. Anything in this case available or signed as a feature request?

    Kind regards, Q
     
    Last edited: Feb 16, 2016
    Flipbookee likes this.
  6. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Hey @Quatum1000, thanks for your post!

    That's a nice and clean color theme! Si3 comes with 15 built-in color themes and since the full source code is available, it's possible to modify them or to add your own themes. If you can tell me what is that color theme I can try to replicate it and add it to Si3.

    Automatic code formatting is not implemented yet, but there is automatic indentation and it's automatically triggered on Paste or while typing code. Note that this only works for C# scripts and not yet for shaders or other script types.

    Si3 has a Go To Definition feature for symbols in the same or another script (for the C# scripts only). In addition Si3 can go to "definition" of .Net symbols for which the source code is not available on your local machine, so instead Si3 will open Microsoft's .Net Reference Source. This is Microsoft's original implementation of .Net libraries and not a decompiled source code, so all the comments will be there along with the original names of local variables. Unity uses Mono .Net libraries, which may be slightly different but still close and enough to understand how .Net works internally.

    Go To Definition is bound to F12 on Window. Pressing F12 as the first key after that will move the cursor back to its original position.

    I hope this explanation helps! :)
     
    Quatum1000 likes this.
  7. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Thanks for your answer.

    +I read the full C# source of your project is included? So I thought about to write my format C#/Shader by my own quickly. Is the text accessible line by line as asci format and colorized and un-puzzeling by drawing on screen?
    If so, perhaps it would be possible to reformat the text by my own script, on any key press.

    + Another cool feature would be having images between lines. (like RTF format)
    Sometimes it's a lot better to have a screen shot in the source code that describe why and how a function is implemented.
     
    Flipbookee likes this.
  8. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @Quatum1000, I don't think it will be easy to apply your own formatting function. Yes, each line of text is stored internally as a string, but for the purposes of the editor it's also stored as list of tokens with some additional attributes. Furthermore, those tokens are also used as leaves in the parse tree, which is the used by the semantic analysis to "understand" the code. And that's not all, there's also the Undo/Redo system which needs to be updated and kept in sync with text changes, so I don't think you'll be able to do all that without my help.

    I already have a plan how to do the formatting properly and the whole system was designed since the beginning to support auto-formatting, so please wait for me to do that. ;)

    Displaying inlined images in code is an interesting idea, but not something I'd do any time soon as there are some features that are going to be much more helpful if they are added first... Thanks for the idea!
     
  9. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    @Flipbookee
    Nah ... don't worry. This can be done very easily. Think about copy & paste.

    + I copy plain text into additional array
    + Format text by my script
    + Clear the current text window
    + Call procedure of CTRL+V (insert text)

    If you provide the info how to push the clean text into a string array, and write it back into the same an empty window, then call the same procedure after (paste CTRL+V), then we are done simply. Useful would be also CursorSet (line, colum); That's enough. Format sections or parts is not required.

    I think you have much stuff to code and test.
    If I buy, I will realize in about 1-2 days, not waiting months until is done. I don't want to expect you doing format for shader too. Providing a short info about takes some minutes. Don't get me wrong :)
     
    Last edited: Feb 17, 2016
    Flipbookee likes this.
  10. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Ah, that sounds kind of simple! :) The only thing left would be to set the cursor position after that...

    Let me check the code first. There's a place where I do auto-indent and that might be a nice place to hook that function in. I'll let you know soon!
     
  11. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    If your inlay function send the last known cursor position, then it should be possible for me to determine the new position after format. For sure if there's a chance to set the absolute cursor(ordinate, abscissa) by script after paste. On real tabbing, the abscissa cursor position does not reflect the real screen char position, but can be handled as well.
     
  12. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @Quatum1000, I just sent you all the details about that... Let me know if you run into any problems ;)
     
    Quatum1000 likes this.
  13. Victor_Kallai

    Victor_Kallai

    Joined:
    Mar 5, 2014
    Posts:
    123
    @Flipbookee

    Hey man, I found a weird bug when I write something like
    Code (CSharp):
    1. myGameObject.GetComponent<MyInterface>().ToString();
    the ToString() method gets underlined like it's an error. But when I open MyInterface in SI3 the underline disappears until the next reload. It's not an important issue, I just thought it worth a mention. Cheers!
     
    Flipbookee likes this.
  14. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @Victor_Kallai, that's a beautiful find! :D I just checked, it works exactly as you described. Seems like Si3 doesn't import interfaces correctly through Reflection. It should import them so that they are ultimately extending the System.Object type, and that's where ToString() comes from. Once the interface is "reimported" from the actual source code then the connection to System.Object is correct... It should be a tiny fix ;)

    I've been checking and fixing these days similar issues and I fixed some rare imperfections like the one you described, but I missed this particular issue. Great find! Thanks man!
     
    Victor_Kallai likes this.
  15. FireMutant

    FireMutant

    Joined:
    Sep 2, 2013
    Posts:
    49
    @Flipbookee, Alright, I blame you for my withdrawals waiting for the next version of SI3. :D You spoiled us releasing new versions with new features so often, and now that it's been 2 months since the last release, I'm not able to focus. ;)

    Not that the current version of SI3 doesn't have everything I need, but who doesn't love new toys?
     
    Flipbookee likes this.
  16. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    @FireMutant haha, nice excuse ;)

    Currently there are no critical bugs in Si3 which makes me breathe easier. That was the reason I took a bit larger task, to make resolving of expressions in Si3 respect all the related rules as they are defined by C# language specification. It's a bit more complex task than what I expected in the beginning, so it takes time. First I have to study all the details then implement that in my code, and then make sure it works as it should. And there are pages and pages defining all those rules with many special cases! I got to go through all of them...

    On top of that the amount of time I had to spend at my real job has increased dramatically in the last month. We are pushing hard these days to fix the last few bugs and get Hitman ready for the release. And since that's the job that pays my bills and inherently finance production of Si3, the priority is obviously to finish that first so that there will be a bit more relaxed time later to pimp Si3 up :cool:

    All that doesn't mean Si3 is getting forgotten! I still find a little bit of time to work on it, just now it's going a little bit slower... And I'm sure you guys will understand that, what needs to be done - needs to be done, and there's no way around it.

    Hitman is getting released this Friday, so there will be plenty of time for Si3 after that! :cool: Let me just say also that I really appreciate that you are looking forward to future improvements. Thanks for that! :D
     
    Victor_Kallai and FireMutant like this.
  17. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    There was an issue in resolving generic method invocation with no parameters like in your example, but I fixed it! :D I've also fixed a couple of interface related issues, so that case works now both for auto-completions and resolving. I think the next update will give a rock solid experience and richer code insights than ever before :cool:
     
  18. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    373
    Hey, do you have any rough ETA when the debugging or class searching could be in?
    Not exact date, just rough estimate.

    Thanks!
     
    Flipbookee likes this.
  19. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Hey @Wrymnn, I hope to get the debugging after a couple of months. Not because it takes that long, but because there are still some higher priority task to be finished before that.

    What do you exactly mean by class searching? If you mean to be able to go to definition of a class by typing its name then that's easy and I plan to add that very soon. For now we can search for script names, but also there are other ways to find the definition of a type or any other symbol, for example by using the Go To Definition or Find All References.
     
  20. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    373
    Thanks.
    Yes, by go to class I mean ctrl + . on visual studio shortcut, which is essential once tou get used to it. I just wouldnt be able to jump from code to code without it.
     
    Flipbookee likes this.
  21. Victor_Kallai

    Victor_Kallai

    Joined:
    Mar 5, 2014
    Posts:
    123
    @Flipbookee Hello, another bug, TotalSeconds gets red underlined
    Code (CSharp):
    1.  
    2.     System.DateTime epochStart = new System.DateTime(1970, 1, 1, 0, 0, 0, System.DateTimeKind.Utc);
    3.     private int getTime { get{ return (int)(DateTime.UtcNow - epochStart).TotalSeconds;} }
    4.  
     
    Flipbookee likes this.
  22. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Yes, this is fixed now. The DateTime class defines a custom subtraction operator that takes two arguments of type DateTime and returns a TimeSpan. In your example TotalSeconds is a member of TimeSpan type, but Si3 doesn't "understand" the type of the expression preceding that. So far Si3 wasn't taking into account custom operators, but now it does ("now" as in my unreleased work in progress version 3.1 ;)).
     
  23. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Okay, I guess I understand what you mean, but I don't get anything like that on Ctrl+. in my Visual Studio. Is that maybe a ReSharper shortcut?
     
  24. Wrymnn

    Wrymnn

    Joined:
    Sep 24, 2014
    Posts:
    373
    Sorry, my mistake, it is LCtrl + , (comma)

    Only class list would be enough, not needed all methods and variables. That is useless anyway in most cases. Just classes. Because searching through folders for class I know name of does really take long time.
     
  25. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    Seem to be having the following issue with a new project on Windows with Unity 5.4.0b10:

    GetString is not allowed to be called from a MonoBehaviour constructor, call it in Awake or Start instead. Called from script 'FGCodeWindow' on game object ''.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEditor.EditorPrefs:GetString(String, String)
    ScriptInspector.FGCodeWindow:.cctor() (at Assets/Plugins/Editor/ScriptInspector3/Scripts/FGCodeWindow.cs:244)
     
  26. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Are you using the latest version of Si3? If not just update from the Asset Store and the issue should go away. ;)

    This was fixed in the latest version as noted in the release notes:
    But let me know if the issue persists after updating Si3...
     
  27. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I agree class, struct and interfaces would be enough.

    @Flipbookee If you will plan to add also methods, properties and fields consider to make it optional, because often the result is too crowded of useless results.

    Cmd+. is on Monodevelop on OSX and is probably the feature that I miss the most on SI3.
     
    Flipbookee likes this.
  28. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    I just pulled it from the AssetStore this morning (purchased it yesterday), so I believe the issue still persists.
     
    Flipbookee likes this.
  29. huulong

    huulong

    Joined:
    Jul 1, 2013
    Posts:
    224
    Hi! An improvement suggestion here.

    I realized the "Open Call-Stack Entries in Script Inspector" option only works for deeper call-stack entries (using right-click on an SI Console log entry), not for the 1st level call (double-clicking on the entry or pressing enter always opens the SI Code Editor. I use SI to access call stack code whenever I want but sometimes accessing the 1st level is enough for me, and I prefer working inside my external code editor.

    I tweaked FGConsole.cs a bit to let it behave the way I want (when the Call-Stack option is checked, always open in external editor). Since SI is a paid asset I cannot just upload the fixed script here, but if you are interested, I can send you (the asset's developer) my changes in private or just paste the lines I modified (nothing too crazy, really). I basically copied code from the pop-up menu and replaced the double-click normal behavior with that, plus a few tweaks.

    On this thread you suggested to open the file in the SI editor then press ctrl+enter but since I do this a lot for debugging I think this patch could help developers more interested in the call-stack feature than in the integrated editor (even though it means they use a small part of the paid product).
     
    Flipbookee likes this.
  30. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Oh, I see. I'll check that! I haven't had a chance to download the beta yet, but I'll do that now... Thanks for the heads up!
     
  31. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    That reminds me... Shortcuts CTRL+UP? and CTRL+DOWN? for going up and down in the call stack! When entering the call stack it should remember what level I'm on and these shortcuts should go up and down a layer so I can swiftly navigate the entire call stack.
     
    Flipbookee likes this.
  32. koblavi

    koblavi

    Joined:
    Oct 1, 2010
    Posts:
    52
    3 months and counting .... :)
     
  33. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Yeah man, I know... I'm still struggling to find enough time for finishing all the recent changes. The big one (operator handling) require a longer continuous chunk of time. And I wasn't able to get that with all the things happening recently.

    Working on small incremental improvements previously was working much better for me, so I think I'll have to switch back to that mode once I'm done with this release. Till then, I'm appreciating your patience and I'm really glad to hear you guys are still caring and expecting this update! Thank you all for your support :)
     
    Victor_Kallai likes this.
  34. Jouni-Mannonen

    Jouni-Mannonen

    Joined:
    Nov 23, 2015
    Posts:
    27
    I just bought SI3 half an hour ago and was very pleased to see that Visual Studio + VA X was included in the optional color schemes. :)

    However, I quickly found that the page up and page down keys behave differently from VS; on Visual Studio the physical screen position of the line you're on remains the same (if possible) by scrolling the screen exactly one page up or down, while in SI3 the scroll is "pushed" leaving you either on the very bottom line or the top line of the screen, which is bad because you a) lose visibility to code around the line you're on and b) pagedown + pageup takes you back to the line you were on but at a different scroll position, making it very disorienting if you want to just look around.

    However... since the code came with the source code, I quickly remedied this for myself. I suspect this might be a desirable option for many VS users to have, so please consider adding it in.

    All I had to do was add
    Code (CSharp):
    1. scrollPositionLine -= (int) (codeViewRect.height / charSize.y);
    around line 7608 of FGTextEditor.cs and a respective addition to pagedown and everything works as I hoped it would. Cheers!
     
    Flipbookee likes this.
  35. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    @Flipbookee I don't remember if something similar was already notified in the forum. Probably yes about extension methods. But in case not I post it.

    I have this extension method:
    Code (CSharp):
    1.  
    2. public static void Despawn(this SpawnPool sp, Transform instance, Func<Transform, bool> checkFn, float interval = 1f)
    that I call this way:
    Code (CSharp):
    1.  
    2. _spawnPool.Despawn(xpBonusTr, DespawnCheck, 5f);
    3.  
    The Despawn method is underlined and the tooltip says "Unresolved method overload".
    The SpawnPool class has more Despawn methods with different arguments.
     
  36. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    I know about this issue and it needs to be fixed. The reason is that DespawnCheck used as an argument is not properly resolved, which then breaks the method overload resolution for Despawn method call.

    I know how to fix this, but it isn't a small fix. That's why this hasn't been fixed so far...

    Alternatively, you could rewrite that line as:
    Code (csharp):
    1. _spawnPool.Despawn(xpBonusTr, t => DespawnCheck(t), 5f);
    If I remember well, this is also what Resharper's heap allocations plugin was suggesting to do to avoid heap allocations! In your code example the compiler will have to implicitly allocate a delegate pointing to DespawnCheck, while in mine that delegate will get allocated only once and cached in a hidden member variable. I didn't get the reasoning behind that, but it might be also something specific to Microsoft .Net and it doesn't necessarily have to be true for Mono .Net, so we'll have to check that by looking at the compiled assembly.
     
  37. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Thank you very much for your feedback. It's a pity that a simpler form is causing again more allocation (similar to the foreach in Unity). I'll have to change it in many many places :confused:
     
    Flipbookee likes this.
  38. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Yeah, I just checked this in Unity and it's true! I was suspecting that Mono implementation might be a bit different than Microsoft's .Net, but it isn't.

    This is the code I was using for the test:
    Code (csharp):
    1. using UnityEditor;
    2. using System;
    3.  
    4. public class TestDelegates
    5. {
    6.     [MenuItem("Test/Test 1")]
    7.     static void Test1()
    8.     {
    9.         for (int i = 0; i < 100000; i++) {
    10.             DoTest(DoNothing);
    11.         }
    12.     }
    13.    
    14.     [MenuItem("Test/Test 2")]
    15.     static void Test2()
    16.     {
    17.         for (int i = 0; i < 100000; i++) {
    18.             DoTest(() => DoNothing());
    19.         }
    20.     }
    21.    
    22.     static void DoTest(Action a)
    23.     {
    24.         a();
    25.     }
    26.    
    27.     static void DoNothing()
    28.     {
    29.        
    30.     }
    31. }
    Running Test1() takes 40ms and allocates about 10 Mb of heap memory each time!!!

    Running Test2() takes 30 ms and allocates 104 bytes only the first time and then doesn't allocate anything more since the instance of the delegate is cached :cool:

    So yeah, you'll have to go and change it in many many places ;)
     
    mcmorry likes this.
  39. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Wow thank you so much for double checking it!
     
  40. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Code (CSharp):
    1.  
    2. [MenuItem("Test/Test 3")]
    3. static void Test3()
    4. {
    5.     Action myAction = DoNothing;
    6.     for (int i = 0; i < 100000; i++) {
    7.         DoTest(myAction);
    8.     }
    9. }
    10.  
    This supports edit and continue
     
    Flipbookee and mcmorry like this.
  41. grimmy

    grimmy

    Joined:
    Feb 2, 2009
    Posts:
    409
    It's probably been asked a million times, but what are the chances of getting a function list for si3? Some of my scripts are pretty long and it would be great to see all my functions listed down the side that i can click on for easy access.
     
    Flipbookee and Jimww like this.
  42. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    Another useful feature might be to allow easy navigation from a Debug.Log() line to it's corresponding output within the SI3 Console. Like a right click -> "Find in Log" option, maybe matching just the static text the best that it can.?
     
    Flipbookee likes this.
  43. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Yeah, it's been asked some long time ago, but there is the Code Navigation bar now, so you can always use that. ;) There's also a keyboard shortcut for accessing the last button in the path: Alt+M on Windows and Ctrl-M on OS X.

    That's not exactly same as the feature you're asking for, I know, but it's very close. I guess, a window listing all the methods of the current class might also be useful, so yeah, it will be added.
     
  44. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Ah, very nice!!! :) I'll try that :cool:
     
    Jimww likes this.
  45. koblavi

    koblavi

    Joined:
    Oct 1, 2010
    Posts:
    52
    ... 4 ;):D
    Whatever updates are coming, they better be massive. Don't mind me. We trust you've not abandoned us.
    Small incremental changes is probably a good Idea.
     
    Wrymnn and Flipbookee like this.
  46. Victor_Kallai

    Victor_Kallai

    Joined:
    Mar 5, 2014
    Posts:
    123
    Hey, I know you are busy and everything, but it would be nice to be able to open other kinds of files as text in SI3. Maybe add a list of extensions that you can 'open as text'. I tried to change the code to add more extensions, but it wasn't that easy. Not a priority, just a small nice feature. The files I was trying to open were '.projmods' - config files for iOS building.
     
    Flipbookee likes this.
  47. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    Related to a window that stays open and shows all your methods, it would be nice if you could have an option to reorder the methods in that list and that code was automatically moved. Would help keep things organized. Maybe have other options to copy/paste/comment-out entire methods.

    Related to search, would be nice to have an option to search only for code that is not commented out.
     
    Flipbookee likes this.
  48. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,788
    Well, there is that Rename feature I'm still working on for version 3.1, and you may argue that isn't a huge improvement. The biggest change is barely visible since it's in the code analysis implementation, and that will only be visible when you use some more advanced C# features.

    There are some fixes and a lot of optimizations which are already done and should be easy to isolate, so I'll try to release that as 3.0.13 for now, so you folks don't feel abandoned ;)
     
    FireMutant and Victor_Kallai like this.
  49. Novack

    Novack

    Joined:
    Oct 28, 2009
    Posts:
    844
    Oh please don't generate releases for the sake of psicological amusement. My vote goes to wait for consistent and content-relevant point releases rather than smaller steps of smaller fixes.
     
    Flipbookee and Victor_Kallai like this.
  50. Jimww

    Jimww

    Joined:
    May 14, 2013
    Posts:
    63
    How about when text is highlighted and you type a quotation mark, it automatically wraps it in quotes? I miss that.

    agile development makes sense to me...
     
    Flipbookee and Novack like this.