Search Unity

Immediate Window

Discussion in 'General Discussion' started by mathieur, Dec 13, 2018.

  1. mathieur

    mathieur

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    31
    Hello! I just wanted to show a new package I created during a hackweek and see if other Unity devs would think it's useful. It's called Immediate Window and is currently available as a preview package.

    It acts very much like any web browser's developer tools by providing instant feedback on any command lines and allowing you to inspect objects and explore APIs (eg: let's you know quickly what the result of
    Application.dataPath would be ;)

     
  2. I would like to see this built into the console like in the browsers. :)
     
  3. mathieur

    mathieur

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    31
    Indeed! First step to get there is to have it be used and stabilized ;)
     
    Lurking-Ninja likes this.
  4. Sign me up! Good job!

    After a quick spin I have found a couple of things which would make a better experience:
    - move the > button to next to the input box on the right
    - allow me to hit enter when I want to run a command
    - please add a "[type your commands here]" placeholder text, because of Unity's design it's not really showing that it's an input and we can type there
    - please add some tooltip text on buttons (obviously I could figure them out, but still :) )

    Otherwise it's a great tool (obviously mainly in run-time), I love it! Thank you for it!
     
    Last edited by a moderator: Dec 14, 2018
  5. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Urrf I'm really going to have to update my project aren't I :( trying to stay on 2018.2 but all new packages aren't being backported much are they.

    anyway this looks super useful, waste a lot of time adding debug lines>compiling>playing and still debugging code just to find out wtf a value is for some unity method ..exactly like Application.dataPath
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    As of today when trying to do anything in it we get:

    "
    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.ImmediateWindow.Services.Evaluator+<EvaluateSilently>d__36.MoveNext () (at Library/PackageCache/com.unity.immediate-window@0.0.1-preview.5/Editor/Sources/Services/Code/Evaluator.cs:135)
    --- End of stack trace from previous location where exception was thrown ---
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    UnityEditor.ImmediateWindow.Services.Evaluator+<Evaluate>d__35.MoveNext () (at Library/PackageCache/com.unity.immediate-window@0.0.1-preview.5/Editor/Sources/Services/Code/Evaluator.cs:117)
    --- End of stack trace from previous location where exception was thrown ---
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
    UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:111)
    UnityEngine.UnitySynchronizationContext.Exec () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:72)
    UnityEngine.UnitySynchronizationContext.ExecuteTasks () (at C:/buildslave/unity/build/Runtime/Export/UnitySynchronizationContext.cs:93)"
     
    Last edited: Dec 17, 2018
    aaamarkin and Sylmerria like this.
  7. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    There is a weird issue in our project where the fact to trigger a global assemblies recompiling will create an error on your Immediate window assembly and then we are stuck due to the impossibility to activate playmode etc...

    It's the same issue than this one : https://forum.unity.com/threads/cop...mp-to-library-scriptassemblies-failed.533904/ but with ImmediateWindow

    We have to delete scriptAssemblies and packageCache in library. Open Unity again and voila.

    BUT this issue happens only on one computer, on mine with the same project all is fine.
     
    DonLoquacious likes this.
  8. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    @mathieur any news on some update or bug fixes for this package ?
    A collegue found some issues and exepect some improvements so he currently returned on ImmediateWindow that was present on the asset store years ago.
     
  9. FracEdd

    FracEdd

    Joined:
    Aug 25, 2017
    Posts:
    3
    For anyone getting the above Evaluator related null ref. It is caused by some debug code in the package which does GameObject.Find("Main Camera").transform;

    If it can't find that game object then it throws a null ref exception and breaks the initialize process so it's from then on broken.

    To work around it add name a game object in your scene "Main Camera" and restart unity, then try opening it.
     
  10. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    Probably related to Aurelien's issue above...

    Any project that uses the [InitializeOnLoad] attribute and which also accesses assembly information will seem to find themselves with a mountain of errors all stemming from a ReflectionTypeLoadException, but only if the ImmediateWindow package is installed. I'd show an example but it's dead-simple to reproduce- just get the current assemblies and try iterating through the types from an auto-loaded editor script.

    I've tried switching from doing it directly in the static constructor, to events (EditorApplication.delayCall, update (with immediately removing the subscriber when successful), etc), to hackish timed delays, to lazy loading, but it seems like assembly access in Editor extensions simply becomes impossible to manage.

    I know this is a Preview package and support is not really expected for Preview packages, so just tossing this out there as an issue you may want to look into if you guys ever feel like expanding on this module. For now I can't really use it.

    Cheers!
     
  11. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    I was able to fix this by Renaming my camera in the first loaded scene to "Main Camera" If you cannot do that, add a dummy gameObject named Main Camera.
    You have to restart unity for it to work.
    It seems like it wants to access Main Camera on initialization, and if that fails, nothing works.

    Hope that helps!
     
    MadeFromPolygons likes this.
  12. mathieur

    mathieur

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    31
    Yes, finally I was able to release a new version that should fix these issues! :D

    For 2018.3, use com.unity.immediate-window@0.0.1-preview.6
    For 2019.1 use com.unity.immediate-window@1.0.1-preview.1
    For 2019.2 use com.unity.immediate-window@1.1.0-preview.1

    Sorry for all the delay!

    M.
     
  13. DavidSWu

    DavidSWu

    Joined:
    Jun 20, 2016
    Posts:
    183
    Great, thanks!
     
  14. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I like it! Please continue work on it!

    I've only tested a few things off the top of my head, but I can see this working out well to perform some batch-like editor tasks which would otherwise be throwaway scripts and similar things.

    Just some tiny feedback:

    upload_2019-6-26_21-18-19.png

    The menu buttons looks a little squashed and icons are cut off, and the clear icon is not really visible (maybe only with the dark skin).

    Also, when I use the full script mode and insert a tab it inserts 16 spaces. Personally, I'm a fan of tabs, but even if there were two modes for tabs and spaces, I think 16 is too much for a small window. More like 4.

    Resizing the window and scrolling through the list of namespaces is pretty laggy.

    It's probably obvious, but auto-completion would be perfect to top it all off.

    To me this looks like a working solution, since I'm already only complaining about visuals and missing user prefs. :) I'll be using it some more and see if there are any real issues.
     
  15. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I had the immediate window open at edit time, ran some code and then after it was done, performed a regular build of my project. The build failed and now Unity shows the following error, which cannot be cleared:

    Copying assembly from 'Temp/Unity.ImmediateWindow.Editor.dll' to 'Library/ScriptAssemblies/Unity.ImmediateWindow.Editor.dll' failed

    Restarting Unity fixed the issue, but maybe this indicates that something about the generated assemblies is causing trouble when building?
     
  16. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    I just discovered this and I think this has a huge potential.
    I really like to give a try but after installing the latest IW on 2019.1, I get the following error when the Editor starts up.
    I'll appreciate if you can take a look. Thanks.
    upload_2019-7-15_12-35-7.png
     
  17. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    Well, that didn't last long. It looks like it was killed for 2020.
     
  18. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Oh, too bad. Do you recall the source for that info?
    I just tried it in 2019.4.21f1 and even the import of the package fails (sends the CPU into overdrive and never finishes). Had to kill unity, now it crashes at start (reverting package.json fixed it). I assume it's no longer supported (nor tested).

    It seemed to be such a useful tool :-(
     
  19. Well, last submit was 2 years ago: https://github.com/Unity-Technologies/com.unity.immediate-window

    @mathieur may we ask for confirmation/reason why was this killed? Wasn't popular enough?
     
    chrisk and _geo__ like this.
  20. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    Just leaving my vote here that I'm still using the immediate window occasionally and would use it more often if it had some sort of auto-complete/intellisense. I have to admit that I'm basically unable to get stuff done without the IDE telling me what the available API is. I would love to launch the immediate window to write a short one-off script to upgrade multiple prefabs in the project, for example.

    The greatest benefit of using the immediate window, for me, would be workflow speed when running one-off code. Not having to create empty scripts which need to compile first, maybe cutting down on using statements and class definitions, etc. But to make this more productive than going through the regular script and IDE workflow I feel like auto-complete is necessary, at least that's what's keeping me from using it more often currently.
     
    Flipbookee and MadeFromPolygons like this.
  21. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    For runtime use I have been applying a workaround with the VisualStudio Debugger. The Debugger offers an immediate window. Therefore we can can use that if the debugger is connected.

    I think if you set a breakpoint in your editor code you could use it to execute one-off code that way, though it is very cumbersome. One advantage: it offers some auto completion.
     
    Xarbrough likes this.
  22. Flavelius

    Flavelius

    Joined:
    Jul 8, 2012
    Posts:
    945
    This would be an immensely useful tool to have built into unity, as there are a lot of tasks that are repetitive if done manually, but are too one-shot in nature to build a custom editor tool for.
    I just had such a moment and remembered that there used to be this package. I hope this finds its way back into an official integration somehow.
     
  23. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    1,338
    Flavelius likes this.