Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Script Inspector 3

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

  1. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    Would love to! Thanks!
     
  2. poppgames

    poppgames

    Joined:
    Jan 18, 2015
    Posts:
    11
    I believe that I found another bug. I was creating a UI button in Unity. It gives no errors in MonoDevelope, but the Si3 does not recognize it. Is the Unity 4.6.1f1 UI included in the codebase?

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4. using UnityEngine.UI; //Error Here
    5. public class ButtonAction : MonoBehaviour {
    6.  
    7.  
    8.     // Use this for initialization
    9.     void Start () {
    10.  
    11.     }
    12.  
    13.     // Update is called once per frame
    14.     void Update () {
    15.    
    16.        Button b; //Once I typed this, Si3 recognised the namespace
    17.  
    18.     }
    19. }

    Edit: Never Mind. I guess the UI is a nacespace. Once I created a Button, which is part of the UI, the error went away. It might just be a bug, as it does not recognize the namespace in the popup box, until something from the namespace is programmed.

    Edit 2: The first bug occurred because I accidentally make a function with the same name as the class. Hence the parser thought it was a public constructor. Oops.

    Code (CSharp):
    1. public void ButonAction(){
    2.          //Oops
    3. }
     
    Last edited: Jan 24, 2015
  3. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @SpectralRook PM-ed :cool:

    This may have been fixed in Beta 4 WIP version... I'll check, give me a few minutes...
     
  4. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @poppgames I see, this is still not working... It only works after compiling at least one script that's using anything from the UnityEditor.UI namespace. This is happening because the UnityEngine.UI.dll library is not referenced from compiled scripts if there's no need for that, and then Si3 doesn't "see" that this library even exists...

    MD knows the library exists because Unity adds it as a referenced DLL in the solution file... So, I'll have to do something similar... Good catch! ;)
     
  5. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Most of the stuff I wanted to do was "private void" like "ToggleCommentSelection", "Redo", "Undo", etc.
     
  6. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @OnePxl That's easy, I can make those public ;)

    But if you wanna go a bit more fancy add this script in any Editor folder:
    Code (csharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. class RemapKeys
    5. {  
    6.     // menu items with my custom Si3 shortcuts
    7.     const string myUndo = "Si3/Undo _&z";
    8.     const string myRedo = "Si3/Redo _&y";
    9.  
    10.     // default shortcuts recognized by Si3
    11.     const string undo = "#^z";
    12.     const string redo = "#^y";
    13.  
    14.     // all menu items are only valid for Si3 windows
    15.  
    16.     [MenuItem(myUndo, true)] static bool ValidateUndo() { return IsSi3Window(); }
    17.     [MenuItem(myRedo, true)] static bool ValidateRedo() { return IsSi3Window(); }
    18.  
    19.     // my remapping handlers go here:
    20.  
    21.     [MenuItem(myUndo)]
    22.     static void Redo() {
    23.         EditorWindow.focusedWindow.SendEvent(Event.KeyboardEvent(undo));
    24.     }
    25.  
    26.     [MenuItem(myRedo)] static void Undo() {
    27.         EditorWindow.focusedWindow.SendEvent(Event.KeyboardEvent(redo));
    28.     }
    29.  
    30.     static bool IsSi3Window() {
    31.         var wnd = EditorWindow.focusedWindow;
    32.         return wnd is ScriptInspector.FGCodeWindow
    33.             || wnd != null && wnd.GetType().Name == "InspectorWindow";
    34.     }
    35. }
    This example will add Si3/Undo and Si3/Redo menu item with Alt+Z and Alt+Y custom shortcuts. Then the handlers are checking is the active tab a Si3 tab or the Inspector, and if it is they will send a Shift+Ctrl+Z or Shift+Ctrl+Y keyboard event to it. :cool:

    You can change this script to use your own preferred shortcuts. Any keyboard shortcut will work except the ones which are already taken in the main menu (Ctrl+Z and Ctrl+Y for example on Windows are taken). You can also add more remapped shortcuts, just follow the same pattern.

    P.S.: Man, I love Unity! No other game engine would allow me to extend its functionality in only a few lines of code like this! :D
     
    antoripa and OnePxl like this.
  7. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Oh, and, if you aren't sure how to encode the modifier keys just place the cursor on "KeyboardEvent" and press F1 or Ctrl+' :D
     
  8. mStep

    mStep

    Joined:
    Sep 24, 2012
    Posts:
    33
    This looks amazing. Is SI2 compatible with Unity 5, and if not is the SI3 beta?
     
  9. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks! :cool:

    I haven't tried Si2 or Si3 with Unity 5 beta myself, but people say it works there too. I wish I had access to Unity 5 beta but unfortunately that's a bit too expensive piece of software for me given that its only purpose would be to check is SI working there or not. ;)

    Some of the existing users may know better than me... Guys! Anyone?
     
  10. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    Haven't spent much time with Unity 5. Just added the latest SI3 beta to an empty project. Two warnings:

    Not noticing any functional issues.
     
  11. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Ah cool, I knew about this warning, it was reported previously but I couldn't fix it because there was no documentation to see what is the signature of the logMessageReceived delegate. But now, there seems to be a new Unity 5 specific Scripting Reference :cool:
    http://docs.unity3d.com/500/Documentation/ScriptReference/Application-logMessageReceived.html

    It's an easy fix, so @SpectralRook I'll send you a quick update and you'll have to try it and see how that works (since I can't do that without Unity 5). ;)
     
  12. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    Tested. Looks good as of Beta 5.0.0b18 on OS X (Yosemite).
     
    Flipbookee likes this.
  13. mStep

    mStep

    Joined:
    Sep 24, 2012
    Posts:
    33
    Faaantastic, thanks for checkin that out for me. Asset bought!

    Any chance of me getting in on this beta action?
     
  14. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks :) and yes, I'll PM you with instructions ;)
     
  15. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks man! :cool:
     
  16. inventor2010

    inventor2010

    Joined:
    Nov 3, 2010
    Posts:
    124
    Found something:

    In overriding a base classes constructor as below:
    Code (CSharp):
    1. public class BaseClass : object
    2. {
    3.     public object anObject;
    4.     public BaseClass(object aO)
    5.     {
    6.         anObject = aO;
    7.     }
    8. }
    9. public class ChildClass : BaseClass
    10. {
    11.     public object anObject;
    12.     public ChildClass(object aO) : base(aO) // << SI issue here
    13.     {
    14.         //Run base constructor and do some other stuff:
    15.         //...
    16.     }
    17. }
    The values being passed into base are falsely underlined, further, in the naming convention I used, the autocomplete is actually very annoying because it insists on filling in the name of the base classes variables rather than what is being passed into the child class constructor.

    This leads me to a behavior change request: (This is actually something that seems "normal" on most windows IDE's, so your still way up there, but it drives me mad.)

    - Only autocomplete if Enter/Return is clicked, if the user simply continues typing, or hit's space, do NOT autocomplete (perhaps optionally as a setting)... It usually does a very good job, but *occasionally* it's just nowhere near and I'd rather just type.
     
  17. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    I see, there's something missing there... Thanks man, I'll fix it :) and that will also fix the autocomplete.

    Yes, this is a good suggestion! Visual Studio has a similar option where you can define your own set of characters that will "accept" a completion. I'd personally never change the default setting for that option, and I guess you'll keep it at default too if the offered completions are always good, which is my goal so I'll fix that first ;)

    Thanks man! Just keep finding issues and we'll end up with a perfect Si3 very soon! :cool:
     
  18. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    May I ask for the status of extension methods ? I used it extensively and it's quite limited without it :)
     
  19. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @thienhaflash Yeah, me too... There's been some work already done on extension methods, so I'll have to finish that. It shouldn't be too much left. I'll check, I think it was almost working.
     
  20. seldom

    seldom

    Joined:
    Dec 4, 2013
    Posts:
    111
    Hi, I'm working on a tool that generates and draws graphs. One example I made is inheritance-relations between C# types, which look like this:


    I think such graphs could be a well fitting addition to SI3, maybe along with call- and caller-graphs or type-reference graphs or... any kind of relation that your code analyser can provide.

    If you are interested, the attached code shows one way how SI3 could use my tool, without depending on it. I'd be happy to help making this happen.

    edit: here is the backend class I used the the video.
     

    Attached Files:

    Last edited: Feb 5, 2015
    Flipbookee likes this.
  21. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    @seldom : looks promising :) Do you have a plan to do the full graph showing which class is depend on each other and which function is being used by a specific class ?
     
  22. seldom

    seldom

    Joined:
    Dec 4, 2013
    Posts:
    111
    Thank you.
    The example I posted above does show the full class hierarchy, but only from the perspective of one "target" class type. If System.object is uses as target, the graph will contain all classes of the loaded assemblies. That would be hundreds of nodes, impossible to render or layout, so there is a limit of 60 nodes. The graph for System.object looks like this (not very usefull):

    I'm not sure I understand what you mean by "which functions are being used by a specific class": Showing the member methods of a class can be done with reflection, but the really cool stuff, like caller graphs (where does a function get called from?), requires analysis of the code files. Thats Flipbookee's field. I'm just offering my help in case he wants to use my tool for graph drawing.
     
  23. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @seldom Hey man, this looks very cool! I've tried it and it didn't compile at first because TypeUtility class was missing, but I coded it quickly to try the demo, and it works :) So cool!!! :cool:

    The graph window needs some more work but it's a great start! What's your plan, is this going to be a free utility?
     
  24. seldom

    seldom

    Joined:
    Dec 4, 2013
    Posts:
    111
    Cool, I'm glad you like it. And thanks for not stopping for no compiler errors :)
    I've added the utility class now.

    My plan is to sell my tool on the asset store, while still maintaining the feature-complete demo. I put my backend code (classes that control and customize the editor window) under MIT license on github.

    What improvements would you like to see in the graph window?
     
  25. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    apologise if this bug was mentioned ealier but i checked that nulllable type (short version '?') work only partially - SI3 recognize T properties properly but miss Nullable only properties. I guess this in generall problem with generics or im wrong and this is different problem due to shorthand?

    BTW u tested my suggestion like i wrote in my last conversation - compile some script to dll version for better stability? sometime i notice that SI3 lose keyboard hook but only when recomplie due to outside modify. same problem for script change recognize when modified outside. i think this may be fixed by compile to dll AssetPostprocessor and hook related script
     
  26. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Nice :)

    If that's the case then I can provide you with all the support you may need for integration with Si3. =)

    I guess you could polish it a little bit more ;) I think it has some small issues with handling mouse events, and I can help you fix that if you like. It's also using EditorGUI.DrawRect which doesn't work with earlier versions of Unity, and if this is supposed to be integrated with Si3 somehow, I think it should at least work with the lowest version of Unity that Si3 works with, which is currently Unity 4.0, but I also hope to make it work with 3.5. There are some minor visual imperfections which can be easily fixed as well.

    One thing I believe might be very useful for your tool is to optionally have a tree view on the side of the window showing all the nodes in another form, as some people may find that more keyboard friendly or maybe cleaner and more compact.

    Having a text edit field for quick nodes filtering would be very nice! Also an option to draw those circles as icons, I'd see that as a useful feature too. :)
     
  27. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Hey @Breyer, can you post some example code where Nullable types don't work? I'd like to check that...

    I'm not sure I got the second part of your post o_O
     
  28. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    oh sorry then, i mean that when i change something outside of unity in unity project folder then sometime i lose keyboard hook (ctrl+s mean save scene, no save script even if SI window is focused), similar problem with script change detection if i modify them, lets say, in Xamarin Studio. Finally i guess this can be fixed by compiling part of source code to .dll according to unity script reference:

    And i bet this apply to code with keyboard hook as well

    nullable example:

    Code (CSharp):
    1. public class DoubleCurvesEditorWindow : EditorWindow
    2. {
    3. static Keyframe? tmpSavedKeyfr;
    4. void OnGUI()
    5.     {
    6. if(tmpSavedKeyfr.HasValue)
    7.                     curves[l].AddKey(tmpSavedKeyfr.Value);
    8. }
    9. }
     
  29. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    Hi Flipbookee, may have discovered a bug! (sorry for the lengthy silence, I haven't coded anything other than MATLAB for ages...)

    if you are typing "transform.forward" and press autocomplete when you get to "transform.for" it inserts a for loop code snippet, even if "forward" is highlighted in the autocomplete box. "transform.fo" and "transform.forw" both autocomplete correctly.
     
  30. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @Breyer: Oh I see, the shorthand syntax doesn't work! It should be an easy fix... Thanks for finding this! :)

    Ok, so Ctrl+S doesn't work after modifying some assets externally and then switching back to Unity? That's weird. Thanks for explanation! I'll try to repro that, although I don't see how that may be connected to Si3. I can understand getting issues after changing scripts in external IDE, that's kind of related, but I'm pretty sure I've cleared all the bugs with that. And then, I don't see how any of that may be connected to keyboard hook :-S So, I'll need to know your Unity version for the beginning (and maybe Windows), and I'll investigate. Let me know if you find out a reliable repro case.
     
  31. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Haha, nice! :D I see, it only happens if you accept the "forward" completion with the Tab key. Thanks man, I'll fix it!
     
  32. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Fixed! :D

    Fixed! :D

    Time for Beta 4 - final checks, polishing, and clean ups :cool:
     
  33. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    Maybe you could change the name to Beta4-Build n or something, I already got a bunch of Beta4 here at my side and can not determine which one is the lastest ... :)
     
  34. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @thienhaflash: Well, there will be only one Beta 4 and I hope only "release" after that ;)
     
  35. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    SI3 is now pretty ease to work with, all Generics currently works, no more grammar errors everywhere. Congratz man, you did a great job on this !

    Had some minor feedbacks :

    1. Import statements not yet added automatically, specificly
    Code (CSharp):
    1. [InitializeOnLoad]
    does not recognize, I need to manually write imports statements :)

    2. Type inference not yet works for Generics, at least in my test.

    More to come ... :) As a side note, I really really love the current state of SI3, very clean and fast ! Must check out if you haven't ... !!! Thanks a lot, again ! :)
     
  36. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    Got this error today while typing
    Code (CSharp):
    1. if (_defineDrawer == null) _defineDrawer = new vlbGUIList<>(;
     
  37. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks @thienhaflash, I'll fix it :)
     
  38. soneugene

    soneugene

    Joined:
    Sep 17, 2014
    Posts:
    2
    There are currently using.
    However, completion is not operated. When could I use the auto- complete?
    Thank you~
     
  39. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    @Flipbookee

    Sorry for very late answer i was too busy for doing test for ensure that bug still exist on my current version (so this may be fixed on newer) atm i had few free times. There what i figured out:

    - problem with detection sometime happen in one very specific case: if you work on SI3

    - save once (only once this is important!)
    then move to xamarin studio,
    write something (no matter if error-prone or not)
    then return to unity, keep unity focused,
    then unity recompile
    but changes isnt visible

    if i save twice then never saw this problem probably already fixed (i have a bit newer version than version where i recognized this problem) or never existed in this specific case (i dont remember my last test), or happen VERY rare

    I noticed something else though - window with ask for reload should appear for every change outside of SI3? if yes then i could say you that this happened only once for me when i did xx (cca 20) test. if not -then false alarm

    according to hook problem - my current version havent this problem, i remember that i had this problem with first version because, after few scene save instead of script save, i always manually saved script due to no trust to shortcut. Probably thats why i didnt notice fix.


    I'm working on Win7
     
  40. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Hey @soneugene, I'm not sure I understood your question ;) but if you are talking about auto-complete not working in Script Inspector 2 that's because there is no auto-complete function in it. Auto-complete only works in Script Inspector 3 which is still in development and currently in beta. Currently it is in its final phase before it gets released on Asset Store, when it will replace the current version (Script Inspector 2) so you can update for free and use the new auto-complete feature. :)

    It may take about one month before Si3 gets released, but if you can't wait that long you are welcome to join the beta and enjoy it even now. :)

    @Breyer Thanks for the detailed explanation, that makes much more sense now, and yes, I have probably not thought about that possibility - after quick-saving changes with Si3 without compiling and then modifying those files using an external IDE, Si3 will get confused - so I'll check that now and I'll fix it! Thanks for discovering this :)

    I also understand your proposed solution to this issue, so thanks, I'll do that or I'll think of something similar :)

    About the reload window, that behavior is intentional. The "reload" dialog will only ask to reload externally made changes if there were any unsaved changes made in Si3, so you get to choose do you want to keep your changes made in Si3 or to replace those with the changes made externally. If there were no changes made in Si3 then asking to reload external changes would be redundant and annoying, so I've decided to always silently reload those changes in Si3 :cool:
     
  41. seldom

    seldom

    Joined:
    Dec 4, 2013
    Posts:
    111
    I agree, the visuals need more work, they are not my strong suit. That's one of the reasons why node drawing is handled by the backend, where users can customize it :)
    If EditorGUI.DrawRect isn't available in Unity 4.0, I'll get rid of it. What issues did you have with Mouse events and visual imperfections?

    That's beyond the scope of my tool, but it's certainly doable in the backend class. I'm not really sold on the value of it though, the graph can already be drawn as a tree.

    Agreed about the search bar. Icons are only available for a fraction of class types, but why not add them anyway :)
    Here are both in action.
     
  42. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks @thienhaflash! It was a sneaky one, but I fixed it as well :D

    @seldom: Those icons look cool! :) Which inspired me to try this:
    Unity-icons.png
    Isn't that pretty? :)
     
  43. thienhaflash

    thienhaflash

    Joined:
    Jun 16, 2012
    Posts:
    507
    Oup, the icons look very good, man :) Please keep it ! So pretty !
     
    Flipbookee likes this.
  44. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    If there was an award for Unity Editor Wizardry, I would totally win it! :cool:

    TooManyTabs.gif

    I wanted this feature for so long time, but I never got any time for that. Now I needed something to test the Beta 4 with :D
     
  45. The-Spaniard

    The-Spaniard

    Joined:
    Jan 7, 2012
    Posts:
    149
    That looks really awesome!
     
    Flipbookee likes this.
  46. soneugene

    soneugene

    Joined:
    Sep 17, 2014
    Posts:
    2
    Hello.
    SI3 is really awesome!
    What do I need to do to take part in the test ? Thank you.
     
    Flipbookee likes this.
  47. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    Thanks @soneugene, I will send you the details now :)
     
  48. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    Did you checked si3 on u5 beta ? I have weird problem with si after moving to unity 5: eidtor window looks ok but text which represent code inside window is completely collapsed... i see literally one very short line even if script have several hundreds lines...
     
  49. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,389
    @Breyer, no, I didn't have a chance to do that yet, but I was told it works fine. Can you please try to change the font (gear button in the upper right corner) or font size (Ctrl+Plus/Minus or Ctrl+MouseWheel) and see if that changes anything?
     
  50. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    Oh indeed changing font fixed this! I had veramono initially changed this everything looks fine. For curiosity i returned to veramono and collapsing dont return... kinda weird but nvm

    Thanks!