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

Full Inspector: Inspector and serialization for structs, dicts, generics, interfaces

Discussion in 'Assets and Asset Store' started by sient, Jan 23, 2014.

  1. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Hey all --

    I'm currently looking for testers for the next Full Inspector release. The beta/RC build includes full source code, so if you're on the demo or haven't tried it yet this is a great way to get a snapshot of the source!

    Here's the current changelog:

    note: Unity 4.5 is required.

    Thanks
     
  2. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    I would love to participate in the beta, how do I enter?
     
  3. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Check your PM inbox :)
     
  4. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    It's very interesting, especially because the rendering of many dictionary keys is very slow and when I'm running the game in the editor I can't have some large settings data visible in the inspector. (any possible improvement on this side?)

    When do you plan to release this update on the asset store? I still see 2.3.1

    Thanks
     
  5. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Perf with the new metadata engine is currently an issue with extremely large collections -- however, the new metadata engine enables a ton of previously impossible editors and higher-level optimizations, which is why it's so useful and, in general, increases the overall performance of FI. I think that the path forward for large collections is a "subview", where you only see 100 or so elements at a time but you can quickly zoom around the collection. A collection with 50,000 elements is simply unusable in the inspector; it's just too much data.

    2.4 is significantly more optimized in comparison to 2.3, both in memory and runtime. For example, due to the new metadata engine, GetElementHeight() is now automatically cached when running in an Edit() cycle.

    How big are the dictionaries you are editing? It's a bit laggy (5-10 FPS), but 2.4 can run a dictionary<int, int> with 5000 elements at 5-10 FPS when doing actual editing. And for something that large, you can simply collapse it and get relatively good perf once again (Unity's Undo change check consumes most of the time here, and the Undo check is run as infrequently as possible).

    There have been a few bugs (only one show-stopping one so far though! so that's good), but I plan on submitting soon; I expect it to be within the next week. I can't promise a timeline though :(. Your best bet to getting a release is to run the RC version.

    2.4 is a pretty huge update - it introduces the new metadata engine, a new serializer (that I've written), a serializer importer/manager, an (across play-mode) backup engine, animation, a simple auto-layout toolkit, inline object editing, and universal foldouts (iirc, there may be more), so testing it has been taking awhile.
     
  6. Cripplette

    Cripplette

    Joined:
    Sep 18, 2012
    Posts:
    66
    Hi,

    I would like to participate to the beta if possible and help =)
     
  7. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Wow I didn't know about so many great features. I really appreciate you effort on improving FI.
    Take your time and keep us updated on your progress :)

    Edit: I posted my question from the phone and I didn't notice the long changelog that you posted few days ago. So I just want to clarify that was not my intention to push for the release.
     
    Last edited: Jul 11, 2014
  8. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I don't have big dictionaries but "complex" ones.

    For example, I have a dictionary<enum, interface> populated with 10 specialized classes, each of them with a dictionary<enum, myclass>, where myclass contains just 2 integers.

    Or also a list<interface> populated with few different classes. Each class ranges from 2 to 15 properties, that could be strings, integers, vectors, and animation curves.

    I'll test it with 2.4 as soon as will be released. Maybe it will fix this.
     
  9. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    public override bool HasPreviewGUI()
    public override void OnPreviewGUI(Rect rect, GUIStyle style)
    public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)

    any way to use use preview view or file icons? as described at the end of this video :


    thanks
     
  10. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sure, that should be easy to get into the next update.
     
  11. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I'll send you a PM soon. Thanks!
     
  12. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    This scenario *should* hopefully be improved, as in general FI is faster now, especially on the memory allocation side (5x reduction!)
     
  13. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    2.4 is finally launching soon! I'll be submitting to Unity tonight and I'm happy to say that Full Inspector now fully supports Desktop, Android, iOS, WebPlayer, Windows Phone, and Windows Store export platforms!

    For the AOT platforms, you can find free serializer support by using Full Serializer.
     
    rakkarage likes this.
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    As an added note, I am working on some updates to improve compatibility between Full Inspector and JSON .NET for Unity on the Windows Phone platform.
     
  15. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    Nevermind, bug solved in current version :)
     
    Last edited: Aug 8, 2014
  16. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    (Sorry double post)
     
    Last edited: Aug 8, 2014
  17. Remiel

    Remiel

    Joined:
    Oct 17, 2012
    Posts:
    105
    I would like to see Full Inspector support serialization of multidimensional arrays. Is that on the roadmap?
     
  18. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    And perhaps additionally, multi-dimensional representations of 1d arrays? I know some people use a 1d array as if it's a 2d array. So FI would show it as if it's 2d.
     
  19. stevethorne

    stevethorne

    Joined:
    Apr 8, 2013
    Posts:
    16
    Hey just bought Full Inspector and I'm loving it! My one concern is the way variable names are drawn in the inspector. Our team's coding standard makes use of m_ in front of our variables. In Unity inspectors this is thrown out and the rest of the variable is used, but in Full Inspector the m stays. For example, the variable m_ItemBox would appear as "Item Box" with Unity's default inspector, but in Full Inspector it shows up as "M Item Box". This is really ugly to look at and makes things difficult to read and work with. Is there any way this could be fixed or taken into account. Alternatively, could you point me to the area that handles how variable names are calculated? I could certainly apply a change myself specifically for our team.
     
  20. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    That would be ObjectNames.NicifyVariableName Yeah I know how goofy that sounds
     
  21. stevethorne

    stevethorne

    Joined:
    Apr 8, 2013
    Posts:
    16
    I actually found where the code is handled! In the DisplayNameMapper.cs file :D

    I just added these lines to the beginning of the MapInternal function right after 'start = 0' and right before the while loop checking for initial underscores:

    Code (CSharp):
    1. if ( start + 1 < propertyName.Length && propertyName[start + 1] == '_' )
    2.     start += 2;
    Thanks Anomalus for the function, but I couldn't be sure that his DisplayNameMapper function 'MapInternal' was only being executed in the Editor, so I wasn't able to use the function. Good to know for later, though!
     
  22. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    Question -
    I have the following arrangement:
    Code (csharp):
    1.  
    2. public class MyBehavior : BaseBehavior {
    3.     // Some serializable classes
    4.     public A a;
    5.     public B b;
    6.     public List<T> list; //list containing A and B (T is a common interface of A and B)
    7.  
    I use the list for iteration of common functionality.
    However in serialization the list is serialized as a different object. How can I make the list serialize in a way that won't copy A and B but rather they'll point to the same object?
     
  23. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yep, you can track this here. However, it's a relatively low priority item. Why not just use two one-dimensional arrays? Most serializers have issues with multidimensional arrays as well (Json.NET from the Asset Store being the only one that works atm iirc).
     
  24. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Tricky, the best I can think of would be using an attribute property editor. I'll look into it when I add multi-dimensional array support. I've added a comment to the GitHub issue to track it.
     
  25. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    A and B need to derive from UnityEngine.Object. An easy way to do this in 2.4 is to use SharedInstance<T>. Unity is taking an unusually long time to review the update, so if you want send me an email and I'll try to get you the submitted build when I can.
     
  26. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks! Looks like you figured out the issue. Let me know if there is anything I can do.
     
  27. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,551
    Yes, I imagine it needs that so devs can indicate what the "width" is if they want to represent it as a 2D array.
     
  28. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    I actually use 2.4.2 :)
    And I finally managed to get a workaround to that.
    I now use a list as a member, and keep A B as public properties that actually access the list. This way there's no serialization problems, and I can use the inspector seamlessly :D
     
    Last edited: Aug 9, 2014
  29. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    SharedInstance is similar to BaseScriptableObject in that regard i believe? except you don't need CreateAsset? or

    Any progress on preview/icon?

    Is there a new trial around for the temp leeches?

    thanks
     
  30. stevethorne

    stevethorne

    Joined:
    Apr 8, 2013
    Posts:
    16
    Is it possible to use the serialization portion of this while still using a custom inspector? I tried having my own custominspector over top of it, but noticed that it doesn't serialize properly anymore ( aka serializing the inheritance classes ) Will i need to use the serialization helpers to serialize the object into the scene file myself? or is there a function i can call in my custom inspector that will cause the object to serialize using one of the serializers ( fullserializer ) you provide?
     
  31. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    If I understand what you mean, you might wanna inherit from CommonBaseBehaviorEditor instead of just Editor.
     
  32. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I just noticed that 2.4 did get accepted -- please update! (Looks like I didn't get the normal package acceptance email).

    Ah, great! I don't recall if SharedInstance is in rc2, I think I added it in rc4.

    SharedInstance is exactly like a BaseScriptableObject instance, except that asset creation etc is automated.

    For the preview/icon, you need to create a custom behavior editor that also extends `fiIInspectorPreview`.

    I'll be pushing out the new trial either today or tomorrow, I just haven't had the time these past few days to build one.

    Yep, that's a good solution, but why are you trying to create a custom inspector? You should derive from `BehaviorEditor` instead of `Editor` if possible, then everything will work seamlessly.

    Thanks all!
     
  33. IkeMacoco_Spark

    IkeMacoco_Spark

    Joined:
    Apr 25, 2014
    Posts:
    3
    First of all I'd like to say that Full Inspector has been a great product and a life saver when it comes to Unity coding. After wrestling with Unity's poor serialization system ( so poor as if it was written by a novice) I just don't see how anyone can practice good design pattern and proper engine architecture without this product. Which says a lot about Unity's coding practice.

    Anyways, I thought I'd share this with everybody in case anyone finds it helpful: I just upgraded to 2.4 as well as Unity 4.5.3 and ran into the following assert whenever we ran our level in the editor:

    ms_IDToPointer->find (obj->GetInstanceID ()) == ms_IDToPointer->end ()

    The editor becomes unstable after this assert and crashes after a few editor operations. I reverted back to my previous version of Full Inspector and the assert doesn't happen.

    The assert is not very helpful, there's no callstack and it seems to be deep inside Unity. Worst of all you can't catch it in the debugger.

    After pulling my hair out for nearly a day, I've finally track down the problem in fiEditorSerializationManager. What seems to be happening is that fiEditorSerializationManager.RunDeserializations() seems to be called in the middle of an async level load. This is somehow causing a race condition with Unity's loading system causing the assert. To fix I prevent RunDeserializations() from executing in the middle of loading a level:

    public static void RunDeserializations() {
    //***BEGIN SPARK CHANGE
    // Do not deserialize in the middle of a level load that might be running on another thread
    // (asynchronous) which can lead to a race condition causing the following assert:
    // ms_IDToPointer->find (obj->GetInstanceID ()) == ms_IDToPointer->end ()
    if ( UnityEditor.EditorApplication.isPlaying && UnityEngine.Application.isLoadingLevel ) {
    return;
    }
    //***END SPARK CHANGE
    while (_toDeserialize.Count > 0) {
    ISerializedObject item = _toDeserialize.Dequeue();

    ......

    I'm not sure if this is the proper fix but it seems to be working so far.

    Thanks.
     
    Last edited: Aug 15, 2014
  34. vToMy

    vToMy

    Joined:
    Apr 19, 2013
    Posts:
    22
    Question -
    I have a MonoBahaviour with a member that needs a reference to its parent (the MonoBehaviour).
    That member is an interface with multiple implementations that I can pick in the inspector.
    However, when I select an implementation in the inspector, I can't give arguments to a constructor, nor is there some sort of callback that I know of, that I could use to set the parent of said member after I pick it.

    Example:
    Code (csharp):
    1.  
    2. public class MyBehaviour : BaseBehaviour {
    3.     public IFoo foo;
    4. }
    5.  
    6. public class Foo : IFoo {
    7.     public MyBehaviour parent;
    8. }
    9.  
    I would like to be able to set the parent of foo after I pick its implementation, with some sort of callback... There must be something I can use right?

    And another unrelated small question - every time I start the game the inspector folds out everything. Is there a way to keep it the same way it was before starting to play?
     
    Last edited: Aug 16, 2014
  35. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks -- looks like a nasty issue. RunDeserializations() is invoked from a custom editor window OnGUI function (and an EditorApplication.update call), which should both be on the primary thread, which makes the race conditions seem really strange. I'll include this fix in the next release.
     
  36. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry -- there are currently no good solutions. My eventual plan is to allow access to the parent object when working with a property editor which will some workaround for this (though even then it may not be pretty).

    However, can you drag and drop the MyBehaviour component reference onto the MyBehaviour field for now?

    Yep. You have to go into fiSettings.cs and set EnableMetadataPersistence to true; however, it is disabled by default. It usually works pretty well except on rare occasions if you have an infinite recursion in the inspector (which are hard to do but still technically possible with get accessors on structs), you'll get a 5-60s lock-up after every serialization cycle while the metadata is being deserialized.

    Thanks.
     
  37. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    I am trying to create a manager that can automatically find the scripts in other gameobjects and allow you to edit them in one place. For example, the following code finds all the Levels in my scene:

    Level.cs (assigned to many game objects)
    Code (CSharp):
    1. using FullInspector;
    2.  
    3. public class Level : BaseBehavior
    4. {
    5.     public int Id;
    6.     public string Name;
    7.     public string Description;
    8.     public string SceneName;
    9. }
    LevelManager.cs (assigned to single game object)
    Code (CSharp):
    1. using FullInspector;
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5.  
    6. [ExecuteInEditMode]
    7. public class LevelManager : BaseBehavior
    8. {
    9.     public List<Level> Levels;
    10.  
    11.     void Update ()
    12.     {
    13.         if(Application.isEditor)
    14.             Levels = FindObjectsOfType<Level>().ToList();  
    15.     }
    16. }
    Full Inspector shows a list of references to game objects.



    I can expose objects within a level and the editing from Manager will correctly update the referenced game objects. For example:

    Code (CSharp):
    1. using FullInspector;
    2. public class LevelDetails
    3. {
    4.     public int Id;
    5.     public string Name;
    6.     public string Description;
    7.     public string SceneName;
    8. }
    9.  
    10. public class Level : BaseBehavior
    11. {
    12.     public LevelDetails LevelDetails;
    13. }
    14.  
    Code (CSharp):
    1. using FullInspector;
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5.  
    6. [ExecuteInEditMode]
    7. public class LevelManager : BaseBehavior
    8. {
    9.     public List<LevelDetails> Levels;
    10.  
    11.     void Update()
    12.     {
    13.         if (Application.isEditor)
    14.             Levels = FindObjectsOfType<Level>().Select(l => l.LevelDetails).ToList();
    15.     }
    16. }
    17.  


    Is there an attribute or something i am missing that would allow a list to expose the base properties for editing instead of showing the gameObject selector control?
     
  38. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Hey tarahugger,

    Are you running on 2.4? For BaseBehavior derived types (or types with an associated BehaviorEditor), a dropdown is automatically shown that allows inline editing.

    level demo.gif

    Let me know if that helps.

    Thanks,
    Jacob
     
  39. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I'll be completing work on a feature that I"m really excited about: fiValue. fiValue allows Full Inspector usage without deriving from BaseBehavior. This means that Full Inspector is even easier to use and incrementally add to your project.

    If we have this simple inheritance hierarchy that we want to use in the inspector:

    Code (csharp):
    1.  
    2. public interface IInterface { }
    3. public class Derived1 : IInterface {
    4.     public int A;
    5. }
    6. public class Derived2 : IInterface {
    7.     public float B;
    8. }
    9. public class Derived3 : Derived2 {
    10.     public List<float> List;
    11. }
    12.  
    then we can utilize it while deriving from MonoBehaviour via

    Code (csharp):
    1.  
    2. // We have to make a non-generic type so that Unity will serialize it.
    3. [Serializable]
    4. public class fiValueIInterface : fiValue<IInterface> { }
    5.  
    6. public class ValueTests : MonoBehaviour {
    7.     public fiValueIInterface InterfaceValue;
    8. }
    9.  
    This is the generated inspector, running inside of a MonoBehaviour.

    fiValue Demo.gif

    (note: animations are disabled when using fiValue due to an issue with GUI.BeginArea and PropertyDrawers).
     
  40. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    Excellent, this was exactly what i needed. I was using the 2.3 trial.
     
  41. stevethorne

    stevethorne

    Joined:
    Apr 8, 2013
    Posts:
    16
    I'm running into an issue now where Full Serializer does not work for iOS out of the box. I'm not sure what it is I'm doing wrong, but these are the issues I'm getting with it.

    This looks like it's an issue with the arrays I have in my CutsceneManager class

    Code (error):
    1. ExecutionEngineException: Attempting to JIT compile method
    2. 'System.Linq.OrderedEnumerable`1<FullInspector.InspectedMember>:GetEnumerator
    3. ()' while running with --aot-only.
    4.  
    5. at
    6. System.Collections.Generic.List`1[FullInspector.InspectedMember].AddEnumerable
    7. (IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0
    8. at
    9. System.Collections.Generic.List`1[FullInspector.InspectedMember].AddRange
    10. (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
    11. at FullInspector.InspectedType..ctor (System.Type type) [0x00000] in
    12. <filename unknown>:0
    13. at FullInspector.InspectedType.Get (System.Type type) [0x00000] in
    14. <filename unknown>:0
    15. at FullInspector.InspectedType..ctor (System.Type type) [0x00000] in
    16. <filename unknown>:0
    17. at FullInspector.InspectedType.Get (System.Type type) [0x00000] in
    18. <filename unknown>:0
    19. at FullInspector.InspectedType..ctor (System.Type type) [0x00000] in
    20. <filename unknown>:0
    21. at FullInspector.InspectedType.Get (System.Type type) [0x00000] in
    22. <filename unknown>:0
    23. at FullInspector.InspectedType.RemoveProperty[IntPtr] (System.String
    24. propertyName) [0x00000] in <filename unknown>:0
    25. at FullInspector.InspectedType.InitializePropertyRemoval () [0x00000]
    26. in <filename unknown>:0
    27. at FullInspector.InspectedType..cctor () [0x00000] in <filename
    28. unknown>:0
    29. Rethrow as TypeInitializationException: An exception was thrown by the
    30. type initializer for FullInspector.InspectedType
    31. at
    32. FullInspector.Internal.BehaviorSerializationHelpers.RestoreState[FullSerializerSerializer]
    33. (ISerializedObject obj) [0x00000] in <filename unknown>:0
    34. at FullInspector.BaseBehavior`1[TSerializer].RestoreState () [0x00000]
    35. in <filename unknown>:0
    36. at FullInspector.BaseBehavior`1[TSerializer].Awake () [0x00000] in
    37. <filename unknown>:0
    38. at CutsceneManager.Awake () [0x00000] in <filename unknown>:0
     
  42. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    129
    Any chance of an extension to detect if current state has changed from saved state....
    To go along with obj.RestoreState(); and obj.SaveState(); maybe... obj.HasStateChanged()?
     
  43. IkeMacoco_Spark

    IkeMacoco_Spark

    Joined:
    Apr 25, 2014
    Posts:
    3
    Currently, properties with foldouts are open by default. Is there a way to make them collapse by default? I had a quick look at it by making the drop down meta data default to inactive but it seems to screw up the foldout animation and the heights of the properties are off. I thought I'd post before digging any further in case you have a quick and easy solution. Thanks and keep up the awesome work!
     
  44. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I think this is an issue with using OrderBy within LINQ. I'll implement a stable sort and use that instead. Thanks.

    Send me a PM or an email if you'd like the new build that includes the fix. If you're on skype, I would love to get in touch to work out any other iOS issues.

    Typically if something is edited in the inspector it'll be reserialized immediately (as of Unity 4.5, because Unity itself will send the serialization requests).

    The only good way I can think of to implement HasStateChanged() would be to serialize the object and check if the serialized state is different. Note however that FI tries hard to not serialize fields that Unity itself can serialize, so this will not work in the general case.

    You can also look into something like Compare .NET Objects if you make a duplicate of the object and then compare them for differences.

    You can also extend `ISerializationCallbacks` which FI will invoke whenever it does serialization/deserialization. Using those callbacks you could easily make a bool `wasModified`.

    I'm just curious, but why are you trying to do that you need said feature?

    I'll add something like [InspectorDefaultFoldoutState(false)] or similar for 2.5. Please send me either a PM or an email if you would like the preview build.

    Thanks.
     
  45. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Is there a way to define a list of ScriptableObjects that implements only a specific interface?
    I tried to use
    List<IDataContainer> settings;
    But as soon I choose one of the implementation listed in the inspector dropdown it raises an exception:

    Attempting to recover from serialization error
    Error converting value 0 to type 'BRA.Framework.Data.IDataContainer'.
    Member: 0
    OriginalObject: System.Collections.Generic.List`1[BRA.Framework.Data.IDataContainer]
    Exception: Newtonsoft.Json.JsonSerializationException: Error converting value 0 to type 'BRA.Framework.Data.IDataContainer'. ---> System.Exception: Could not cast or convert from System.Int64 to BRA.Framework.Data.IDataContainer.
    at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable (System.Object value, System.Type initialType, System.Type targetType) [0x00059] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Utilities/ConvertUtils.cs:453
    at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast (System.Object initialValue, System.Globalization.CultureInfo culture, System.Type targetType) [0x00036] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Utilities/ConvertUtils.cs:375
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (System.Object value, System.Globalization.CultureInfo culture, System.Type targetType) [0x00016] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:491
    --- End of inner exception stack trace ---
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType (System.Object value, System.Globalization.CultureInfo culture, System.Type targetType) [0x0002a] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:495
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue) [0x00089] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:233
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract) [0x0002a] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:210
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IWrappedCollection wrappedList, Newtonsoft.Json.JsonReader reader, System.String reference, Newtonsoft.Json.Serialization.JsonArrayContract contract) [0x00094] in /Users/mcmorry/Lavoro/RoadRacer/Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:735
    UnityEngine.Debug:LogWarning(Object)
    FullInspector.JsonNetSerializer:HandleError(Object, ErrorEventArgs) (at Assets/FullInspector2/Serializers/JsonNet/JsonNetSerializer.cs:76)
    Newtonsoft.Json.JsonSerializer:OnError(ErrorEventArgs) (at Assets/Plugins/JsonDotNet/Source/JsonSerializer.cs:484)
    Newtonsoft.Json.Serialization.JsonSerializerInternalBase:IsErrorHandled(Object, JsonContract, Object, Exception) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalBase.cs:103)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:populateList(IWrappedCollection, JsonReader, String, JsonArrayContract) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:741)
    Newtonsoft.Json.Serialization.<CreateAndPopulateList>c__AnonStorey82:<>m__83(IList, Boolean) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:681)
    Newtonsoft.Json.Utilities.CollectionUtils:CreateAndPopulateList(Type, Action`2) (at Assets/Plugins/JsonDotNet/Source/Utilities/CollectionUtils.cs:604)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:CreateAndPopulateList(JsonReader, String, JsonArrayContract) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:671)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:CreateList(JsonReader, Type, JsonContract, JsonProperty, Object, String) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:462)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:CreateValueInternal(JsonReader, Type, JsonContract, JsonProperty, Object) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:227)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:CreateValueNonProperty(JsonReader, Type, JsonContract) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:210)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader:Deserialize(JsonReader, Type) (at Assets/Plugins/JsonDotNet/Source/Serialization/JsonSerializerInternalReader.cs:122)
    Newtonsoft.Json.JsonSerializer:DeserializeInternal(JsonReader, Type) (at Assets/Plugins/JsonDotNet/Source/JsonSerializer.cs:424)
    Newtonsoft.Json.JsonSerializer:Deserialize(JsonReader, Type) (at Assets/Plugins/JsonDotNet/Source/JsonSerializer.cs:416)
    Newtonsoft.Json.JsonConvert:DeserializeObject(String, Type, JsonSerializerSettings) (at Assets/Plugins/JsonDotNet/Source/JsonConvert.cs:755)
    FullInspector.JsonNetSerializer:Deserialize(MemberInfo, String, ISerializationOperator) (at Assets/FullInspector2/Serializers/JsonNet/JsonNetSerializer.cs:121)
    FullInspector.Internal.BehaviorSerializationHelpers:RestoreState(ISerializedObject) (at Assets/FullInspector2/Core/BehaviorSerializationHelpers.cs:151)
    FullInspector.BaseBehavior`1:RestoreState() (at Assets/FullInspector2/Core/BaseBehavior.cs:59)
    FullInspector.BehaviorEditor`1:CheckForPrefabChanges(Object) (at Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs:118)
    FullInspector.BehaviorEditor`1:SceneGUI(Object) (at Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs:22)
    FullInspector.FullInspectorCommonSerializedObjectEditor:OnSceneGUI() (at Assets/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:77)
    UnityEditor.DockArea:OnGUI()

    Any clue?
    Thanks
     
  46. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    The limitation here is how Json.NET handles custom converters and inheritance -- I suggest using Full Serializer, which handles this scenario properly. You can use it just for that specific behavior instead of changing your entire project over.

    So instead of having this

    Code (csharp):
    1.  
    2. public class MyBehavior : BaseBehavior { /* ... */ }
    3.  
    use this

    Code (csharp):
    1.  
    2. public class MyBehavior : BaseBehavior<FullSerializerSerializer> { /* ... */ }
    3.  
     
  47. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Wow it works very well :)
    Thanks

    If only Full Serializer was available when I started the project, I could have it as the default one. Now is too late, or I'd lose all the serialized data. A method to convert from one format to another automatically would be the solution, but I suppose that it's not possible :(
     
  48. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    The InspectorCommentAttribute should have CommentType.None as default but the constructor has .Info
     
  49. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    CommentType.Info is intentionally the default -- seems more appropriate, as the `None` doesn't look as pleasing. Further, the comment is typically meant to draw the reader's attention. Drawing no icon is still easily doable, just slightly more typing.
     
  50. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Mmhh... personally I don't agree. I used intensively on previous version as a description of the field and now suddenly the inspector is full of Icons.
    Anyway is your choice, but in that case I suggest you to fix the comment in the CommentType enum that states:
    Code (CSharp):
    1. /// <summary>
    2. /// No header. This is the default comment style.
    3. /// </summary>
    4. None = 0,