Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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
    To be honest, the enum display is something I have to rewrite, including removing all use of Unity EditorGUI.EnumPopup... which just goes batshit insane when you have a "None = 0" value in an masked enum.

    If you want to look at it, you can check the file in Plugins/Editor/AdvancedInspector/FieldEditors/EnumEditor.cs

    Also, using byte instead of int, you save 24 bits (64 bits -> 40 bits) in a 32 bits environment, and (96 bits -> 72 bits) in a 64 bits environment because of the implicit 32/64 bits memory address overhead.
     
  2. sanjodev

    sanjodev

    Joined:
    May 29, 2012
    Posts:
    63
    Is the memory address overhead stored only once or each time I instantiate the class or each time I instantiate a class with multiple instances of the enum type?

    public class Foo
    {
    public Flags f1;​
    }

    public class Bar
    {
    public Flags f1, f2, f3;​
    }
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    My bad, I have no idea what I was smoking. Enum is not an object, it's a value type, it doesn't have an address overhead.

    So it's 32 bits -> 8 bits.

    And the overhead of objects is 128 bits, not 64.
     
  4. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I have this error when downgrading from 4.6 to 4.3

    TypeLoadException: Could not load type 'AdvancedInspector.ExternalEditor' from assembly 'AdvancedInspector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
    System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/MonoCustomAttrs.cs:108)
    System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/MonoCustomAttrs.cs:151)
    System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/MonoType.cs:595)
    UnityEngine.AttributeHelperEngine.CheckIsEditorScript (System.Type klass) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/AttributeHelperEngine.cs:76)

    any ideas?
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Ok, I will probably need a version that works with 4.3 ... is there one?
     
  6. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Sorry, not really. The cutoff for 1.5+ is Unity 4.5.

    Why not upgrade your project to 4.6 instead?
     
  7. Olivierlr

    Olivierlr

    Joined:
    Jul 4, 2014
    Posts:
    14
    Is Advanced Inspector compatible with Unity 5.0? If not yet, do you have an ETA?
     
  8. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    The latest version (1.52f) is compatible with Unity 5, but some Unity class inspector might not be fully working. In those cases, you can simple turn off the specific editors in the preference panel.

    1.53 will have support for all the currently supported classes for Unity 5.
     
  9. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I don't mind version that is older than 1.5 , and yeah, Unity version for PS4 and Xbox one only supports upto 4.3 :(
     
  10. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I'm really not sure to understand... Unity 4.6 and 5.0 both support Xbox 360/One and PS3/PS4. Am I missing something?
     
  11. Hedonsoft

    Hedonsoft

    Joined:
    Jul 11, 2012
    Posts:
    168
    I recently upgraded my project to Unity5 and redownloaded and installed AdvancedInspector now I'm getting a bunch of errors.

    Assets/_GameAssets/Scripts/NN/Gameplay/Items/Weapons/WeaponBase.cs(20,28): error CS0234: The type or namespace name `Space' does not exist in the namespace `AdvancedInspector'. Are you missing an assembly reference?
    Assets/_GameAssets/Scripts/NN/Gameplay/Items/Weapons/WeaponBase.cs(20,28): error CS0234: The type or namespace name `SpaceAttribute' does not exist in the namespace `AdvancedInspector'. Are you missing an assembly reference?
    Assets/_GameAssets/Scripts/NN/Gameplay/Items/Weapons/WeaponBase.cs(31,28): error CS0234: The type or namespace name `Space' does not exist in the namespace `AdvancedInspector'. Are you missing an assembly reference?
    Assets/_GameAssets/Scripts/NN/Gameplay/Items/Weapons/WeaponBase.cs(31,28): error CS0234: The type or namespace name `SpaceAttribute' does not exist in the namespace `AdvancedInspector'. Are you missing an assembly reference?

    Do I need to add a namespace other than just AdvancedInspector?
     
  12. Hedonsoft

    Hedonsoft

    Joined:
    Jul 11, 2012
    Posts:
    168
    NM fixed it. I was using AdvancedInspector.Space, I just removed the AdvancedInspector
     
  13. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    In version 1.52+;

    - IMPORTANT: To avoid conflict with UnityEngine.SpaceAttribute, AdvancedInspector.SpaceAttribute have been renamed to SpacingAttribute.
     
  14. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Nope. I have contacted Sony directly and they told me that only 4.3 is supported at the moment. Also it goes with my previous experience with console version of Unity. They are almost always behind the latest version of Unity. I think Unity will probably skip version 4.6 and go for 5 if they ever decide to upgrade their console version. And I think it won't be any time soon. My guess is probably in about 6 months or 8 months?
     
  15. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    You're talking about the major player revision, no? Not the editor? PS4 is in the build setting platform of Unity 4.6/5.0. Are you saying that while it's listed there, you can't use it?
     
  16. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Code (csharp):
    1.  
    2. NullReferenceException: SerializedProperty cannot be null in an InspectorField field constructor.
    3. AdvancedInspector.InspectorField..ctor (AdvancedInspector.InspectorField parent, Int32 index, System.Type type, System.Object[] instances, UnityEditor.SerializedProperty serializedProperty, System.Attribute[] attributes)
    4. AdvancedInspector.InspectorField..ctor (System.Type type, System.Object[] instances, UnityEditor.SerializedProperty serializedProperty, System.Attribute[] attributes)
    5. AdvancedInspector.TerrainColliderEditor.RefreshFields () (at Assets/Plugins/Editor/AdvancedInspector/UnityTypes/TerrainColliderEditor.cs:24)
    6. AdvancedInspector.InspectorEditor.set_Instances (System.Object[] value)
    7. AdvancedInspector.InspectorEditor.OnEnable ()
    8.  
    Any ideas on this one? Latest Terrain Composer mate :)
     
  17. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    In order to use Unity for PS4 and Xbox One, you need to use special Unity Edition that the platform provider gives to you.
    Yes, I know what you mean by looking at the build settings, there is console platform that you can switch to, But in practice, you can't do that because it only actually works for the edition of Unity that is "made" for the platforms. I do agree that it is bit confusing, I am guessing they are there because Unity want people to aware that there are these platforms that Unity supports.
     
  18. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    It will make more sense in the 5.x life cycle, I believe the idea is to release those platforms as modules instead of separate Unity versions.
     
  19. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    That sucks. I'll look into making it compatible with 4.3 again.
     
  20. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    They changed an internal variable name in Unity 5.

    You can change the TerrainColliderEditor.cs with;

    Code (CSharp):
    1. namespace AdvancedInspector
    2. {
    3.     [CanEditMultipleObjects]
    4.     [CustomEditor(typeof(TerrainCollider), true)]
    5.     public class TerrainColliderEditor : InspectorEditor
    6.     {
    7.         protected override void RefreshFields()
    8.         {
    9.             Type type = typeof(TerrainCollider);
    10.             SerializedObject so = new SerializedObject(targets);
    11.  
    12.             fields.Add(new InspectorField(type, Instances, type.GetProperty("isTrigger"),
    13.                 new DescriptorAttribute("Is Trigger", "Is the collider a trigger?", "http://docs.unity3d.com/ScriptReference/Collider-isTrigger.html")));
    14.             fields.Add(new InspectorField(type, Instances, type.GetProperty("terrainData"),
    15.                 new DescriptorAttribute("Terrain Data", "The terrain that stores the heightmap.", "http://docs.unity3d.com/ScriptReference/TerrainCollider-terrainData.html")));
    16.             fields.Add(new InspectorField(type, Instances, so.FindProperty("m_EnableTreeColliders"),
    17.                 new DescriptorAttribute("Create Tree Colliders", "", "")));
    18.         }
    19.     }
    20. }
    I'm currently working at updating all the custom editor for Unity 5.
     
    twobob likes this.
  21. Hedonsoft

    Hedonsoft

    Joined:
    Jul 11, 2012
    Posts:
    168
    Thanks!
     
  22. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Version 1.53 have been submitted to the Asset Store with the following changes;

    • Added support to drag'n'drop component from Project view. Previously only GameObject would work.
    • Added option to invoke contextual menu using a modifier key with a left-click.
    • Removed the constructor component from the collection attribute. Now this behaviour has its own attribute; Constructor Attribute.
    • Fixed an issue for copying ComponentMonoBehaviour with private field in a derived class.
    • Fixed an issue where a ComponentMonoBehaviour should not copy its references.
    • Brought back 4.3 support since some people are stuck on it for PS/Xbox compatibility. Note that some feature do not work on 4.3.
    • Fixed an issue where IRuntimeAttribute would collide with IListAttribute in passing down in a collection.

    Note that Advanced Inspector 1.53 now comes in 3 different version; 4.3, 4.6 and 5.0.

    The new Asset Store tools installs the version for your current editor. If you move your project from one editor version to another, you may need to re-install the proper Advanced Inspector. To check, the full version is displayed in the Preference panel in the form "1.53 (v4.6)".

    Note that all supported custom inspector have been fixed for Unity 5.0.

    P.S.: Supporting 3 different version which each has differences... That's one royal pain. Unless major request, 1.53 is probably the last version to support Unity 4.3.
     
    Last edited: Mar 18, 2015
  23. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Homage to your efforts.
     
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Thanks for making version for 4.3

    Is it possible to have 4.3 version but still run under Unity 4.6?
    You may think why and I am asking stupid question, but it's a bit of long story ... basically, what I need to do is to have 4.6 version of the project so I can do level editing (the tool that I use called Rotorz is impossible to run under 4.3) and then build and deploy using the 4.3 for console builds.

    I don't mind having limited features for 4.6 and it is fine if it just actually behave as if it is 4.3 under 4.6

    So I want to load up my project under 4.3 editor, add Advanced Inspector and keep it 4.3 version in my project. Then I want to load the project using 4.6 and work on it.

    If this is not possible, then I can't ask you more than that. :D
     
  25. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    You can most likely run AI 4.3 on 4.6, but not the other way around.
    Basically, 4.6 added new stuff that AI support or made possible like UDictionary. 1.52/1.53 also supports Unity's attribute like "Tooltip", but since they don't exist in 4.3, the library won't load properly. In short, the 4.3 is a stripped down version of 4.6 specific features.

    Just to be sure I've loaded the 4.3 on Unity 4.6 and with a quick check haven't found any issue.
     
  26. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    excellent, once I can download 4.3 I will try it and let everyone know.
     
  27. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    This could have saved me a lot of time on the project I'm working on. I don't need it now but I just bought it to show my support. Writing custom editors is so f-ing tedious.
     
    Last edited: Mar 19, 2015
  28. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i have dictionary is resested when play scene
     
  29. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Is your dictionary deriving from UDictionary? Does it have the [Serializable] attribute?

    You don't say... I didn't write this because I enjoy custom editor, you know? :p

    Thanks a lot for buying it. Hopefully you may one day use it too. ;)
     
  30. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    i don't know lol i have make that's
    [SerializeField]
    public Dictionary<string,Anim> diction = new Dictionary<string, Anim>();

    don't see curve too
     
  31. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Please take a look at the class "AIExample32_Dictionary". Let me know if you have any question after that.
     
  32. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
  33. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    The solution I found was to have this class which you derive your own state from;

    Code (CSharp):
    1. public abstract class AdvancedState : StateMachineBehaviour { }
    And in an Editor folder, you make this class;

    Code (CSharp):
    1. using AdvancedInspector;
    2.  
    3. [CustomEditor(typeof(AdvancedState), true)]
    4. public class AdvancedStateEditor : InspectorEditor
    5. {
    6.     public override void OnInspectorGUI()
    7.     {
    8.         DrawAdvancedInspector();
    9.     }
    10. }
    The issue with StateMachineBehaviour is that the guys at Unity implemented it the same way any end-user would implement their own Inspector, and they flagged it as being the default inspector for all derived class. In essence, it blocked any inspector up the line, like in this case the ScriptableObject inspector of AI.

    To be honest, I have absolutely no idea why they made it that way, blocking any kind of generic third-party tool in the process from working out of the box without any modification.

    If you feel it would be useful to have those directly in AI's package, I will add them. As for now, I feel it's a workaround to a Unity design oversight. Also, a bug was submitted to Unity about that issue.
     
  34. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    I can't seem to drag multiple assets onto an array in Advanced Inspector. Is this a bug or is it just not supported?

    To clarify, I have a class something like this attached to a game object:
    public class MultipleSpritesBehaviour : MonoBehaviour {
    public Sprite[] Sprites;
    }

    It shows a list editor for the array of sprites. When I select multiple sprites at the same time (by holding shift) in the project folder and then drag onto the list, it doesn't do anything. If I disable Advanced Inspector and let the built-in Unity array inspector take over, then dragging and dropping multiple sprites like that does add all the sprites to the array as expected.
     
  35. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Trying here it works fine... if you... select the sprite component in the texture. Damn.

    Alright, I guess I need to find out how to get the sprite associated to a texture file.
     
  36. RodolfoLasparri1

    RodolfoLasparri1

    Joined:
    Feb 24, 2013
    Posts:
    14
    Hey, great plugin, found a bug:

    on Unity's WheelCollider component, the Spring/Damper values can't be modified at all if AdvancedInspector is active!
     
  37. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Odd, I'll look into it. For now, you can go in the Preference panel and disable that specific inspector.
     
  38. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Version 1.53 is now available on the store. I guess the store forgot to told me they approved it.
     
  39. BehemothPro

    BehemothPro

    Joined:
    Feb 14, 2015
    Posts:
    19
    Hey, I love AI so far it's really been a life saver for me. thanks.

    I'm creating an EditorWindow using ExternalEditor and I was wondering if there's anyway I can get the editable name field of a ScriptableObject to display.
     
  40. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Not sure... This maybe?
    Code (CSharp):
    1. [Inspect]
    2. public string Name
    3. {
    4.     get { return base.name; }
    5.     set { base.name = value; }
    6. }
     
  41. BehemothPro

    BehemothPro

    Joined:
    Feb 14, 2015
    Posts:
    19
    Awesome. It doesn't change the asset name when I press enter which is a little annoying, so I ended up using Method(MethodDisplay.Invoke) and having a textfield that applies the name change when the return key is pressed. Thanks!
     
    Last edited: Mar 27, 2015
  42. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Version 1.54 have been submitted to the Store with the following changes;

    • Added missing constructors in Collection attribute.
    • Asset under source control now shows up as Read Only properly when not checked out.
    • External Editor now shows a source control bar at the bottom when an inspected item is under source control.
    • Fixed some inspector on the 4.3 version.
    • Fixed an issue with struct in Unity type, such as Spring Joint in the Wheel Collider.
    • Allow Textures to be dragging in as being a Sprite.
    • Multi-drag in array are now ordered by name, to avoid unnecessary sorting.
    • Fixed an issue where dragging a single item from the inspector to a collection.
     
  43. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    1.54 is now available on the store.
     
  44. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    I'm getting a bunch of "Advanced Inspector is inspecting an obsolete member; uv1 on type Mesh" warnings when selecting objects with meshes in the hierarchy.
     
  45. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    You can ignore it, it has no impact on anything, or you can open the MeshEditor.cs file, and remove this line;

    Code (CSharp):
    1.             fields.Add(new InspectorField(type, Instances, type.GetProperty("uv1"),
    2.                 new DescriptorAttribute("UV1", "Lightmap UVs.")));
    For some reason, they removed the UV1 data, and now has UV3 and UV4.
    I'll fix that for the next version, but it has no impact on anything.

    If you're using UV3 or UV4 and want to see those, you can add:
    Code (CSharp):
    1.             fields.Add(new InspectorField(type, Instances, type.GetProperty("uv3"),
    2.                 new DescriptorAttribute("UV3", "The third texture coordinate set of the mesh, if present.", "http://docs.unity3d.com/ScriptReference/Mesh-uv3.html")));
    3.             fields.Add(new InspectorField(type, Instances, type.GetProperty("uv4"),
    4.                 new DescriptorAttribute("UV4", "The fourth texture coordinate set of the mesh, if present.", "http://docs.unity3d.com/ScriptReference/Mesh-uv4.html")));
     
  46. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    That fixed it. Thanks!
     
  47. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Hi LightStriker,

    Your extension looks really good and I will probably buy it shortly. Just a question: With the default Unity inspector if you have something like this:
    Code (CSharp):
    1.     [System.Serializable]
    2.     public class MyClass
    3.     {
    4.         public string myName;
    5.         public float test1;
    6.     }
    7.     public MyClass[] myClass;
    The content of myName is used as label for the array, so instead of showing the classic "Element 0", "Element 1"... Unity uses the string in "myName".

    This default behavior despite being great, it forces to add that string to "MyClass" which is only needed for the inspector. My question is, does "Advanced Inspector" have a solution for this?

    Thanks in advance
     
  48. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Odd, never knew about that behaviour in Unity. It looks like it takes the first serialized field, and if it's a string it uses it.

    Advanced Inspector instead uses the standard .NET ToString() method. It does not override the index displayed, but add information beside it. It shows up like this;



    In this example the field "Name" was not needed.

    Code (CSharp):
    1. [Serializable]
    2. public class MyClass
    3. {
    4.     public string name;
    5.  
    6.     public override string ToString()
    7.     {
    8.         return name;
    9.     }
    10. }
    It means you can return anything to be displayed.
     
  49. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Thats a more powerful solution that can be very flexible. ;)

    Many thanks
     
  50. Oriam

    Oriam

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

    First of all, great product. I have used it in two projects already and it is great.

    In my current project I had to make a script for custom scene gui elements (OnSceneGUI). To do this, I had to create an editor script for my MonoBehavior. Because of this, I lost all the Advanced Inspector functionality in that object, which was not intended. Is there a way to get your plug-in functionality even when I have an editor script to use OnSceneGUI? I am not overriding OnInspectorGUI at all.

    Hope you can help me to figure this out.

    Thanks in advance.
    Oriam