Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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:
    546
    Free fully featured trial here (v2.6.2)!

    2.6 has been released! Make sure to update!

    $forum-header-updated.png

    Inspect Everything

    Full Inspector allows you to edit and serialize the full range of .NET types using the Unity inspector. The following kind of types are supported:
    1. interfaces/abstract types (you select the concrete implementation in the inspector)
    2. structs
    3. dictionaries
    4. arbitrary generic types
    5. properties
    6. a better array / list editor (gif) (using Rotorz)
    7. tooltips and comments via attributes on fields/properties/types
    Full Inspector makes the inspector "just work" with your complex object graph.

    Video Introduction

    The following video demonstrates some of the core features of Full Inspector.



    The audio is slightly quiet, so you might need to turn your volume up.

    Serialize Everything

    Full Inspector also allows provides clean integration of Full Serializer, Json.NET, protobuf-net, BinaryFormatter, or your own custom solution using a simple integration API.

    Full Inspector makes Json.NET, protobuf-net, or BinaryFormatter integrate wonderfully into Unity. If you would have annotated a type with [Serializable] before, then annotate it with the serializer's annotations. It's that simple.

    Usage

    Using Full Inspector is extremely simple. When you're adding a new MonoBehaviour or ScriptableObject, simply derive from BaseBehavior (or BaseScriptableObject) instead of MonoBehaviour, and suddenly you'll be able to use structs, interfaces, dictionaries, and general generic types!

    The default serializer is Json.NET. If Unity would have previously required you to add a [Serializable] annotation, then you just need to annotate that type with Json.NET annotations. There is a similar story for protobuf-net, BinaryFormatter, etc.

    You can also write custom PropertyEditors, which are extremely similar to Unity's PropertyDrawer type. Please see the samples and or the manual for an explanation of how to write property editors. Don't worry though, it isn't complicated.

    Get it!

    Full Inspector is available on the Asset Store here. Please find the website here and the guide here.

    A free trial here is now available. It includes all of Full Inspector, except there are two limitations:
    • Unity will error when publishing a build
    • Source code is not available
    To install, simply unzip the downloaded zip file into your Unity Assets folder. Make sure to backup first!

    Of course, full source code is included with this asset when you purchase from the Asset Store.
     
    Last edited: Apr 20, 2016
    Gozdek and rakkarage like this.
  2. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,368
    Hey sient, any updates to this?
     
  3. Wenzil

    Wenzil

    Joined:
    Apr 3, 2013
    Posts:
    19
    It's been out for 2-3 days. Here's the official website: http://jacobdufault.github.io/fullinspector/

    I'm just dropping by to draw attention to this very well made product. It's a must-have for programmers in my opinion. With support for serialization of interfaced fields, it allows you to design more intricate / modular / encapsulated object models and still fully leverage the inspector. I wish Unity would provide this feature built-in!
     
  4. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,285
    @sient, it sounds good. Are there any performance considerations when using in mobile apps? Also, any conflict issues as I'm already using JSON .NET for Unity.
     
  5. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    My plan is to do a performance pass for 1.3 or 1.4. I haven't been having any perf issues thus far, but there is always room for optimization. The runtime code is pretty minimal and mainly just passes work off to the serializer of choice.

    If you really need fast performance, then I'd recommend using protobuf-net instead of Json.NET.

    Awesome! There will be no conflicts; you just need to delete the folder "FullInspector/FullInspector/Serializers/JsonNet/DLLs".

    Edit: There are currently a few minor build issues with Json.NET for Unity from Parent Element; they are simple to resolve manually and will be dealt-with in version 1.3 (current eta is 3/7/2014).
     
    Last edited: Feb 27, 2014
  6. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,285
    @sient, are they any issues when using a particular Stripping Level on iOS?
     
  7. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Very cool asset,

    Wondering if it can use EasySave 2 from the asset store ?

    Edit: Which is more performant, EasySave2 or Json.NET from the asset store?

    1. Are there Example projects showing how to save/load for various commonly encountered use cases ?
    2. Video tutorials ?
    3. Trial version ?

    Cheers.
     
    Last edited: Feb 26, 2014
  8. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Sure, you can use EasySave 2 from the asset store. However, it looks like EasySave 2 only supports writing the serialized data out to a file, which makes it significantly less useful. I've written a sample that demonstrates how to use EasySave 2 here. I don't have access to EasySave 2, however, and this is just what I've been able to gleam from the documentation.

    I'm not sure which is faster, Json.NET or EasySave 2. If you're looking for performance, I would highly recommend that you use protobuf-net; Full Inspector ships with a serialization plug-in for it.

    Yep, there are lots of samples. I plan on doing some video tutorials down the road, but right now there is lots of documentation on the website. I may release a trial version, but it will likely lack any serialization support.

    Thanks! Let me know if you have any other questions.
     
  9. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Strip assemblies and Strip ByteCode appear to work at the moment (potentially micro mscorlib down the road), but more investigation is needed. I'll update this post when I have more information.
     
  10. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Thanks for checking out EasySave2.

    Does Protobuf-net support all unity platforms. Desktop, Console, IOS, Android, WinRT ?

    Have you battle tested protobuf-net in a complex project?
    The reason is that I just checked the project page and they seem to have lots of issues outstanding. Also the project doesn't seem to have been updated since 2010. Edit: sorry, Sept 2013.

    I saw the documentation page but really need working examples to see how it actually works with the various Serialization packages. If this package does the job, it would be totally awesome. A solid Serialization framework that rules them all.

    Edit: Can you make a video showing the various saving/loading use cases ?



    Cheers.
     
    Last edited: Feb 27, 2014
  11. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Forgot to ask an very important question:

    Does the supported Serialization solution working for both in-editor and during run time?
     
  12. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    protobuf-net is extremely mature and is heavily used in the industry.

    Currently I'm working to get it working perfectly on iOS without manual user intervention. It's doable right now, but it requires a precompilation step which I'd like to automate.

    There are lots of included samples. I can probably put them up on a separate github repository (but this will likely not be until I push out 1.3). For now, here are a few samples that each use a different serializer.

    Sure, but I don't have time at the moment. It'll probably be a week or two until I get the opportunity.

    Absolutely. It would be awful if it did not.

    Thanks.

    Let me know if you have any more questions.
     
    Last edited: Mar 5, 2014
  13. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    "There are lots of included samples. I can probably put them up on a separate github repository (but this will likely not be until I push out 1.3). For now, here are a few samples that each use a different serializer."

    What I mean by examples is more in-depth.

    Say if you are using Protobuf.
    1. A demo scene with 4 Gos
    2. Go1 has unity component
    3. Go2 has simple custom component
    4. Go3 has complex custom component, class, and data structures.

    Serialize the scene with these 4 Gos, Change the go's properties, Load back the saved Gos.
     
  14. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Serialization seamlessly interops with Unity. You don't need to do anything special, so in that regard there is nothing to sample. So for your example, you just add the annotations and it just works, even if some of the components don't derive from BaseBehavior (though then they won't be able to use protobuf-net on themselves or get an awesome inspector).

    If you are modifying a behavior in the editor that is not the selected editor, then you need to call RestoreState/SaveState (or enable reserailization serialization of everything in the settings); I can add a sample for this.
     
  15. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    I think a quick 5 min video will really help to understand how the package works.
     
  16. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Awesome news! I'm going to be submitting a 2.0 update in a few days. I've added some really awesome new features that require a change in serialization format.
    • Ref<> is gone, forever.
    • BinaryFormatter is now supported as a serializer
    • There is also an experimental easysave-2 serializer
    • Simple, free, and easy serialization support for AOT platforms such as iOS (via BinaryFormatter, protobuf-net via a data-type-only (DTO) assembly, or Json.NET if purchased).
    • Bug fixes :)

    Serialization has become even easier. Assuming that you're using the BinaryFormatter serializer by default, then this code below serializes perfectly.

    Code (csharp):
    1.  
    2. public interface IInterface { }
    3.  
    4. [Serializable]
    5. public class Derived1 : IInterface {
    6.     public int A;
    7. }
    8.  
    9. [Serializable]
    10. public class Derived2 : IInterface {
    11.     public int B;
    12. }
    13.  
    14. [Serializable]
    15. public struct Struct {
    16.     public GameObject GameObject;
    17.     public Transform Transform;
    18. }
    19.  
    20. public class BinaryFormatterStructDemoBehavior : BaseBehavior {
    21.     public IInterface MyInterface;
    22.     public Struct SomeStruct;
    23.  
    24.     public enum Enum {
    25.         ValueA, ValueB, ValueC
    26.     }
    27.     public Dictionary<Enum, string> EnumStringDict;
    28. }
    29.  
    BinaryFormatterStructDemoBehavior will generate this awesome inspector:

    $fullinspector-binaryformatter.png

    Thanks! Let me know if you have any questions.
     
  17. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Great news.

    "protobuf-net via a data-type-only (DTO) assembly",

    What does this actually mean?
     
  18. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    I was wondering about the differences between BinaryFormatter and ProtoBuf and found this article:

    http://stackoverflow.com/questions/...uilt-in-binaryformatter-based-net-serializati

    If you mean BinaryFormatter:

    • being based on fields, is very version intolerant; change private implementation details and it breaks (even just changing it to an automatically implemented property)
    • isn't cross-compatible with other platforms
    • isn't very friendly towards new fields
    • is assembly specific (metadata is burnt in)
    • is MS/.NET specific (and possibly .NET version specific)
    • isn't obfuscation-safe
    • isn't especially fast, or small output
    • doesn't work on light frameworks (CF?/Silverlight)
    • has a depressing habit of pulling in things you didn't expect (usually via events)
    I've spent lots of time in this area, including writing a (free) implementation of Google's "protocol buffers" serialization API for .NET; protobuf-net
    This is:

     
  19. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Yep, I wouldn't particularly recommend BinaryFormatter. However, it's easy to use (protobuf-net requires compiling your serialized models into a separate assembly and the models cannot reference any of your behaviors/Assembly-CSharp/Assembly-JavaScript/Assembly-Boo types explicitly, otherwise the cross compiler crashes) and free (Json.NET for iOS costs $20).

    Lets say that you have a BaseBehavior that references a struct which is serialized using protobuf-net. That struct needs to be placed in a separate assembly (data-type-only, or one that contains only data types) that protobuf-net can precompile or bake the serialization data into.

    This precompiled assembly will be included directly into your project, providing the serialization models that protobuf-net uses. In this way, protobuf-net doesn't have to do reflection/JIT compilation at runtime, which iOS does not support. I intend to write more documentation on how to do this, but as you can already tell, it isn't as simple as BinaryFormatter or Json.NET.

    Thanks
     
  20. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Updating the previous demo code to work with Json.NET (instead of BinaryFormatter) is also simple.

    Code (csharp):
    1.  
    2. [JsonObject(MemberSerialization.OptIn)]
    3. public interface IInterface { }
    4.  
    5. [JsonObject(MemberSerialization.OptIn)]
    6. public class Derived1 : IInterface {
    7.     [JsonProperty]
    8.     public int A;
    9. }
    10.  
    11. [JsonObject(MemberSerialization.OptIn)]
    12. public class Derived2 : IInterface {
    13.     [JsonProperty]
    14.     public int B;
    15. }
    16.  
    17. [JsonObject(MemberSerialization.OptIn)]
    18. public struct Struct {
    19.     [JsonProperty]
    20.     public GameObject GameObject;
    21.     [JsonProperty]
    22.     public Transform Transform;
    23. }
    24.  
    25. public class JsonNetDemoBehavior : BaseBehavior<JsonNetSerializer> {
    26.     public IInterface MyInterface;
    27.     public Struct SomeStruct;
    28.  
    29.     public enum Enum {
    30.         ValueA, ValueB, ValueC
    31.     }
    32.     public Dictionary<Enum, string> EnumStringDict;
    33. }
    34.  
     
  21. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,368
    That's awesome, the `Ref<>` was a deal breaker for me.

    Question: How are polymorphic classes handled? Say I have an array/list of base types but the contents are all of different derived classes. Do they serialize/deserialize properly?
     
  22. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Based on your previous recommendation to use Protobuf for performance, I thought it was a good solution and now it seems that you are suggesting Json.NET and BinaryFormatter.

    Edit: If Protobuf is most performant and requires some tedious setting up work. It would be nice to make some editor scripts to streamline this process. This would make your package more appealing for those who are looking to use Protobuf for better performance.

    If you are also suggesting to use Json.NET, could you do some performance metrics to see how it compares with BinaryFormatter and Protobuf? Having this kind of information would really help potential customers.
     
    Last edited: Mar 5, 2014
  23. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Polymorphic classes are handled properly in the inspector. You get a dropdown to select the instance type you want and then you can edit that specific instance. Here is an example.

    In terms of serialization, the short answer is yes, inheritance is handled properly. The longer answer is that it depends on your selected serializer. All of the primary ones (Json.NET, protobuf-net, and BinaryFormatter) properly support inheritance.

    The reason I'm suggesting different serializers at different times is because you can pick the one you want to use -- there is no "best" serializer. If you need something really fast, go with protobuf-net. If you need something that outputs something that's human readable, use Json.NET. If you need something that is annotation-free (for example, if you're just prototyping), use BinaryFormatter. One of the awesome parts of Full Inspector is that you can mix and match your serializer choice depending on what you need per behavior (though this may be dubious software engineering).

    I have a solution for the protobuf-net precompilation step, but I need to do some more testing to ensure that it fully works. There are also a few potential known issues that might not be resolvable -- still looking into it.

    In terms of performance, BinaryFormatter is likely to be slowest, closely followed by Json.NET. protobuf-net is going to be fastest. There are a number a benchmarks out there, such as the ones here and here.

    Thanks.
     
  24. Cripplette

    Cripplette

    Joined:
    Sep 18, 2012
    Posts:
    60
    WoW this assets looks very good, I will grab it. Every feature of this must be built-in by Unity, they are all a must have ^^
     
  25. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    "In terms of performance, BinaryFormatter is likely to be slowest, closely followed by Json.NET"

    Does this mean that Json.NET is just as slow as BinaryFormatter ? Would be nice to have some numbers so that we can say 10% or 50% faster or slower.
     
  26. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Thanks! I hope you enjoy the asset. If you would like a pre-release version of 2.0, feel free to send me an email.

    From this benchmark I found this comparison, showing Json.NET as faster than BinaryFormatter.

    Let me know if you have any other questions.

    Thanks.
     
  27. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Wondering if you've got some more info about demo scenes or when 2.0 will be ready.

    Cheers.
     
    Last edited: Mar 11, 2014
  28. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    I submitted 2.0 to Unity a couple days ago -- hopefully it'll be up on the asset store either Thursday or Friday.

    It includes a number of demo scenes in the FullInspector2/Samples folder, listed below:
    • samples-assetstore
    • samples-binaryformatter
    • samples-jsonnet
    • samples-protobufnet
    • samples-other
     
  29. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Superb !

    Can't wait to give it a good spin.

    Cheers.
     
  30. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Awesome news! 2.0 is now available on the asset store! This is a breaking change, so make sure to backup before you update! Additionally, please make sure to delete your old "FullInspector" folder; it has been replaced with "FullInspector2".

    2.0 includes lots of awesome changes, but the big ones are:
    • Ref<> is gone, forever!
    • BinaryFormatter is now supported as a serializer (beta)

    A free trial here is now available. To install, simply unzip the downloaded zip file into your Unity Assets folder. Make sure to backup first!

    The trial includes all of Full Inspector, except that there are two limitations:
    • Unity will error when publishing a build
    • Source code is not available
     
  31. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    I downloaded the new version,

    First two examples have some errrors.

    1. samples - assetstore, all the scripts are missing.
    2. samples - binaryformatter

    ArgumentException: A surrogate for LevelTextParser already exists.
    System.Runtime.Serialization.SurrogateSelector.AddSurrogate (System.Type type, StreamingContext context, ISerializationSurrogate surrogate) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Runtime.Serialization/SurrogateSelector.cs:63)
    FullInspector.Serializers.Formatter.UnityObjectBinaryFormatterWorker.Work (System.Runtime.Serialization.SurrogateSelector surrogates, StreamingContext context) (at Assets/FullInspector2/Serializers/Formatter/Surrogates/UnityObjectSurrogate.cs:26)
    FullInspector.FormatterSerializer`1[System.Runtime.Serialization.Formatters.Binary.BinaryFormatter]..cctor () (at Assets/FullInspector2/Serializers/Formatter/FormatterSerializer.cs:36)
    Rethrow as TypeInitializationException: An exception was thrown by the type initializer for FullInspector.FormatterSerializer`1
    FullInspector.BinaryFormatterSerializer..ctor ()
    System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519)
    System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528)
    System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:77)
    System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:372)
    System.Activator.CreateInstance (System.Type type) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:254)
    System.Activator.CreateInstance[BinaryFormatterSerializer] () (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System/Activator.cs:248)
    FullInspector.Internal.ObjectCache.GetInstance[BinaryFormatterSerializer] () (at Assets/FullInspector2/Core/ObjectCache.cs:25)
    FullInspector.SerializationHelpers.RestoreState[BinaryFormatterSerializer] (ISerializedObject obj) (at Assets/FullInspector2/Core/SerializationHelpers.cs:195)
    FullInspector.BaseBehavior`1[TSerializer].RestoreState () (at Assets/FullInspector2/Core/BaseBehavior.cs:51)
    FullInspector.FullInspectorCommonSerializedObjectEditor.EnsureRestored (ISerializedObject behavior) (at Assets/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:136)
    FullInspector.FullInspectorCommonSerializedObjectEditor.OnInspectorGUI () (at Assets/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:144)
    UnityEditor.DockArea:OnGUI()
     
  32. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Those are really strange errors. Did you do a clean install, ie, delete the original FullInspector folder and then update to FullInspector2 (making sure to delete FullInspector2 if it already existed)?

    Let's see if fixing #2 fixes #1 first, but just to make sure, do you have scripts under "FullInspector2\Samples\AssetStore"?

    For #2, can you first confirm for me that you did a clean install? The only explanation I think of for having another surrogate for LevelTextParser defined is if that type exists in multiple assemblies (and assuming that two types loaded from two assemblies can be considered equal, which I'm not confident about). The simpler explanation is that you have multiple copies of the UnityObjectBinaryFormatterWorker class, perhaps one from an old version, causing the surrogates to get loaded twice.

    Thanks.
     
  33. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,202
    I would like to know some performance stats.

    Obviously, this is doing a double deserialization, where Unity deserialize the GameObject/Scene, and then the MonoBehaviour deserialize its internal Binary/JSon/etc. (OnEnable?) So, every GameObject being instanced goes by that deserialization? How does it affect the instantiation time?
     
  34. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    I've just written a simple benchmark for object instantiation, viewable here. The results are essentially: protobuf-net is faster at mid to large sized object graphs than Unity, everything else is 1-3x slower. I have a good feeling that I can reduce this time on non-AOT platforms by doing some delegate compilation for the minor reflection that Full Inspector is doing.

    There are some heuristics that prevent some double serialization. If a MonoBehavior/ScriptableObject contains a type that Unity can directly serialize, then Full Inspector will not send it through your selected serializer.

    Correct, the objects are deserialized upon the OnEnable/Awake call. This has been the only reliable method I've found for deserialization that is also future proof.

    In regards to serialization propagation, the only objects that run through the Full Inspector serialization mechanisms are those that directly derive from BaseBehavior or BaseScriptableObject. If your BaseBehavior has a TransformComponent reference, Full Inspector is never going to look at the reference besides recording that the reference exists and needs to be restored.

    Thanks! Let me know if you have any other questions.
     
  35. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    I deleted the old version and imported the new update.

    Found that another package GridFramework is conflicting. It had a C# and Js file named "LevelTextParser" I deleted that package and now the example 2 is working. Example 1 still is missing all references.

    Btw, how to avoid the naming conflict with other packages?
     
  36. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,202
    So... If I understand right, even if Proto is "faster" for instancing - which I find surprising, the object is still not usable until OnEnable/Awake is done. Therefore, even Proto full "readiness" is not achieved in your benchmark... Unless OnEnable/Awake is called from Instanciate()?
     
  37. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    The object is fully usable after the benchmark is done (Instantiate() calls Awake). protobuf-net is a well optimized library and can actually run faster than the Unity serializer. Surprising, but true.

    You can test it out if you want. Just download the trial and import the code in the gist. Enter play mode and then go into "Window/Full Inspector/Run Performance Sample"
     
  38. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Oops, it looks like somehow the AssetStore samples source code didn't get included in the release. I've attached it here; just unzip this folder into your Assets directory and then reopen the scene. View attachment $FullInspector AssetStore Samples.zip

    I've just wrote some code to verify this, but there is a bug in Mono's SurrogateSelector implementation. It doesn't disambiguate between two types with the same name but which are in different assemblies. I plan on reimplementing SurrogateSelector (it's a pretty simple class, thankfully) that doesn't have this issue. Thanks.
     
  39. rcalt2vt

    rcalt2vt

    Joined:
    Jun 6, 2009
    Posts:
    36
    Just popped on to say great release man. Thanks for all the improvements!
     
  40. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    599
    For those interested in benchmarks, here's a full detailed comparison I came across yesterday.
     
    Last edited: Mar 18, 2014
  41. vexe

    vexe

    Joined:
    May 18, 2013
    Posts:
    599
    @sient: I have two questions if you don't mind:

    1- Do you handle UnityEngine Objects serialization yourself too? (Like MonoBehaviour, etc) - If so, I'm really curious how, cause for example MonoBehavoiur, it's not mocked with Serializable so BinaryFormatter can't do it, nor any other attribute that's required from any other serailizer...

    2- Where do you put your serialized data? - like if you serialized a struct, etc where do you keep the serialized data?

    Thanks!
     
  42. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,284
    Nice comparison.

    Would also be really cool to have metrics for various Unity's platforms. Desktop, Mobile.
     
  43. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    I'm happy to answer any questions.

    UnityEngine.Object references took awhile to figure out how to serialize properly. I went through a bunch of solutions before settling on Ref for awhile, and only recently coming across the current solution, which I think is optimal in terms of ease of use / speed. In essence, UnityEngine.Object references are all serialized by Unity itself.

    The serialization strategy changed in 2.0, and here's an overview of how it now works:

    1. Full Inspector discovers all fields/properties on the BaseBehavior that Unity will not properly serialize.
    2. For each of those fields, a key is stored in a keys vector on the GameObject.
    3. For each of those fields, the stored value is run through the selected serializer and the serialized state is stored in a serialized value array.
    4. Whenever a serializer comes across a UnityEngine.Object reference, it gets assigned a unique id (relative to the serializing behavior) and is stored in a list of objects in the behavior. Upon deserialization, that unique key is used to lookup the original object reference. This ensures that you get proper behavior, when, for example, your behavior becomes a prefab.

    There are three lists in each BaseBehavior instance that Full Inspector uses.

    Code (csharp):
    1.  
    2. [SerializeField]
    3. private List<string> _serializedStateKeys;
    4. [SerializeField]
    5. private List<string> _serializedStateValues;
    6. [SerializeField]
    7. private List<UnityObject> _objectReferences;
    8.  


    Here's an example of how serialized data is stored (from the latest build, notice that there are no Json.NET annotations)

    $serialization example.PNG

    Notice the three storage lists (one for keys, values, and objects). If you look at the "3: Structs" GameObject and the "5: Inheritance" GameObject references, you'll notice that the first one got serialized with unique id = 0 and the second with unique id = 1 (which just so happen to correspond to their positions in the references list).

    Let me know if that clarifies things or if you have any other questions!

    Thanks
     
    Last edited: Mar 19, 2014
  44. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    Awesome; probably worth mentioning though that those benchmarks are likely running on .NET and not Mono, which likely has different performance characteristics.
     
  45. Dean-Kuai

    Dean-Kuai

    Joined:
    Jun 17, 2013
    Posts:
    19
    Thanks for this awesome plugin, I've been looking for it for a long time~

    I've got a problem. If modify a prefab in scene and then apply it, the prefab in project not updated (not each time). Also if modify a prefab in project, the same prefab in scene will not update too. I have to quit unity and reopen it to make the update implemented. Is this fixable?

    Another question, is there a way to keep the serialized data while switching the serializer?
     
  46. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    The issue you're referring to with prefabs (here) has already been fixed and will be included in the next update. If you would like to get the current master build, then feel free to just send me an email (there are also instructions for how to apply the update manually in the issue ticket).

    Changing the serializer requires a recompile, which means that Unity will lose the current state of the object. When the object goes to restore itself, it'll deserialize with the old serialized state but with a new serializer, resulting in an deserialization error.

    I may be able to add in some logic to the editor that will try to detect if the serializer has changed states; I can't promise anything yet though.

    Thanks! Let me know if you have any other questions / if I can help with anything else.
     
  47. Dean-Kuai

    Dean-Kuai

    Joined:
    Jun 17, 2013
    Posts:
    19
    Great! I'll wait for the next update, thanks :D
     
  48. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    I've just submitted 2.1 to the asset store. If you would like it now, feel free to send me an email or PM. The trial is now pointed at 2.1, so if you're on that feel free to update.

    There are a lot of changes in 2.1 resulting in a much more polished experience while using Full Inspector. The big ones are undo/redo, attribute editors, and showing prefab override properties in bold.

    Here's the full change log for any interested, though even it still doesn't capture all of the small tweaks.

    I hope you'll enjoy this update. Please let me know if you have any questions. If you would like the update now, please feel free to shoot me an email or PM.

    Thanks.
     
  49. acidbolt

    acidbolt

    Joined:
    Dec 23, 2013
    Posts:
    4
    Hello, I feel like I am missing something obvious here..

    I just installed the trial, but the FullInspector samples and also forge-unity (sorry if that's off-topic) won't compile. Wherever PropertyEditor appears in the code, I get this error: "The type or namespace name `PropertyEditor`1' could not be found. Are you missing a using directive or an assembly reference?"

    I can't find anything related in the documentation, so I'm a little confused..
     
  50. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    546
    The Full Inspector samples themselves are not compiling? That's really strange, as when I import the trial into a project I don't get any errors. What version of Unity are you running? Full Inspector is tested on 4.3.

    Or is the issue only with forge-unity? I've just pushed an update so that it will compile with the latest version of Full Inspector. If you continue to have issues with forge-unity, can you create an issue on the forge-unity page here?

    Thanks.