Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Feedback Alt-P is a godsent

Discussion in '2020.1 Beta' started by Thygrrr, Feb 24, 2020.

  1. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    375
    The new "Properties" inspector windows you get with right mouse button or Alt-P are so good.

    Thank you for adding that.

    (Don't try to get properties of an open scene though...)
     
  2. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    298
    For those who don't have the latest Alpha, what is it!? Now you got me all hyped up :p
     
  3. Jichaels

    Jichaels

    Joined:
    Dec 27, 2018
    Posts:
    237
    Woooooooow I didn't know this was a thing, that's really cool !

    @bjarkeck Basically an Inspector popup with every field of the selected asset/object

    upload_2020-2-24_16-17-26.png
     
    SINePrime, Cromfeli, bjarkeck and 3 others like this.
  4. bjarkeck

    bjarkeck

    Joined:
    Oct 26, 2014
    Posts:
    298
    Guys, you are killing me, screenshot! :p

    Edit: Thanks! That is sweet
     
    Last edited: Feb 25, 2020
    Cromfeli likes this.
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah it's brilliant I can't live without this simple change, been recommending it heavily. Unity should shout about it more, makes everything easier.
     
    Thygrrr likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,314
    I can't press alt+P with one hand on my keyboard. I would prefer a shortcut that can be fired single-handed. Having one hand on the mouse to select the asset, using the other to quickly trigger the shortcut.
     
    Stexe, oxysofts, WildStyle69 and 3 others like this.
  7. SINePrime

    SINePrime

    Joined:
    Jan 24, 2019
    Posts:
    54
    Nice, been waiting for UX improvements.

    Can the hotkey be rebound to, say, middle mouse button for instance?
     
    TextusGames and Peter77 like this.
  8. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,966
    Isn't it in the newish keyboard shortcut list?
     
    SINePrime and Peter77 like this.
  9. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    296
    Is this the exact equivalent to what would otherwise be shown in the inspector if you left clicked on the object?
     
  10. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    791
    Hey folks, it's there, its just badly labelled - will find out why and fix. Here I've set mine to just P.

     
  11. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,133
    can this be made toggle-able? now it opens new window every time?
     
  12. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,637
    I like it too, but it makes things a little incoherent. How is it different from the inspector? Is it a single-use inspector?

    As with other minor additions to Unity lately, it feels like some developer woke up one day and said "I'll implement this today", instead of feeling like a part of some vision for Unity.
     
  13. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,966
    @willgoldstone, you could probably link to the preview thread for this. I tried to find it to do that, but couldn't really find it.
     
  14. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    314
    It will be named Focused Inspector. It is indeed a single-use inspector, for those use cases where you need to work on different Assets or GameObjects at the same time and don't want to constantly change your selection to do so.

    We do have plans for deeper workflow improvements but we felt this one would provide immediate value without disrupting existing workflows.

    You can also create a Focused Inspector from the ellipsis menu of a Component.

    Try it out and let us know what you think.
     
  15. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah I can't use alt at all because it's rebound to CTRL on my keyboards. A habit picked up from mac. It's way way more efficient and comfortable to use CTRL if it's next to space :)

    So yeah same for the quick search as well. Would be nice if Unity fix it.
     
    Peter77 likes this.
  16. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    765
    Oh, very interesting. I'm doing something similar for a few years now. I have a simple script that provides pretty much the same functionality for ScriptableObjects (Focussed inspector on the left, my inspector on the right)
    upload_2020-3-6_14-24-32.png

    A few notes from my experience:

    I use double click to open the assets in a new window. This is very accessible and easy to remember, might be an interesting alternative/addition to using a shortcut from a UX perspective.

    Oftentimes, when opening the additional windows, it is so I can easily connect them to one another. The current workflow for the focussed Inspector would be to ping the object in order to have something draggable. In my case, I made a small draggable area in the top left, with which I don't have to do that extra step. Might be interesting to consider as well :)
     
    Last edited: Mar 6, 2020
  17. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,314
    That's a really smart improvement!
     
  18. benoitd_unity

    benoitd_unity

    Unity Technologies

    Joined:
    Jan 2, 2018
    Posts:
    314
    Yes I also like that suggestion, taking note of it.
     
    Peter77 likes this.
  19. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,314
    I guess that would be useful not only for the Focus Inspector, but the regular Inspector as well.
     
    Johannski and benoitd_unity like this.
  20. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    765
    Assetizer.gif
    Totally, that's also what I thought, so I made a simple DraggableAttribute. In the gif you can also see another advantage of the double click: There is no ambiguity whether the game object/ScriptableObject isthe one the Focused Inspector should be for, or the Component itself (This happens for SerializedFields in the normal inspector when using a shortcut).
     
    oxysofts, Jaimi and Peter77 like this.
  21. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Seeing as you posted a picture of it... https://forum.unity.com/threads/editor-hotkey-shortcuts-editor.841693/

    Why can't you click on that hotkey map and have the command panel actually show all shortcuts that are mapped to that selected key(s) -including combo modifiers... it would certainly be useful in seeing what certain keys are being used for.. instead of looking at a giant fff off list things.. because its otherwise useless unless you know command to put in the input filter box. . or make filter box support a hotkey arg -P and it will list the shortcuts mapped to P
     
    JoNax97 likes this.
  22. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    5,751
    I'll rain on your parade with a few small bugs, floater = focused inspector:
    1. Ctrl+W doesn't close the frontmost floater.
    2. ALT+P on the same object keeps spawning new ones instead of bringing forward already opened one
    3. Floaters are created in cascade so we have to move them for inter object connection (and probably most usage).

    improvement:
    1. Double click would be nice but second click is already used to deselect and double click would induce delay in the interaction. So instead double middle click or right click + key modifier = new floater at the cursor. At the cursor gives faster access
    2. In fact there could be a "create floater near cursor" shortcut for fast change and a "create floater next to others" for convenient connection.
    3. Optionally create floaters side by side. Ideally this method should have enough layout intelligence to add the new floater next to the frontmost floater and keep that frontmost floater's size.

    What is this? It sounds like a trigger word from a James Bond.
     

    Attached Files:

  23. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,314
    It usually stands for a series of dots such as ...
    I guess he referred to the three vertically arranged dots button in the upper right area of the inspector.
     
  24. Sangemdoko

    Sangemdoko

    Joined:
    Dec 15, 2013
    Posts:
    183
    Sorry for necroing this thread but I can't find any information about this focused inspector feature in the forum other than here.

    The manual documentation is quite clear on how to open the focused inspector using the short cut and the right-click -> properties. But I can't find how to open that window via code.

    I have a custom inspector and I would like to have a button to open this FocusedInspector window via code. Something similar to what they do in the Peek asset on the Asset Store:

    But I can't find any reference to the FocusedInspector in the API. I assume I will need to use reflection to get a reference to it but I'm not sure what the path I'm supposed to use.

    I'm looking for some function that could simply create the focusedInspector window passing the Unity Object as parameter (I'm mostly going to use it for scriptable objects, but if it works with monobehaviors even better).

    @benoitd_unity could you point me in the right direction for this?
    Thank you
     
  25. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,966
    You need to call PropertyEditor.OpenPropertyEditor.

    But that is of course internal because that's the default for Unity for some reason. So reflection it is!

    Code (csharp):
    1.  
    2.  
    3. private static MethodInfo openPropertyEditorInfo;
    4. private static object[] callOpenBuffer = { null, true };
    5.  
    6. private static bool OpenInPropertyEditor(Object asset) {
    7.     if (openPropertyEditorInfo == null) {
    8.         System.Type propertyEditorType = typeof(Editor).Assembly.GetType("PropertyEditor");;
    9.         openPropertyEditorInfo = propertyEditorType.GetMethod("OpenPropertyEditor", BindingFlags.Static | BindingFlags.NonPublic);
    10.     }
    11.  
    12.     if (openPropertyEditorInfo != null) {
    13.         callOpenBuffer[0] = asset;
    14.         openPropertyEditorInfo.Invoke(null, callOpenBuffer);
    15.         return true;
    16.     }
    17.  
    18.     return false;
    19. }
    20.  
    We're using the above code with [OnOpenAsset] for some asset types, so eg. when you double-click a material in the project view, you get a PropertyWindow for that material, which I feel is pretty neat.

    @benoitd_unity, any chance to change the API so at least the type and the open method are public? I can think of a ton of instances where it'd be nice to open the property editor for some object from a button in a custom editor, but right now it's a bit of a pain.
     
    Last edited: Nov 24, 2021
  26. Sangemdoko

    Sangemdoko

    Joined:
    Dec 15, 2013
    Posts:
    183
    @Baste

    Thank you so much!

    For some odd reason for me
    Code (CSharp):
    1.  typeof(Editor).Assembly.GetType("PropertyEditor");
    returns null, so I had to do this instead:

    Code (CSharp):
    1. var editorAssembly = typeof(Editor).Assembly;
    2. System.Type propertyEditorType = null;
    3. foreach (var typeInfo in editorAssembly.DefinedTypes) {
    4.     if (typeInfo.Name == "PropertyEditor") {
    5.         propertyEditorType = typeInfo.AsType();
    6.     }
    7. }
    Not as elegant but it works great.

    I'm using Unity 2021.1.0f1 btw.
     
    Baste likes this.
  27. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    368
    Fascinating!
    I use an editor extension script to allow the developer to enter values then press generate. The GameObject appears in the hierarchy with out playing. I save the scene and the object persists. We all know this but I need to save those generating parameters like a monoscript attached to a game object does.
    I am thinking I use this script here to capture the values and then somehow stuff them in another script that I attach to the generated GO. I dont think a scriptableObject will work because I need to use the previous values to regenerate the object at some future point which means filling in the script values from some saved data kept somewhere. I am not trying to derail this thread as I know others will get here looking similar answers to this.
    Thank you in advance.
     
  28. giantkilleroverunity3d

    giantkilleroverunity3d

    Joined:
    Feb 28, 2014
    Posts:
    368
    1. private static MethodInfo openPropertyEditorInfo
    MethodInfo does not resolve.
    Needs using statement or assembly reference.
     
  29. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    765
    Nice! I fixed the GetType problem by using the full name identifier (UnityEditor.PropertyEditor) and also specified the method parameters, since an overload of the method was added in 2021.2.

    This script will open all assets (except of folders) in a new EditorProperties Window. I set the callbackOrder to 100, so other scripts can handle the double click first, if there are any.
    Tested with Unity 2020.3 - 2021.2, just add the file inside an Editor folder.

    Code (CSharp):
    1.  
    2. // --------------------------------------------------------------------------------------------------------------------
    3. // <copyright file="OpenPropertiesEditorWindowDoubleClickListener.cs">
    4. //   Copyright (c) 2021 Baste Buanes, Johannes Deml. All rights reserved.
    5. // </copyright>
    6. // <author>
    7. //   Baste Buanes
    8. // </author>
    9. // <author>
    10. //   Johannes Deml
    11. //   public@deml.io
    12. // </author>
    13. // --------------------------------------------------------------------------------------------------------------------
    14.  
    15. using System.Reflection;
    16. using UnityEditor;
    17. using UnityEditor.Callbacks;
    18. using UnityEngine;
    19.  
    20. namespace JD.AssetizerEditor
    21. {
    22.    /// <summary>
    23.    /// Listens <see cref="OnOpenAssetAttribute"/> (order 100) for everything except folders.
    24.    /// Opens the asset in a new window (like an unchangeable inspector).
    25.    /// Forum thread: https://forum.unity.com/threads/alt-p-is-a-godsent.834703/
    26.    /// </summary>
    27.    public static class OpenPropertiesEditorWindowDoubleClickListener
    28.    {
    29.       private static MethodInfo openPropertyEditorInfo;
    30.       private static System.Type[] callTypes = new[] { typeof(Object), typeof(bool) };
    31.       private static object[] callOpenBuffer = { null, true };
    32.  
    33.       /// <summary>
    34.       /// Listens <see cref="OnOpenAssetAttribute"/> (order 100) for everything except folders.
    35.       /// </summary>
    36.       /// <param name="instanceID"><see cref="OnOpenAssetAttribute"/></param>
    37.       /// <param name="line"><see cref="OnOpenAssetAttribute"/></param>
    38.       /// <returns>True if opening the asset is handled</returns>
    39.       [OnOpenAsset(100)]
    40.       private static bool HandleOpenAsset(int instanceID, int line)
    41.       {
    42.          Object obj = EditorUtility.InstanceIDToObject(instanceID);
    43.          if (obj == null)
    44.          {
    45.             return false;
    46.          }
    47.  
    48.          if (IsFolder(obj))
    49.          {
    50.             return false;
    51.          }
    52.  
    53.          return OpenInPropertyEditor(obj);
    54.       }
    55.  
    56.       private static bool IsFolder(Object obj)
    57.       {
    58.          string assetPath = AssetDatabase.GetAssetPath(obj);
    59.          return !string.IsNullOrEmpty(assetPath) && AssetDatabase.IsValidFolder(assetPath);
    60.       }
    61.  
    62.       private static bool OpenInPropertyEditor(Object asset)
    63.       {
    64.          if (openPropertyEditorInfo == null)
    65.          {
    66.             System.Type propertyEditorType = typeof(Editor).Assembly.GetType("UnityEditor.PropertyEditor");
    67.  
    68.             // Get specific method, since there is an overload starting with Unity 2021.2
    69.             openPropertyEditorInfo = propertyEditorType.GetMethod(
    70.                "OpenPropertyEditor",
    71.                BindingFlags.Static | BindingFlags.NonPublic,
    72.                null,
    73.                callTypes,
    74.                null);
    75.          }
    76.  
    77.  
    78.          if (openPropertyEditorInfo != null)
    79.          {
    80.             callOpenBuffer[0] = asset;
    81.             openPropertyEditorInfo.Invoke(null, callOpenBuffer);
    82.             return true;
    83.          }
    84.  
    85.          return false;
    86.       }
    87.    }
    88. }
    89.  
     
  30. Mese

    Mese

    Joined:
    Dec 13, 2015
    Posts:
    32
    It's there a way for this code to not open a new instance of the same window twice, and just bring the first windows forward?