Search Unity

Advanced Inspector - Never Write An Editor Again

Discussion in 'Assets and Asset Store' started by LightStriker, May 4, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Very odd. I'll go install 5.3.4, something obviously changed since 5.3.3.
     
  2. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Damn, that wasn't simple to track down. I think I found out what was causing it. I'll submit a version to the store this weekend.

    EDIT:

    I skipped some planned features because I believe performance and stability are always crucial.

    Version 1.66 was submitted to the Asset Store with the following changelist;

    [FIXES]
    • Removed Light shadow warning about Unity Pro.
    • Removed HDR limitation on camera, it's no longer valid.
    • Performance issue fixed on the Selection Tracker while duplicating large selection of GameObject.
    • Performance issue when entering/exiting play and reloading context.
     
    Last edited: Apr 9, 2016
  3. KJoanette

    KJoanette

    Joined:
    Jun 8, 2013
    Posts:
    59
    I have an editor window set up which has multiple ExternalEditors created. The tabs from the first object editor is showing up in all the other editors as well. The tabs do nothing there but they shouldn't be there either, as they don't exist inside the object being inspected inside the other editors.

    Example:
    https://goo.gl/1DUi98
     
    Last edited: Apr 19, 2016
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Hmm... Very odd.

    Thanks, I'll fix that asap.
     
  5. bomberest0

    bomberest0

    Joined:
    Oct 7, 2012
    Posts:
    12

    Code (CSharp):
    1. [Expandable(AlwaysExpanded = true)]
    2.     [Serializable]
    3.     public class InGameGenerator
    4.     {
    5. }
    But "In Game Generator" may be collapsed by double-click.

    How can i made a collection always expanded?

    Code (CSharp):
    1. [Expandable(Expandable = false)]
    2.     [Serializable]
    3.     public class CellPointsContainer : PointsContainer
    4.     {
    5.     }
    I made "Cell points container" elements always expanded by "[Expandable(Expandable = false)]" but they may be collapsed and expended by alt-click on List. And they collapsing when adding new element. I need to have always expanded list and list elements.

    Code (CSharp):
    1. [Expandable(AlwaysExpanded = true)]
    It`s not working with list elements.

    "Remove element" button i too near to "drag" button.
     
    Last edited: Apr 20, 2016
  6. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Just to be sure, on which version are you right now? (The version is visible in the "About" tab of the preference panel)
     
  7. bomberest0

    bomberest0

    Joined:
    Oct 7, 2012
    Posts:
    12
    Unity 5.3.4 p4
    AI 1.66
     
  8. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Thanks, I'm looking into it.
     
  9. Zoey_O

    Zoey_O

    Joined:
    Mar 15, 2013
    Posts:
    28
    OnDataChanged of IDataChanged doesn't seem to be called if I'm inspecting something Restricted to a Toolbox selector. If I use Dropdown, then OnDataChanged is called. Is this intended? If so, is there a way to tell when a Toolbox Restriction has completed?
     
  10. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    No, it's not intended. Are you on 1.66? I fixed a similar bug a while ago.
     
  11. Zoey_O

    Zoey_O

    Joined:
    Mar 15, 2013
    Posts:
    28
    Yes, Advanced Inspector 1.66 and Unity 5.3.4f1
     
  12. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Well, I guess I know what I'll do this weekend. :p
     
  13. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I'll need more information. Can you make me a reproducible example?

    As for the 2 other issues, I have a build with the following fixes ready to be submitted to the store as the 1.67 version;
    • Reworked how IDataChanged works, fixing an issue where the event would not be raised in a Restrict Attribute in Toolbox mode.
    • Fixed an issue where the IDataChanged flag would be "eaten" by the wrong class.
    • Fixed an issue where tabs would show up in an External Editor where they should not.
     
  14. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Is this compatible with other plugins using PropertyAttribute extensions?
     
  15. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    It supports type-driven PropertyDrawers, but right now it does not handle property-driven drawers. Do you have some plugin in mind that would be interested to support?
     
  16. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thank you for your prompt reply.
    I have written some custom stuff that uses property-driven drawers and I use Dialog System for Unity which has a conversation selection property-driven drawer.
     
  17. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I'll add support for property drawers.
     
  18. Oriam

    Oriam

    Joined:
    Nov 11, 2012
    Posts:
    23
    Hi LightStriker,

    I am trying to build several projects as Windows Store Apps 8.1, but I am having troubles. Does the plugin support Windows Store Apps?

    I found the following reply in the comments section of the Asset Store:
    Reply from publisher
    1 year ago

    WP8/WP10/Window Store and other build using Core.dll are now supported since version 1.60.

    However, when I try to build I get the following errors in ActionBinding.cs and ComponentBehaviour.cs (using Advanced Inspector 1.66 and Unity 5.3.2, though we use several Unity versions):
    Assets\Plugins\AdvancedInspector\Core\ActionBinding.cs(105,61): error CS1061: 'System.Type' does not contain a definition for 'GetMethods' and no extension method 'GetMethods' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)

    I get this for GetProperties, IsAssignableFrom, GetMethod, GetFields.

    I know Windows Store Apps use a different API and not al methods are supported. Is there a workaround for this issue?

    Thanks in advance.
     
  19. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    That's very odd, as I have added #if !NETFX_CORE around all stuff that aren't supported by WP8/10/Store Core.dll a long whole ago. I admit, I don't build WP often, so maybe something slipped back in.

    If you're not using ActionBinding - which is usually the class using the most Reflection features - you can simply erase it. It's not used by Advanced Inspector, as it's only an utility class to show how one could make something similar to UnityEvent.

    I'll check this later today and try to fix it for this weekend. Contact me at admin@lightstrikersoftware.com if you want a fix faster.
     
  20. Oriam

    Oriam

    Joined:
    Nov 11, 2012
    Posts:
    23

    Thank you very much for your quick response. I think we can wait for your fix next week, as this also happens on ComponentBehaviour.cs.

    Thanks :)
     
  21. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Should be fixed now.

    Also, PropertyAttribute drawers;



    Code (CSharp):
    1. [CustomPropertyDrawer(typeof(PropertyAttributeExample))]
    2. public class PropertyAttributeExampleDrawer : PropertyDrawer
    3. {
    4.     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    5.     {
    6.         EditorGUI.LabelField(position, "This is a attribute-bound property drawers.");
    7.     }
    8. }
    9.  
    Like said previously, they will fail on Properties or Methods, as Unity only allows them on Fields.
    (You have no idea how much I dislike those for being bound to one of the worst class ever; SerializedProperty)

    Also, a new attribute; IgnoreBase. This attribute allows you to ignore all members from a parent class. This allows you to derive from a class like "Button" and add new members, like say an AudioClip you would play every time you click on it.That SoundButton comes as example in the package. For some reason, we found that it would be useful if all our button would play sounds while being pressed. Odd, right?



    It's quite an edge-case attribute, but I found it useful a few times, like in the above example. They also require quite some work to relist everything that should appear on the inspector. I praise the day Unity will drop the idea of writing custom Editor for each of their class and allow us to directly derive from them without having to rewrite everything.

    I'll update the documentation and submit version 1.67 this weekend.
     
  22. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    Hi,

    Been using Advanced Inspector, loving it. There is just one annoying thing bugging me about it. The project is successfully compiled by Unity Editor, but I'm not able to compile through MonoDevelop. It always complains about not being able to find type or namespace "Advanced Inspector", even though it's there. Am I missing something obvious?

    Thank you,
     
  23. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    What do you mean by "Compile through MonoDevelop"? Never did that, but have you added the plugin solution to your project?
     
  24. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Version 1.67 was submitted to the store with the following changes;

    [CHANGES]
    • Added a new attribute; IgnoreBase. Allows deriving from class like Button and ignoring its properties when inspecting.
    • The Method attribute now has a property named "UndoMessageOnClick". This attempt to record a undo when pressing the button.
    • Added support for attribute-bound PropertyDrawers. Note; since they are Serialization bound, they only works with fields, not Property or Methods.
    [FIXES]
    • Reworked how IDataChanged works, fixing an issue where the event would not be raised in a Restrict Attribute in Toolbox mode.
    • Fixed an issue where the IDataChanged flag would be "eaten" by the wrong class.
    • Fixed an issue where tabs would show up in an External Editor where they should not.
    • Latest version became increasingly imcompatible with Windows Phone 8.0. Fixed the reflection issue in ActionBinding and ComponentMonoBehaviour.
    • Insert, Remove, Move Up, Move Down, Move To Top and Move To Bottom on the contextual menu were broken.
    • Exceptions caught by the inspector now returns the proper stack trace in the logged error.
    • Cleanup done in the Undos. Some functions were not flagging proper undo stacks.

    Drawing attribute-bound property drawers is a totally new feature. Please report any issue with it.
     
  25. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    I mean trying to build the solution through MonoDevelop. I normally prefer building it that way because it's faster and I don't have to switch between windows.

    Here is a screenshot of the compile error

    Screen Shot 2016-05-09 at 08.17.09.png

    The weird thing is that, as you can see, the main project correctly references the firstpass project where the Plugins/AdvancedInspector stuff is.
     
  26. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Have you checked the compilation order? The firstpass is compiled first?

    The order should be, if I remember right;

    - FirstPass
    - CSharp
    - Editor-FirstPass
    - Editor-CSharp
     
  27. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    Yes, that is the order I'm seeing.
    This must be a MonoDevelop bug because it doesn't happen always. Sometimes I click the "Open C# project" ,the project is "correctly" opened and the error doesn't happen, other times it does happen and I can't compile it. I wonder if no else experiences this problem
     
  28. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Well, I'm not using MonoDevelop, I'm using Visual Studio - the one now shipped with Unity. I never experienced that bug, so it's probably limited to MonoDevelop.
     
  29. Oriam

    Oriam

    Joined:
    Nov 11, 2012
    Posts:
    23
    Thank you LightStriker, I'll keep you updated as soon as Unity updates the store.
     
  30. Miguel-Ferreira

    Miguel-Ferreira

    Joined:
    May 8, 2015
    Posts:
    90
    Thank you. I'm in a Mac btw, that's why I'm using (stuck with) MonoDevelop
     
  31. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thank you that will be awesome!
     
  32. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Assuming it works flawlessly... Mail me at admin@lightstrikersoftware.com if you find any bug. The Asset Store should validate it within a few days.
     
  33. Oriam

    Oriam

    Joined:
    Nov 11, 2012
    Posts:
    23
    Hi LightStriker,

    Just downloaded the new version (1.67), and it is working without problems in Windows Store Apps 8.1. Thank you very much for your quick update. You deserve 11 stars.

    P.S. Just so you know, I get the following warning when building. I know it is nothing, it's only so you know it is there.
    Assets\AdvancedInspector\Examples\CSharp\SoundButton.cs(218,31): warning CS0109: The member 'AdvancedInspector.SoundButton.audio' does not hide an inherited member. The new keyword is not required.
     
  34. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Thanks!

    Bleh for SoundButton.. It's only an example for the new IgnoreBase attribute. You can erase it if you want.
     
  35. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Note that in version 1.67, clicking on a inspected method is broken and throws an exception.
    A quick workaround is to add an empty Method attribute on the inspected method.

    Version 1.67a have been submitted with a fix to the asset store.

    Mail me at admin@lightstrikersoftware.com is you want the fixed version before the store approves it.
     
    Last edited: May 12, 2016
  36. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Version 1.67 have also been found to have issue with Dictionary right now and attribute-bound property drawer that relied on the FieldInfo and Attribute property of the drawer.

    Version 1.67b will be submitted as soon as 1.67a is accepted - so that at least the first critical bug is fixed - with a fix with both issue.

    If you are using Dictionary and have the issue, please mail me at admin@lightstrikersoftware.com so I can send you the fixed package ahead of the store.

    Terribly sorry for that, I'm my own quality control after all.
     
  37. Zoey_O

    Zoey_O

    Joined:
    Mar 15, 2013
    Posts:
    28
    Is there a way to make it so that when a collection is inspected, it will call ToString on all the instances its displaying in the header for each item (I'm fine with it being optional)? I think the way it works now, is it takes the generic parameter of the list, and ToString is overriden at that level in the class hierarchy, it will call it.

    If I have a list of an interface, for example, where I need to read the ToString in the inspector, and I wrote the interface, then I can just put string ToString(); in the interface and it works.

    If I can't modify the interface, or the inheriting classes, I'll create a UNITY_EDITOR define and an additional list that contains a CollectionItem<T> (a custom class I wrote), where the T is whatever the interface is in the list, and has one DisplayAsParent property of T and it's ToString just calls the inner T's ToString and everything seems to work. It would be nice if I could just tell the list to always call ToString, overridden or not, interface or not.

    If there is already a feature that does this that I am missing, let me know. =)
     
  38. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I had to re-read that quite a few times. Probably because it was Monday.

    Usually, the ToString feature works this way;

    Code (CSharp):
    1.         public bool OverloadToString
    2.         {
    3.             get
    4.             {
    5.                 Type type = Type;
    6.                 if (type == null)
    7.                     return false;
    8.  
    9.                 MethodInfo info = type.GetMethod("ToString", new Type[0]);
    10.                 return info != null && info.DeclaringType != typeof(object) && info.DeclaringType != typeof(UnityEngine.Object) && info.DeclaringType != typeof(ValueType);
    11.             }
    12.         }
    So it doesn't matter if the ToString implementation is from a parent, as long as it's not object, UnityEngine.Object or ValueType. However, as you know, interfaces does not have parents or proper implementation.

    However, while inspecting elements of a collection, the "Type" property returns the type of the object, not the type of the collection's generic.

    Would you have some example of your issue with ToString? It should work fine, even if each object in a collection have or not different ToString implementation.
     
  39. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Hi,

    1.
    I just wonder how could I make it work on StateMachineBehaviour?
    StateMachineBehaviour inherits from ScriptableObject, so this should work with it right?

    2.
    The Unity editor default initial indention is kind of 16px,
    I feel that advancedInspector's initial indention is a little too much (32px), is there a method to make them less indented? I prefer the initial indention to be 0px if possible.

    Best regards,
     
    Last edited: May 18, 2016
  40. Zoey_O

    Zoey_O

    Joined:
    Mar 15, 2013
    Posts:
    28
    For an example of the interface issue here is the code and I've uploaded an image.

    As you can see, if the type is an interface, either as a property, or an item in a collection, ToString() isn't called, except when I use the IExampleWithToString as the type. This is from Advanced Inspector today, 1.67a or something (was an update when I made the test project). If I'm overlooking something let me know.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class Test : MonoBehaviour
    5. {
    6.     public ExampleClass ExampleClass = new ExampleClass();
    7.     public List<ExampleClass> ExampleClassList = new List<ExampleClass>() { new ExampleClass() };
    8.  
    9.     public IExample ExampleInterface = new ExampleClass();
    10.     public List<IExample> ExampleInsterfaceList = new List<IExample>() { new ExampleClass() };
    11.  
    12.     public IExampleWithToString ExampleWithToStringInterface = new ExampleClass();
    13.     public List<IExampleWithToString> ExampleWithToStringList = new List<IExampleWithToString>() { new ExampleClass() };
    14. }
    15.  
    16. public interface IExample
    17. {
    18. }
    19.  
    20. public interface IExampleWithToString : IExample
    21. {
    22.     string ToString();
    23. }
    24.  
    25. public class ExampleClass : IExampleWithToString
    26. {
    27.     public override string ToString()
    28.     {
    29.         return "Example Class Override";
    30.     }
    31. }
    32.  
     

    Attached Files:

  41. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    1. It's kinda odd, but Unity added a StateMachineBehaviour editor that overwrite AI's one that starts at ScriptableObject. The work around is very simple - if a bit dumb. Make this;

    Code (CSharp):
    1. public class AdvancedStateMachineBehaviour : StateMachineBehaviour { }
    Derive your class from AdvancedStateMachineBehaviour instead of StateMachineBehaviour.
    Then in an editor folder;

    Code (CSharp):
    1.     [CanEditMultipleObjects]
    2.     [CustomEditor(typeof(AdvancedStateMachineBehaviour), true)]
    3.     public class StateMachineBehaviourEditor : InspectorEditor { }
    And you get Advanced Inspector in your StateMachine. I should probably add this to the default AI package, but it's a bit annoying to have to change your base class. Very annoying how Unity made an inspector for their StateMachineBehaviour. I'm not sure exactly what their inspector is adding as functionality in this case.

    2. The default AI's indention is 0px... However, unlike Unity, AI reserves space for the image boarders of sub-objects. I'll look into it, I can probably shave off a few pixels here and there.
     
  42. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Thanks a lot.

    This allowed me to dig properly into what's going on... And it actually somewhat make sense. I'm using the field/property declared type to check if I can display it, because of multi-selection. Right now, if there's a multi-selection it goes that way;

    - Is the field "mixed", multiple-selection of different value? If so, draw "---".
    - If the field is null, draw "None"
    - Can the inspector type overload ToString?

    Now, I could check the object type instead of the field/property type if there's no multi-selection. I'll actually do that.
     
  43. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Non-critical version 1.67c submitted for review;
    • Managed to shave off 6 pixels off the labels section.
    • Fixed an issue that prevented inspecting nested Unity type.
    • Use the object type instead of the declaring type for ToString overload test.
     
  44. Zoey_O

    Zoey_O

    Joined:
    Mar 15, 2013
    Posts:
    28
    Thanks!
     
  45. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Thanks, this method works fine for me :)
     
  46. plundo

    plundo

    Joined:
    Mar 16, 2013
    Posts:
    4
    Something that's bugged me about unity, and I was hoping AI could do it?... Display a sprite in the inspector?
    When you have large collections that contain sprite fields, I'd like to show the sprite in the inspector next to/under the sprite field.
     
  47. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    You can use the IPreview feature, but I have a feeling that is not what you mean.

    How should that sprite show up?
     
  48. plundo

    plundo

    Joined:
    Mar 16, 2013
    Posts:
    4
    Like a shader texture preview would be great, just a way to see the sprite (in my case a square icon)

     
  49. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I'll try to find how Unity does it. It might be limited to the combo of UV/Texture, not sure.
     
  50. Astro75

    Astro75

    Joined:
    Dec 18, 2014
    Posts:
    48
    Or maybe it is possible to show sprite only when mouse hovers on a sprite field. It could be shown in a popup box near the mouse. That way Sprite fields could be left the same height as they are currently.