Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Inspector Gadgets

Discussion in 'Assets and Asset Store' started by Kybernetik, Jun 8, 2019.

  1. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    [Pro] [Lite] [Documentation] [Forum] [mail@kybernetik.com.au]

    Inspector Gadgets enhances various aspects of the Unity Editor to streamline your development workflow.

    Features:

    Enhanced Transform Inspector -> The Inspector for the Transform component has been improved with the ability to Copy, Paste, and Snap individual properties, toggle between Local or World space, adjust the scale on all axes at once, and more.
    transform-inspector-labelled.png

    Draw All Gizmos [Pro-Only] -> Show scene gizmos for every selected object individually instead of using a single gizmo to move them all at once.
    draw-all-gizmos.png

    Movement Guides [Pro-Only] -> While you are moving an object in the scene, Inspector Gadgets will indicate the position you are moving the object from and the distance you have moved it.
    movement-guides.gif

    Auto Hide UI -> Instead of having UI objects block a massive part of your Scene view, Inspector Gadgets can hide them when you aren't working with them and automatically focus the camera on them when you are.
    auto-hide-ui.gif

    Context Menu Functions -> Dozens of useful functions are added to the context menu (right click menu) of each field in the Inspector based on its type. One of these functions allows you to indicate that certain values should persist when you leave Play Mode instead of reverting to their original values.
    persist-after-play-mode.gif

    Continued in the next post.
     
    Last edited: Sep 3, 2020
    Mark_01 likes this.
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    Object Reference Fields [Pro-Only] -> References to UnityEngine.Objects (such as any reference to a GameObject, Component, or any asset) automatically draw buttons to find a reference if they don't have one and can draw the Inspector of the referenced object right beneath the field.
    object-foldout-expanded.png

    Decorator Attributes [Pro-Only] -> Various attributes allow you to customise the way serialized fields are drawn in the Inspector and even add things like buttons.
    decorator-attributes.png

    Find Missing Scripts -> If you have any missing scripts, Inspector Gadgets makes it easy to find and fix them.
    missing-script.png

    Source Code [Pro-Only] -> The full source code of Inspector Gadgets is included as plain C# files with detailed comments so you can see all its internal workings, track down bugs, make any modifications you see fit, and avoid becoming dependant on the developer to fix issues (but feel free to email KybernetikGames@gmail.com or post in this thread if you need support).

    Download it for free and check out the Documentation to get started.
     
    Last edited: Jul 2, 2019
    Grumpy-Dot likes this.
  3. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    @Kybernetik
    Hello, awesome work, I look forward to have the new features.
    I am wondering if you started working on an enhanced inspector for RectTransform.
    I would really appreciate to have the same features we get for simple Transforms, but for UI elements as well, such as being able to reset quickly the position and rotation, copy and snap values easily, and see the global values.
    I was thinking about doing it myself, so if you need my help with the code, let me know.
    Best regards!
     
  4. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    I'm glad you like it.

    A RectTransform Inspector is on my list of things I would like, but I don't plan on actually working on it any time soon. I've looked through the source code of the default one and it's much more complicated than the regular Transform Inspector. If you can get it working without breaking any of the existing functionality I'd be happy to take a look, but I don't work with RectTransforms much so I just don't think the time investment would be worth it.
     
  5. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    @Kybernetik Hello, I have a quick suggestion.

    I've noticed that 'Find in Assets' feature from ObjectDrawer does not work as expected for prefabs with a specific script, as no asset is filled when I press the button, even if there definitely is a prefab in the Assets which has the correct script and which has the same name as the script.

    The issue appears to be in the FindAssetOfType method from InspectorGadgetsUtils, which will only search assets with the correct type, therefore ignoring prefabs which have the required component.
    My suggestion is to first search for a perfect name + type match, and (only in the case of scripts), also search for prefabs which have the script and choose the ones which have the appropriate name first.

    Let me know what you think. Cheers!
     
  6. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    I've already fixed that issue in the v6.0 preview.
     
    Grumpy-Dot likes this.
  7. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    v6.0 is now up on the store.
    • Inspector Gadgets Pro is now delivered as regular scripts instead of a pre-compiled DLL to make it easier to view and modify the source code. Also reorganized the namespaces.
    Warning: when upgrading from an earlier version you must delete the old version before importing the new one. This will also cause any Inspector Gadgets components (such as CommentComponent) in your project to go missing so you will need to set them all up again. This is an unfortunate side effect of the way Unity handles references to scripts inside a DLL compared to regular script files.
    • Added Persist After Play Mode context menu function to all serialized properties.
    • Added [OnOpenAsset] functions which are triggered when you hold certain modifier keys and Double Click on an asset in the Project window:
      • Alt + Double Click on a prefab to Instantiate it in the scene.
      • If you hold Ctrl as well it will also focus the camera on the instance.
      • Ctrl + Shift + Alt + Double Click any asset to open its folder in your OS file explorer.
    • Added context menu handler for AnimationCurve properties with several functions: Smooth Tangents, Flip Horizontal, Flip Vertical, Enforce Horizontal Symmetry, Extend Mirrorred.
    The full Change Log is here.
     
    Last edited: Jul 2, 2019
    Grumpy-Dot likes this.
  8. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    @Kybernetik I found an issue with the new version. When pressing the small copy position button in the Transform Inspector, I only get the position (1, 1, 1). The copy works if right clicking on the position and copy the position manually.

    The issue appears to be that the copy button for position, actually copies the scale, the copy button for rotation copies the position and the copy for scale copies the rotation - they are shifted.

    Have a nice weekend!
     
  9. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    Looks like a simple fix. Open Assets/Plugins/Inspector Gadgets/Inspector/Transform/TransformPropertyDrawer.cs, go to DoInspectorGUI, and just swap UpdateDisplayValues to be before DoMiniButtonsGUI.

    I'll submit the fix in the morning, but it could still take a few days to get approved.

    Thanks for letting me know.
     
    Grumpy-Dot likes this.
  10. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    v6.1 is up on the store with the fix. Nothing else has really changed, just a few minor improvements to some comments.
     
    Grumpy-Dot likes this.
  11. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    @Kybernetik Hello, when using the option to fill missing serialized fields in from the scene (Find in hierarchy or Find in scene) the plugin is ignoring the disabled (not-active) components and game objects.
    This is most of the times not what I want, as I have a lot of disabled objects that need to be referenced.
    If you think that is the right default behaviour, please add an option so that we can auto-fill disabled game objects as well.
    Thanks!
     
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    That sounds reasonable. I already have a few ideas to improve those buttons in the next version so I'll add that to the list, though I'm not actively working on Inspector Gadgets at the moment (Animancer is taking up most of my time right now).
     
    Grumpy-Dot likes this.
  13. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    690
    Hi, I have a question regarding color attributes.
    I'm using 3rd party asset that has its own inspector drawer for its properties.
    I would like to change color attributes for certain properties and I'm not sure if your attribute will work.
    For instance, Odin's "GUIColor" attribute does not work and perhaps if you use Weaver to force change the color, it will work no matter what. I'm just hoping that's how it works for your attributes.

    Thanks.
     
  14. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    Unfortunately Unity doesn't support property drawer stacking, so each property can only have one drawer - either the custom drawer for the asset or the drawer for my [Color] attribute (or Odin's).

    I believe Odin has a workaround to allow stacking, but I expect it would only work when all the attributes in the stack are from Odin.

    Your only real option as far as I know would be to modify the 3rd party drawer to include a color parameter and set the GUI.color while drawing it.
     
  15. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    690
    Thanks for the quick reply.
    I see. So you are not using Weaver. How hard do to think to use Weaver to inject color attributes? I just discovered Weaver and it seems like a quite powerful technique.
     
  16. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    I'm not actually sure what you're referring to. One of my other assets is called Weaver, but it has no connection to custom property drawers.
     
  17. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    690
    Yeah, what I need falls between the two assets. I don't mind purchasing both of your assets if that's a possibility. Perhaps adding a color attribute weaver as a custom extension example might be a good idea, if possible. Thanks.
     
  18. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    No, I mean Weaver has nothing to do with property drawers or their attributes. It can't just magically add things to existing 3rd party code. Doing so would require an entirely different tool which would not be even remotely simple to implement.
     
    chrisk likes this.
  19. jason416

    jason416

    Joined:
    Nov 8, 2018
    Posts:
    25
    Inspector Gadgets seems to remove any slider drawers on variables using the [Range] attribute. Is this normal and how would I get the range sliders back?
     
  20. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    That's not normal at all and I still use range sliders normally in my scripts.

    Are you perhaps trying to use another drawer attribute at the same time? Unity only supports one drawer per field.
     
  21. jason416

    jason416

    Joined:
    Nov 8, 2018
    Posts:
    25
    hmm ok I just tried it in a fresh project and yeah the sliders are fine. Must be some other conflict happening.

    UPDATE:
    ok found the culprit, nothing to do with the InspectorGadgets. Just temp script hiding in the assembly messing things up.
     
    Last edited: Jan 6, 2020
  22. Grumpy-Dot

    Grumpy-Dot

    Joined:
    Feb 29, 2016
    Posts:
    66
    @Kybernetik Hello, please include this method in IGEditorUtils.cs class if you can. I hope others might find it useful, because I'm using it a lot.

    Code (CSharp):
    1.         [MenuItem("CONTEXT/Transform/Remove all components")]
    2.         internal static void RemoveAllComponents()
    3.         {
    4.             GameObject selectedGameObject = Selection.activeGameObject;
    5.             Transform transform = selectedGameObject.transform;
    6.  
    7.             if (selectedGameObject == null || transform == null)
    8.             {
    9.                 return;
    10.             }
    11.  
    12.             Undo.RecordObject(selectedGameObject, "Remove all components");
    13.  
    14.             foreach (Component component in selectedGameObject.GetComponents<Component>())
    15.             {
    16.                 if (component != transform)
    17.                 {
    18.                     Undo.DestroyObjectImmediate(component);
    19.                 }
    20.             }
    21.         }
    Feel free to format it as you see fit. Thanks!
     
  23. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    That sounds useful. I'll add it to the next version.

    Here's my rewritten version which supports multi object selection:

    Code (CSharp):
    1.        [MenuItem("CONTEXT/Transform/Remove All Components")]
    2.         private static void RemoveAllComponents(MenuCommand menuCommand)
    3.         {
    4.             var components = ((Component)menuCommand.context).GetComponents<Component>();
    5.             for (int i = 1; i < components.Length; i++)// Skip the Transform.
    6.             {
    7.                 Undo.DestroyObjectImmediate(components[i]);
    8.             }
    9.         }
    That way if you want to do it recursively you can simply expand the children and select them all before doing it.
     
    Grumpy-Dot likes this.
  24. KP328

    KP328

    Joined:
    Apr 26, 2013
    Posts:
    64
    I installed the lite version of Inspector Gadgets. I added a canvas with a panel for testing. I needed to uninstall the plugin to check an unrelated issue, but I found it seemed to break the UI functionality in the editor. Now only the selected item is visible, so if an item on the canvas is selected, the canvas itself doesn't display, etc.

    Also the panel won't display anything (the color assigned to it won't show). Reinstalling Inspector Gadgets fixes it, but it seems to break some functionality in the project when it is uninstalled.

    I tried deleting this canvas and adding a new one but same issue.

    Starting a new project without Inspector Gadgets works as expected.

    The only way I could see to uninstall it was to delete its folder under 'Plugins'. Maybe it's changing some settings in the editor that stay after it's gone causing the issue?

    Unity 2019.4.3
    Inspector Gadgets Lite 6.1
     
  25. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    In the top right of the Unity Editor is a Layers dropdown where you can show and hide layers (the eye icon). The Auto Hide UI system just works by toggling that so it's probably just being left hidden when you delete Inspector Gadgets.
     
    KP328 likes this.
  26. KP328

    KP328

    Joined:
    Apr 26, 2013
    Posts:
    64
    That was it, thanks.

    Great plugin by the way.
     
  27. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
  28. Bezoro

    Bezoro

    Joined:
    Mar 16, 2015
    Posts:
    23
    Attempting to build the project with Inspector Gadgets Pro in it results in some exceptions preventing said build.

    Unity 2020.2.0b1
    Windows Build Support (IL2CPP)
    is the only platform module installed.
    Project Template: HDRP.
    API Compatibility Level: Set by default as .NET Standard 2.0.
    Scripting Backend: Set by default as IL2CPP.
    Target Platform: Windows
    Architecture: x86_64
    Inspector Gadgets 6.2
     
  29. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    The
    string IComment.TextFieldName => nameof(_Text);
    in the CommentComponent and CommentAsset just needs a #if UNITY_EDITOR around it:
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.         string IComment.TextFieldName => nameof(_Text);
    3. #endif
    I'll submit a fix to the store. That's what I get for trying to sneak in last minute bug fixes without re-testing everything.
     
  30. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,145
    Inspector Gadgets v6.3 is now up on the Asset Store with that fix and also fixed the Drag & Drop Sub-Assets system to not allow certain asset types that won't work (since Unity is dumb and would just corrupt the asset instead of telling you) and to ask if it isn't sure about a particular type.
     
unityunity