Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Advanced Inspector - Never Write An Editor Again

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

  1. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    5.6.6,
    Seems legit
     
  2. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    1,785
    says 1.71 beta?
    upload_2018-11-7_15-26-23.png

    upload_2018-11-7_15-29-39.png

    Don't know how else to try and get the right one?
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    I have honestly no idea why you would have 1.71 Beta. Clearly not supposed to be a valid version.
    The latest version on the store for Unity 5 is supposed to read 1.72a or 1.73.

    I just dusted off Unity 5, downloaded AI from the store and it imported me the 2017 version.
    Clearly the store needs to be a bit more careful on what it imports.

    If you send me an email to admin@lightstrikersoftware.com, I can send you the latest Unity 5 version.
     
    twobob likes this.
  4. rosevelt

    rosevelt

    Joined:
    Oct 23, 2012
    Posts:
    47
    Is Advance Inspector working well with Unity 2018.3 ?
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    2018.2 yes...
    As for 2018.3, there's a lot of work underway to make it work with it.
     
  6. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Hey @LightStriker, great asset! Thanks very much for your hard work on it - it's saving me a lot of time and hassle. A quick request: the little in-scene asset picker which appears next to GameObject/component references is very cool. However, it doesn't respect the SelectionBase attribute. I have a hierarchy which looks like this:

    Code (CSharp):
    1. -[SelectionBase] ParentComponent
    2.   -SomeMesh
    3.   -SomeOtherMesh
    ...and I want to pick references to ParentComponent using the awesome little picker tool. However, it doesn't appear to work (no references are picked), presumably because it's only looking at the SomeMesh GameObjects and not walking up the hierarchy to find ParentComponent. To be clear: the ParentComponent doesn't have any Meshes or Colliders or anything which might be hit by a raycast (is that how it works?).

    Do you think it would be possible to add support for SelectionBase parent objects to the picker? It would be amazing if it were possible to do this.

    Thanks again!

    Ben
     
  7. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    Shouldn't be very hard. In the ObjectField.cs file, you have a Pick() method where you could check for other component or attribute. I'm not too sure of the usual rules with SelectionBase, as last time I tried to use it it was a bit all over the place - even in normal Unity.
     
  8. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    83
    Hey, thanks for the feedback. I've just got this implemented - I wasn't able to find Pick() as you stated, but I edited InspectorEditor.cs around line 347 to add an additional check for SelectionBase attributes up the chain. I used the Unity functions HandleUtility.FindSelectionBase() and HandleUtility.GameObjectContainsAttribute which someone has handily decompiled on Github.

    The picker is super usable now. Thanks for your help!

    Ben
     
  9. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    220
    I'm writing an editor again.
     
  10. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    12
    Hi LightStriker! I love Advanced Inspector, works great! However I am a bit befuddled by the whole discussion with Miguel-Ferreira earlier in this thread, about adding a button to the inspector. A button below the properties that will allow one to perform an action in the editor, without having to write a custom editor.

    At the moment, my WorldCore class (which generates worlds) requires two simple buttons, so I wrote a custom editor for it - however this disables the use of Advanced Inspector. You mentioned using #if UNITY_EDITOR will allow one to put it in the class itself - without having to write a custom editor? However I haven't found an example of the correct syntax within this #if #endif statement, as the custom editor code only throws up errors.

    Could you elaborate with an example, perhaps?

    Edit: Example code that doesn't throw up errors and doesn't work. What am I missing?
    Code (CSharp):
    1.     #if UNITY_EDITOR
    2.  
    3.     public void OnInspectorGUI()
    4.     {
    5.        
    6.         if(GUILayout.Button("Generate World"))
    7.         {
    8.             GenerateWorld();
    9.         }
    10.        
    11.         if(GUILayout.Button("Delete World"))
    12.         {
    13.             DeleteWorld();
    14.         }
    15.     }
    16.    
    17.     #endif
     
  11. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    12
    As is so often the case, I figured it out and it was MUCH MUCH simpler than I anticapated XD

    Just add the [Inspect] attribute to the desired method. Problem solved, it shows up in the inspector.

    Thanks! :D
     
  12. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    Haha! I was writing you an answer. Yeah, I tend to like when it's simple.
     
  13. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    12
    Hello again :D

    I have a different question. I am using a ScriptableObject called Map, which creates Tiles (also ScriptableObjects). These are stored in an Advanced Inspector UDictionary along with a Vector2. However when I enter or exit play mode, these get deserialized.

    Before:
    Screenshot 2019-03-09 at 17.05.36.png

    After:
    Screenshot 2019-03-09 at 17.05.45.png

    Now in the Map SO I have this creating the dictionary:

    [Serializable]
    public class GridDictionary : UDictionary<Vector2, Tile> { }
    public GridDictionary grid = new GridDictionary();


    Is it a bug? Did I write something wrong? Is it not supported this way? Am I missing a declaration or an attribute? Or is it because I am on 2018.3?

    Thanks!
     
  14. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    Where are those Tile stored? A ScriptableObject is a file. Do you have a file for each of those tiles?
     
    SFvdB likes this.
  15. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    12
    Again, answering my own question. ScriptableObjects in memory are not serialized, according to what I could fine. Not even when they're stored in a SO, apparently. Alright, taking a different approach. Still loving Advanced Inspector, by the way ;)
     
  16. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    Is there a reason for Tile to be a ScriptableObject?
     
  17. SFvdB

    SFvdB

    Joined:
    Mar 10, 2014
    Posts:
    12
    It's not related to Unity's 2D tilemaps. It would've made storing mapdata a bit easier. But I've decided to break it down a bit go for a simpler approach. That way it won't create a whole slew of asset files.
     
  18. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    I meant, is there a reason for it to be a ScriptableObject, instead of a normal object?
     
  19. noania

    noania

    Joined:
    Apr 19, 2014
    Posts:
    33
    Will the asset be updated for Unity2019? It has served me well for long time so I'm not complaining even if it won't be. I just would like to know whether if it's time for me to leave it behind and move on.
     
    NeatWolf likes this.
  20. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,501
    My goal is to rewrite it to use UIElements, which should give it quite a major performance boost. But sadly, I have no timetable on when that could be done.
     
    noania and NeatWolf like this.
  21. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    220
    I really wish Unity makes Advanced Inspector the official package. It's still the best inspector on the asset store. Here's a little fix for GradientEditor class.

    Code (csharp):
    1.  
    2.         public override void Draw(InspectorField field, GUIStyle style) {
    3.             object o = GetValue(field);
    4.  
    5.             var gradient = (Gradient)o;
    6.  
    7.             EditorGUI.BeginChangeCheck();
    8.             gradient = EditorGUILayout.GradientField(gradient);
    9.  
    10.             if (EditorGUI.EndChangeCheck()) {
    11.                 field.SetValue(gradient);
    12.             }
    13.         }
    14.