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. Alec-Slayden

    Alec-Slayden

    Joined:
    Dec 16, 2008
    Posts:
    101
    Oops Sorry, thanks =)
     
  2. Deleted User

    Deleted User

    Guest

    :( So what's the point of the static inspector then? If I want to look at variables I can just open the class itself.
     
  3. bilke

    bilke

    Joined:
    Jul 13, 2012
    Posts:
    54
    I have a BaseBehaviour with a custom editor using the ToolKit. Now I need add a Handle for which I need to implement OnSceneGUI. I tried tried to use a [CustomBehaviorEditor] and implemented OnSceneGUI() there which works but then I see Unity's default inspector and not the custom editor. Is it possible to have a custom editor with a OnSceneGUI() implementation?
     
  4. boysenberry

    boysenberry

    Joined:
    Jul 28, 2014
    Posts:
    365
    Hi and am just getting started with Full Inspector and decided to see about using JSON.NET together with Full Inspector, is that possible or are they mutually exclusive? Currently I am getting complaints about ambiguous references to the JProperty property. I tried removing the Full Inspector version of JSON hoping that It would allow me to switch to using JSON.NET, alas no go.

    Is what I am trying to do the wrong way to go about using serialization, e.g. only one serializer tech, not two.
    Any help would be much appreciated, I am hoping for AOT serialization to allow for game closing without data loss.

    Thanks in advance,
    Boysenberry Payne
     
  5. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    The values inside of static values often change at runtime. The static inspector lets you easily determine their current values. Another great user-case (which I use) is that if you're writing inspector code and have constants as static variables, you can very easily tweak those constants in real-time and see the changes immediately without going through a compile cycle.
     
    Deleted User likes this.
  6. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sure, derive from tkCustomBehaviorEditor instead of BehaviorEditor and then override GetControlEditor to return the tk editor that you made.
     
  7. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    That's really strange. You can use multiple serializers at the same time - there shouldn't be any issues there. Did you see these instructions for installing Json.NET?

    As a heads up, Full Serializer also supports AOT compilation (as of FI 2.6.1), though I'm a bit confused by "to allow for game closing without data loss". AOT compilation doesn't deal with this issue afaik.
     
  8. bilke

    bilke

    Joined:
    Jul 13, 2012
    Posts:
    54
    Unfortunately I cannot find tkCustomBehaviorEditor in FI 2.6?
     
  9. boysenberry

    boysenberry

    Joined:
    Jul 28, 2014
    Posts:
    365

    Thanks for the quick response. I was a bit confused about the purpose behind AOT, just read up on it, so no more confusion. I am reading over the instruction for installing JSON.NET now, thank you. I wasn't aware that Full Serializer supported AOT, which now that I know what it is, I am grateful for.

    I am going to go ahead and setup JSON.NET just because I have it now to see how I do. If I run into any snags after RTFMing, I will come back for more advice.

    Thank you for you help and most amazing asset!

    Boysenberry Payne
     
  10. boysenberry

    boysenberry

    Joined:
    Jul 28, 2014
    Posts:
    365
    Update to my last post, I followed the instructions and it worked like a charm, thank you.

    Now I am wondering if I should use JSON.NET for serialization though. Are there any advantages to using it over Full Serializer? I still get to use Full Serializer's features with it, right? I was drawn to JSON.NET by your documentation actually. It sounded like the right choice for platform compatibility, etc.

    Honestly, while I understand serialization and have used it for years programatically, its always been very intentional and specific in my usage.

    In Unity it still seems almost like who knows what's getting serialized or not because its all done behind the scenes with everything public of a specific type getting serialized unless specified otherwise, etc., but only if its not in particular situation like behind a property handler, etc.

    Full Serializer has opened the whole thing up for me a lot more, so once again, thank you!

    Boysenberry Payne
     
  11. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    What do you mean by this? My game is crashing in Android and I'm getting error in iOS. Do I need to JSON.net from the asset store?
     
  12. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Alright I just read this, and will try.
     
  13. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    I added JSON.net for Unity. I can now build on iOS but I get this runtime error from XCode.

    Code (CSharp):
    1. ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.Dictionary`2<int, TicToc.KittyPawp.IBubble>:.ctor (System.Collections.Generic.IDictionary`2<int, TicToc.KittyPawp.IBubble>)' while running with --aot-only.
    Can anyone help me? Are there extra steps when building for iOS?
     
  14. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry, it is available in 2.6.1. It should be available on the asset store right now.
     
  15. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    The only reason I'd recommend Json.NET over Full Serializer is that it might be faster - honestly though, I'm not sure - I haven't benchmarked FS against other serializers.

    Json.NET should serve you well, but there are a few user-stories where it just doesn't work as you want. One of the prominent issues that people have often run into is when you have an interface and a UnityObject derived type, ie,

    Code (csharp):
    1.  
    2. public interface IFace {}
    3. public class MyImpl : BaseBehavior, IFace {}
    4.  
    5. public class TestObject : BaseBehavior {
    6.     public IFace field;
    7. }
    8.  
    If you create add an instance of TestObject to a GameObject and select MyImpl as the implementation type, with Json.NET this will not serialize correctly (inheritance and converters do not mix - all types which derive from UnityEngine.Object have a custom converter applied). However, this same scenario will work fine in Full Serializer.

    Sure, if you have any questions about it feel free to ask. I'm happy to answer :).
     
  16. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Hey,

    iOS should just work. It looks like you are using the mono AOT compilation which afaik cannot be used to publish apps anymore - instead you have to switch over to il2cpp.

    I think you can resolve the generics issue with the mono AOT compiler by adding something like this to your project:

    Code (csharp):
    1.  
    2. // I don't believe you ever have to actually invoke this code - just have the generic types somewhere so mono will bake the generic parameters
    3. public static class _AotGenerics {
    4.     static _AotGenerics() {
    5.         IDictionary<int, TicToc.KittyPawp.IBubble> a = new Dictionary<int, TicToc.KittyPawp.IBubble>();
    6.     }
    7. }
    8.  
     
  17. sient

    sient

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

    As a heads up, 2.6.1 is now live in the asset store. Make sure to update! See this post for more information on the update.

    Jacob
     
  18. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi sient,

    Having one issue in both 2.6 and 2.6.1. When serializing a BaseScriptableObject or SharedInstance<T> using FullSerializer, I'm getting some extra json output after the serialized data, in the form of:

    Code (CSharp):
    1. "_objectReferences": {
    2.         "$content": []
    3.     },
    4. "_serializedStateKeys": {
    5.         "$content": [
    6.             "Instance"
    7.         ]
    8.     },
    9. "_serializedStateValues": {
    10.         "$content": [
    11.             ***with the serialized data repeated again here with /r/n after each property
    12.         ]
    13.     },
    14. $type":
    etc.

    My process is to create an InspectorButton in either the BaseScriptableObject or SharedInstance<T> which loads them via Resources.Load, and then serializes them to json. This is so that modders can alter the info there. I then load the deserialized version into the game during runtime.

    Serializing regular classes doesn't add the extra json stuff. Having the extra json output doesn't affect the data in any way, but it's a little confusing visually. On the one hand, the content in _serializedStateValues can be useful as a reference to see what the original info was before being modded, as it displays what my original values are. But I was wondering if there is a way to not have it printed?

    Also, in 2.6.1 the column alignment in the inspector now seems to be dependent on the length of each variable or property name, not uniform as it was before. Was this by design?

    Thanks.
     
    Last edited: Apr 18, 2015
  19. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    Hi @sient , Is there a way to NOT serialize properties using....

    Code (CSharp):
    1. SerializationHelpers.SerializeToContent<SomeClass, JsonNetSerializer>(test);
    What about not serializing private fields? I only want to serialize my public fields.

    Edit: looks like private fields arent serialized by default.
     
    Last edited: Apr 18, 2015
  20. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    This post says that there is such a thing called [JsonIgnore] but I can't find it in this plugin and Json.Net for Unity.
     
  21. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    This is a known issue with Full Serializer (see here) where excess data gets emitted. The values will still deserialize properly as, ie,

    Code (csharp):
    1.  
    2. "_serializedStateValues": [
    3.     ***with the serialized data repeated again here with /r/n after each property
    4. ],
    5.  
    Would you mind sending me a screenshot? I made some changes, but the alignment should be significantly more uniform now.
     
  22. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    SerializationHelpers.SerializeToContent is pretty simple - it basically just pipes the two parameters directly to the serializer. If you want to customize serialization at all you'll have to customize the class you are serializing with the specific annotations.

    I'm not sure what's going on here. The type [Newtonsoft.Json.JsonIgnore] is not available? Unity fails to compile if you type that above a field or property? Are there any error logs?
     
  23. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    @sient Thanks for the awesome assets!

    I'm using FullSerializer and am running into an issue I'm hoping you can help me figure out. My entire goal is to deserialize into an existing object. It's very possible I'm going about this completely wrong :p

    I'm trying to load data from a file into an existing object (which is a SerializedObject). It worked great until I added a TestItem to MySaveFile. In this example, I set the TestObject.ignoreString = "test". After calling Load() on MySaveFile, ignoreString == "", instead of "test". The [fsIgnore] variable fileName doesn't get reset so I can't figure out why ignoreString is. I'm guessing the Test instance is being replaced.

    Code (CSharp):
    1.  
    2. using FullSerializer;
    3.  
    4. [System.Serializable]
    5. public class MySaveFile : BaseSaveFile
    6. {
    7.     public TestItem testItem;
    8. }
    9.  
    10. [System.Serializable]
    11. public class TestItem
    12. {
    13.     [fsIgnore]
    14.     public string ignoreString = "";
    15.  
    16.     public string serializeString = "";
    17. }
    18.  
    19. [System.Serializable]
    20. public class BaseSaveFile : ScriptableObject
    21. {
    22.     private static readonly fsSerializer _serializer = new fsSerializer();
    23.  
    24.     [fsIgnore]
    25.     public string fileName = "";
    26.  
    27.     public int fileVersion = 0;
    28.  
    29.     public void Load()
    30.     {
    31.         DeserializeIntoObj(GetType(), GetTextFromFile(), this);
    32.     }
    33.  
    34.     private void DeserializeIntoObj(Type type, string serializedState, object deserializeInto)
    35.     {
    36.         fsData data = fsJsonParser.Parse(serializedState);
    37.  
    38.         _serializer.TryDeserialize(data, type, ref deserializeInto).AssertSuccessWithoutWarnings();
    39.     }
    40.  
    41.     private string GetTextFromFile()
    42.     {
    43.         // truncated for brevity
    44.         return "";
    45.     }
    46. }
    47.  
    Edit: here is an example project showing the issue.
     
    Last edited: Apr 19, 2015
  24. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    I sent you an email with two pics, thanks.
     
  25. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    It looks like the scene file in the project didn't get saved properly. I'll take a closer look if you can update the project, but my hunch says that is has to do with

    Code (csharp):
    1.  
    2. [Serializable]
    3. public class TestItem
    4. {
    5.     [fsIgnore]
    6.     public string ignoreString = "";    // this is the problem - this gets wiped on deserialize (or the entire object is)
    7.  
    8.     public string serializeString = "";
    9. }
    10.  
    Does removing [Serializable] fix the issue?
     
  26. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks!
     
  27. blindgoat

    blindgoat

    Joined:
    Oct 24, 2012
    Posts:
    31
    I appreciate your help. I opened the project on another computer and it worked fine :S. It's using Unity 5.0.1f1. I know my buddy got the same blank scene issue until he updated to the latest version of Unity. I tweaked a few things and uploaded it to the same spot. Hopefully it works this time.

    Removing [System.Serializable] makes it so TestItem isn't serialized in the ScriptableObject which is not what I want.

    If the scene doesn't work again, you can try following these steps:
    1. Make an empty GameObject and attach TestSaver.cs to it
    2. Drag the TestSaveFile ScriptableObject into the new TestSaver's saveFiles array
    3. Look at the TestSaveFile ScriptableObject in the Project window and note that ignoreString == "test"
    4. Run project which will:
      1. Serialize TestSaveFile and write the data to disk
      2. Load save file from disk into the TestSaveFile ScriptableObject. Note that ignoreString is now empty
     
    Last edited: Apr 20, 2015
  28. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    Wonderful. Update broke build. Deleted all FullInspector files, re-imported everything. Now FullInspecter generated files aren't being generated and none of the full inspector classes are being detected by Unity or VS for that matter.

    It seems the solution to all of this was to remove all the FullInspector classes, which allows Unity to compile without errors, which then allows FullInspector to run the code to generate the necessary classes. This seems like a fairly massive install-flow oversight.
     
  29. zee_ola05

    zee_ola05

    Joined:
    Feb 2, 2014
    Posts:
    166
    using Newtonsoft.Json is what I'm looking for! Thanks!
     
  30. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Okay, I'm updating Unity. I'll take a look when that update finishes.
     
  31. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry to hear that :(. I separated out the Generated folder from the root FullInspector directory so that this would not happen (assuming that the generated folder is not removed). If it does get removed, I have some docs/guides here that allow you to download premade generated folders.
     
  32. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Great! Happy to help :)
     
  33. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Okay, I've found the issue within Full Serializer. I've fixed it in this commit.
     
  34. Vorren

    Vorren

    Joined:
    Oct 24, 2014
    Posts:
    19
    Hey sient,
    you seem to have changed the way dictionaries are serialized in fullserializer - it is not backwards compatible.
    Was:
    Code (CSharp):
    1. _serializedStateKeys:
    2.   - myDict
    3.   _serializedStateValues:
    4.   - '[{"Key":{"$content":"keyname","$type":"System.String"},"Value":{}}]
    5.  
    Became:
    Code (CSharp):
    1. _serializedStateKeys:
    2.   - myDict
    3.   _serializedStateValues:
    4.   - '{"keyName":{}}
    It breaks deserialization and makes it more difficult to update FI.
     
  35. Vorren

    Vorren

    Joined:
    Oct 24, 2014
    Posts:
    19
    Actually it seems that deserialization is backwards compatible - some dictionaries work fine. It fails with really complex object as value. It didn't fail in 2.6
     
  36. Vorren

    Vorren

    Joined:
    Oct 24, 2014
    Posts:
    19
    Hey sient, I found the cause of the problem I mentioned above:
    fxMetaType.cs line 244 causes NullReference exception when ctor is null;
    I added null checking and it all works well now:
    Code (CSharp):
    1. _hasDefaultConstructorCache = ctor != null;
    2. if(_hasDefaultConstructorCache.Value){
    3. _isDefaultConstructorPublic = ctor.IsPublic;
    4. }
     
  37. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    It would have been really if I broke backwards compatibility; I try extremely hard to not do that.

    Awesome! Thanks. I appreciate the fix. I've committed it to the repository here.
     
  38. Vorren

    Vorren

    Joined:
    Oct 24, 2014
    Posts:
    19
    Hey sient,
    It seems that there is a bug concerning BaseObject: I have a BaseScriptableObject-inherited class, that has a Dictionary, which stores keys:Enum values and values: BaseObject-derived class instances. Those instances have GameObject's as fields (basically - prefab configuration). For some reason that I haven't yet uncovered references to gameobjects are lost and not serialized properly. An older (pre-update) version of the asset referenced a bunch of prefabs, now it references only 4 of more than 60, and all slots previously occupied by those prefabs are now replaced with one of those 4 remaining prefabs.
    You did some heavy refactoring in BaseObject, so I suggest that you take a closer look at the class.
     
  39. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    This sounds like a pretty major issue that I want to get resolved ASAP. I've sent you a PM with more details.
     
  40. denlee0710

    denlee0710

    Joined:
    Mar 9, 2015
    Posts:
    36
    Hi sient,

    I've found a scenario where Full Serializer's processor (and I assume converter too) does not work correctly.

    We have an ISavaData interface with several implementations. Our save/load code passes around ISaveData objects for general processing and serialization/deserialization. This all works fine until we tried to add a processor to one of the SaveData implementations, and use fsObjectAttribute to register the processor.

    If we call serialization with this:
    Code (CSharp):
    1. ISaveData saveData = GetSaveData();
    2. fsResult result = serializer.TrySerialize(saveData, out data);
    Then processor won't be invoked because typeof(saveData) is ISaveData and there's no processor registered for it.

    So naturally we tried the other way:
    Code (CSharp):
    1. fsResult result = serializer.TrySerialize(saveData.GetType(), saveData, out data);
    This serializes fine and processor was invoked, but ran into a problem when deserializing:
    Code (CSharp):
    1. ISaveData saveData;
    2. fsResult result = serializer.TryDeserialize(data, ref saveData);
    Type information is not recorded if storage type and instance type is the same, and the deserializer mistakenly thought they are actually the same because we passed in .GetType(), its actual type, as argument. So with no type information recorded it tries to instantiate ISaveData, which of course throws an exception. We cannot pass the actual type because we do not know what the type is at the time of deserialization.

    I'm not sure how exactly is the best way to approach this. I could change the part of the code in fsSerializer.cs so that it always records type information so that it works for now, but I would rather not have to modify the source of a plugin for future compatibility, and I'm not sure if this is a change you want.

    Any ideas?
     
  41. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks, this should be fixed as of this commit.
     
    denlee0710 likes this.
  42. denlee0710

    denlee0710

    Joined:
    Mar 9, 2015
    Posts:
    36
    Thanks sient that was fast!

    Another thing I found, in fsResult:
    Code (CSharp):
    1. public bool HasWarnings {
    2.     get {
    3.         return _messages.Any();
    4.      }
    5. }
    This throws NullReferenceException if _messages is null. I'm not sure if that is intended behavior, but if not perhaps should use RawMessages instead?
     
  43. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Ha, thanks. I've fixed this issue in this commit.
     
  44. tthmok

    tthmok

    Joined:
    Apr 16, 2014
    Posts:
    3
    Unity 5
    FI 2.6.1
    These problems also existed in FI 2.6

    I'm having some trouble in a large project and I haven't been able to reproduce in a smaller test project but hopefully I could be pointed in the right direction for what I might want to look at. The problem is if I just take these 2 classes that look like they are having issues and put them into a new project the errors don't occur. There are no other errors in the logs that point me anywhere else so I'm having a hard time figuring out what's going wrong. These errors generally lead to a crash of the Unity Editor once code compiles/recompiles.

    Here's the error as it looks in the Unity editor log

    Exception caught when deserializing property <Items> in <Shop_Farm (Inventory.InventoryItemList)>
    System.ArgumentException: not of type:Inventory.InventoryItem
    Parameter name: value
    at System.Collections.Generic.Dictionary`2[System.String,Inventory.InventoryItem].ToTValue (System.Object value) [0x0002f] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:656
    at System.Collections.Generic.Dictionary`2[System.String,Inventory.InventoryItem].System.Collections.IDictionary.Add (System.Object key, System.Object value) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:671
    at FullSerializer.Internal.fsDictionaryConverter.AddItemToDictionary (IDictionary dictionary, System.Object key, System.Object value) [0x00080] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/Converters/fsDictionaryConverter.cs:154
    at FullSerializer.Internal.fsDictionaryConverter.TryDeserialize (FullSerializer.fsData data, System.Object& instance_, System.Type storageType) [0x00202] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/Converters/fsDictionaryConverter.cs:57
    at FullSerializer.fsSerializer.InternalDeserialize_5_Converter (FullSerializer.fsData data, System.Type resultType, System.Object& result) [0x0001d] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:741
    at FullSerializer.fsSerializer.InternalDeserialize_4_Cycles (FullSerializer.fsData data, System.Type resultType, System.Object& result) [0x00034] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:733
    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x00109] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:712
    at FullSerializer.fsSerializer.InternalDeserialize_2_Version (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x000f8] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:652
    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1& processors) [0x0004a] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:616
    at FullSerializer.fsSerializer.TryDeserialize (FullSerializer.fsData data, System.Type storageType, System.Object& result) [0x0003f] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/Module/Source/fsSerializer.cs:587
    at FullInspector.FullSerializerSerializer.Deserialize (System.Reflection.MemberInfo storageType, System.String serializedState, ISerializationOperator serializationOperator) [0x00028] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/FullSerializer/FullSerializerSerializer.cs:93
    at FullInspector.Internal.fiISerializedObjectUtility.RestoreState[FullSerializerSerializer] (ISerializedObject obj) [0x0016e] in /Users/tthmok/Documents/projects/game/Assets/FullInspector2/Core/fiISerializedObjectUtility.cs:209
    UnityEngine.Debug:Internal_Log(Int32, String, Object)
    UnityEngine.Debug:LogError(Object, Object)
    FullInspector.Internal.fiISerializedObjectUtility:RestoreState(ISerializedObject) (at Assets/FullInspector2/Core/fiISerializedObjectUtility.cs:216)
    FullInspector.BaseScriptableObject`1:RestoreState() (at Assets/FullInspector2/Core/BaseScriptableObject.cs:59)
    FullInspector.BaseScriptableObject`1:OnValidate() (at Assets/FullInspector2/Core/BaseScriptableObject.cs:41)
    UnityEditor.AssetDatabase:LoadAssetAtPath(String, Type)
    FullInspector.Internal.AssetDatabase:LoadAssetAtPath(String, Type) (at Assets/FullInspector2/Core/fiLateBindings.cs:81)
    FullInspector.Internal.fiPersistentEditorStorage:get_PrefabStorage() (at Assets/FullInspector2/Modules/PersistentMetadata/fiPersistentEditorStorage.cs:153)
    FullInspector.Internal.fiPersistentEditorStorage:Read(Object) (at Assets/FullInspector2/Modules/PersistentMetadata/fiPersistentEditorStorage.cs:33)
    FullInspector.Internal.fiPersistentEditorStorageMetadataProvider`2:RestoreData(Object) (at Assets/FullInspector2/Modules/PersistentMetadata/fiPersistentEditorStorageMetadataProvider.cs:14)
    FullInspector.fiPersistentMetadata:GetMetadataFor(Object) (at Assets/FullInspector2/Modules/PersistentMetadata/fiPersistentMetadata.cs:52)
    FullInspector.Internal.fiGraphMetadataSerializer`1:UnityEngine.ISerializationCallbackReceiver.OnBeforeSerialize() (at Assets/FullInspector2/Modules/PersistentMetadata/fiGraphMetadataSerializer.cs:32)


    Shop_Farm is of type Inventory.InventoryItemList
    Code (csharp):
    1. public class InventoryItemList : BaseScriptableObject<FullSerializerSerializer>
    2.     {
    3.         public string Header;
    4.         public Sprite Icon;
    5.         public bool RandomizeItems = false;
    6.         public int RandomItemAmount = 5;
    7.         public Dictionary<string, InventoryItem> Items;
    8.  
    9.         public InventoryItem ItemForName (string name)
    10.         {        
    11.             InventoryItem item;
    12.             if (Items.TryGetValue (name, out item)) {
    13.                 return item;
    14.             }
    15.             return null;
    16.         }
    17.     }
    18.    
    The <Item> in question is of type Inventory.InventoryItem
    Code (csharp):
    1.  
    2. [System.Serializable] // @TODO more properties for build time
    3. public class BuildTime {
    4.     public int Seconds = 0;
    5. }
    6.  
    7. public class InventoryItem : BaseScriptableObject<FullSerializerSerializer> {
    8.         public int order;
    9.         public string title = "New item";
    10.         public string description = "New Description";
    11.  
    12.         [InspectorDividerAttribute]
    13.         public BuildTime BuildTime;
    14.         [InspectorDividerAttribute]
    15.  
    16.         public Sprite icon = null;
    17.         public Vector2 iconSize = new Vector2(-1f,-1f);
    18.         public int MaxAmountPurchasable = 99;
    19.         public bool HideIfPurchased = false;
    20.         public bool HideIfRequirementsNotMet = true;
    21.         public bool ShowInInventory = true;
    22.         public bool ShowItemInfoButton = true;
    23.  
    24.         [InspectorRange(0f, 400)]
    25.         public int Calories;
    26.         [InspectorRange(0f, 400)]
    27.         public int Nutrients;
    28.  
    29.         public ItemType itemType;
    30.  
    31.         public enum ItemType
    32.         {
    33.             Food,
    34.             Consumable,
    35.             Outfit,
    36.             Permanent,
    37.             Buildings,
    38.             Building_Upgrades,
    39.             Furniture
    40.         }
    41.  
    42.         public Color color = Color.white;
    43.      
    44.         public abstract class ItemComparer : IComparer<InventoryItem>
    45.         {
    46.             public abstract int Compare (InventoryItem x, InventoryItem y);
    47.         }
    48.  
    49.         public class OrderComparer : ItemComparer
    50.         {
    51.             #region IComparer implementation
    52.             public override int Compare (InventoryItem x, InventoryItem y)
    53.             {
    54.                 if(x == null || y == null){
    55.                     Debug.Log("null");
    56.                 }
    57.                 return x.order - y.order;
    58.             }
    59.             #endregion
    60.         }
    61.     }
    62.  
    Printed out the 'state' info during the error it looks like this
    Code (csharp):
    1. state:{"Corn":0,"Milk":1,"Mushroom":2,"Onion":3,"Eggplant":4,"Raddish":5,"Lettuce":6,"Tomato":7,"Soybeans":8,"Watermelon":9,"Strawberry":10}
    Regardless of the list size and which items I put into it the failure always happens on the first item. Here is a look at what the Shop_Farm and the Corn asset look like.

    Shop_Farm:
    Code (csharp):
    1. %YAML 1.1
    2. %TAG !u! tag:unity3d.com,2011:
    3. --- !u!114 &11400000
    4. MonoBehaviour:
    5.   m_ObjectHideFlags: 0
    6.   m_PrefabParentObject: {fileID: 0}
    7.   m_PrefabInternal: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 1ac0d787636bb4133b89437d1bb5eadf, type: 3}
    12.   m_Name: Shop_Farm
    13.   m_EditorClassIdentifier:
    14.   _objectReferences:
    15.   - {fileID: 11400000, guid: a6d5c52f89afd4904afcfcd522de2f92, type: 2}
    16.   - {fileID: 11400000, guid: bce5d66040e3d4049b1950dd241d46fa, type: 2}
    17.   - {fileID: 11400000, guid: 53703c596824d462a9ffed632aa33c88, type: 2}
    18.   - {fileID: 11400000, guid: 97f44867b287a45c9b64ef96fe79bb4f, type: 2}
    19.   - {fileID: 11400000, guid: bc43348ac83ac4775888a079a7c12e7d, type: 2}
    20.   - {fileID: 11400000, guid: b4d34ea5ac278401e947c501dc52b8bc, type: 2}
    21.   - {fileID: 11400000, guid: e146ab458362148a8b98b6dabaaa2f2e, type: 2}
    22.   - {fileID: 11400000, guid: 9f0d2e5e83f004c7d86cc0545207983c, type: 2}
    23.   - {fileID: 11400000, guid: 733d1190424994ba599ea6b85bfdd7dd, type: 2}
    24.   - {fileID: 11400000, guid: ad51d2dfede9147c7a81af330c2e2d48, type: 2}
    25.   - {fileID: 11400000, guid: 40b746e070ad74bc4b24a48c7ab05db3, type: 2}
    26.   _serializedStateKeys:
    27.   - Items
    28.   _serializedStateValues:
    29.   - '{"Corn":0,"Milk":1,"Mushroom":2,"Onion":3,"Eggplant":4,"Raddish":5,"Lettuce":6,"Tomato":7,"Soybeans":8,"Watermelon":9,"Strawberry":10}'
    30.   Header: Farm
    31.   Icon: {fileID: 21300000, guid: c3f204af4b0cf45f89915e24cfb5c00d, type: 3}
    32.   RandomizeItems: 1
    33.   RandomItemAmount: 4
    34.  
    Corn:
    Code (csharp):
    1. %YAML 1.1
    2. %TAG !u! tag:unity3d.com,2011:
    3. --- !u!114 &11400000
    4. MonoBehaviour:
    5.   m_ObjectHideFlags: 0
    6.   m_PrefabParentObject: {fileID: 0}
    7.   m_PrefabInternal: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 29c3b5e51c0b0440db9bd797c07a3320, type: 3}
    12.   m_Name: Corn
    13.   m_EditorClassIdentifier:
    14.   _objectReferences: []
    15.   _serializedStateKeys:
    16.   - BuildTime
    17.   - iconSize
    18.   - itemType
    19.   - color
    20.   _serializedStateValues:
    21.   - '{"Seconds":0}'
    22.   - '{"x":-1.0,"y":-1.0}'
    23.   - '"Food"'
    24.   - '{"r":1.0,"g":1.0,"b":1.0,"a":1.0}'
    25.   order: 0
    26.   title: Corn
    27.   description:
    28.   BuildTime:
    29.     Seconds: 0
    30.   icon: {fileID: 21300000, guid: 65edf0cb2ec954208bf910aeed89cc60, type: 3}
    31.   iconSize: {x: -1, y: -1}
    32.   MaxAmountPurchasable: 99
    33.   HideIfPurchased: 0
    34.   HideIfRequirementsNotMet: 1
    35.   ShowInInventory: 1
    36.   ShowItemInfoButton: 0
    37.   Calories: 400
    38.   Nutrients: 0
    39.   itemType: 0
    40.   color: {r: 1, g: 1, b: 1, a: 1}
    41.  
     
    Last edited: Apr 29, 2015
  45. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Are you able to send me the project? I'd like to take a closer look. I have a feeling this is because the UnityEngine.Object references are getting messed up somehow.
     
  46. nikkolas-golesh

    nikkolas-golesh

    Joined:
    May 3, 2015
    Posts:
    4
    Unity 5

    We are experiencing and issue where one specific component on an object is not serialized using Full Inspector and instead trying to use the default Unity inspector. We have copied the behavior code exactly to a different component and it will then serialize properly using Full Inspector but under a different component name. But we would like to avoid this fix to the problem if there is a different solution. We have also tried removing the behavior script and creating it again with the same name and then pasting the same code back in but it will still not serialize properly.
     
  47. Remiel

    Remiel

    Joined:
    Oct 17, 2012
    Posts:
    105
    I just wanted to drop by and say that both Full Inspector and its developer are AMAZING!
    I've been bothering him for weeks with improvement requests yet he has never lost his patience and has always been most helpful - in most cases implementing my suggestions in under a day!
    If there is any of you out there not sure whether you should give Full Inspector a try - just do it! And if you run into any issues, no fear - the support is quick and amazing!
     
    Deleted User likes this.
  48. Deleted User

    Deleted User

    Guest

    Are you still having this issue? I had this issue and figured out that "Awake" was the cause of it. Deleting my Awake function solved it.
     
  49. nikkolas-golesh

    nikkolas-golesh

    Joined:
    May 3, 2015
    Posts:
    4
    This solution didn't work for us. And, it isn't really an option. We rely heavily on our Component's Awake functions to preform a lot of pre-initialization.
     
  50. Remiel

    Remiel

    Joined:
    Oct 17, 2012
    Posts:
    105
    If you want to use Awake in behaviours deriving from BaseBehaviour you MUST override it and call base.Awake() before you do anything else. It might not solve your problem if something else is causing it, but BaseBehaviour Awake must be called otherwise certain things wont work.