Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. 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. c0ffeeartc

    c0ffeeartc

    Joined:
    Jul 23, 2015
    Posts:
    42
    After setting
    Code (CSharp):
    1. FullInspector.fiSettings.PrettyPrintSerializedJson = true;
    result is string inside prefab similar to following:

    \"x\":
    1.0,\r\n \"y\": 1.0,\r\n \"z\": 1.0\r\n },\r\n

    Is this expected ?
     
    Last edited: May 25, 2016
  2. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Yes, though I was wrong about what was causing it. It actually happens if one of the ParticleSystem's in the dictionary is a scene object rather than a prefab in the project folder. So, when you try to apply those changes to the prefab, Unity as normal tries to change the scene object references to nulls, but I guess Dictionary's don't like nulls as keys, so it throws that error. So I guess it's not really FullInspector's fault, but it would be cool if there was a more graceful way around this.
     
  3. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    Alright... "adding metadata to Unity", what does that mean in practice? :)

    Thanks!
     
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    So Im assuming the trial doesnt work with the beta? Also installation instructions would be nice because Im not sure if its an issue with the beta, the trial or user incompetence as it doesnt appear do be working for me(5.4b18)
     
  5. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    Hi, I want to know the same before downloading the trial: does it work with the beta? (I'm using the latest version)
     
  6. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
  7. noanoa

    noanoa

    Joined:
    Apr 17, 2014
    Posts:
    225
    Hi, when serializing a dictionary of Gradient( Dictionary<string, Gradient> ), unity gives the following error. (However, it seems the dictionary is serialized alright) Is there any way to fix the error?

    Type Gradient needs to have a [Serializable] annotation for property drawer integration to work
    UnityEngine.Debug:LogError(Object)
    FullInspector.Internal.fiGenericPropertyDrawerPropertyEditor`2:.ctor() (at /Users/jdufault/Personal/FI/Project/Assets/FullInspector2/Core/Editor/PropertyEditors/fiGenericPropertyDrawerPropertyEditorManager.cs:24)
    FullInspector.Internal.GradientPropertyEditor:.ctor()
    ...and so on
     
  8. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yes, PrettyPrintSerializedJson means that newlines will be included in the json. The \r\n is just the escaped newline value - though actually the raw newline value shouldn't be visible/escaped.
     
  9. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
  10. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I'll try to improve the behavior if I get a chunk of time to look into it.
     
  11. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry, the trial is pretty out of date. I've responded to some of your private communications with an alternative solution though.
     
  12. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I've created an issue at https://github.com/jacobdufault/fullinspector/issues/147. This should hopefully be relatively easy to fix, so it should get resolved soon. Then I'll upload a build to access.
     
    noanoa likes this.
  13. mcurtiss

    mcurtiss

    Joined:
    Nov 29, 2012
    Posts:
    26
    Hey there,

    Recently bought the product, and it's great, though I'm running into an error and I don't know what I did to cause it:

    It errors even in clean scenes. I was able to resolve the issue simply by restarting Unity, but I would like to try to understand why this came about in the first place.

    Also, I'm having issues with lag when I serialize several large arrays/Dicitionaries/HashSets (30 arrays of around 1,000+ elements). The serialization seems adds several (10+) seconds to load time. Can you point me in a direction towards speeding this up? The use case is basically that I want to create all the data for a tilemap while in the editor so I don't have to generate it at runtime.

    edit: I've realized I shouldn't be doing what I'm trying to do.
     
    Last edited: Jun 22, 2016
  14. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    346
    I'm testing out FS and am running into an issue where private fields don't appear to be serializing. Is this expected behavior?

    Code (CSharp):
    1.     public abstract class SWBehavior : BaseBehavior<JsonNetSerializer> {
    2.     }
    3.  
    4.     public abstract class SWElement : SWBehavior, ISWElement {
    5.     }
    6.  
    7.     public class LevelData : SWElement, ILevel {
    8.         [ShowInInspector]
    9.         private LevelType _levelType;
    10.         [ShowInInspector]
    11.         private float _currentLevelTime;
    12.         [ShowInInspector] [InspectorCollapsedFoldout]
    13.         private PlayerData _player = new PlayerData();
    14.         [ShowInInspector]
    15.         private MapData _map;
    16.  
    17.         public IMapData GetMap()
    18.         {
    19.             return _map = Assert<MapData>(_map);
    20.         }
    21.  
    22.         public float GetLevelTime()
    23.         {
    24.             return _currentLevelTime;
    25.         }
    26.  
    27.         public void SetLevelTime(float time)
    28.         {
    29.             _currentLevelTime = time;
    30.         }
    31.  
    32.         public void IncreaseLevelTime(float deltaTime)
    33.         {
    34.             _currentLevelTime += deltaTime;
    35.         }
    36.  
    37.         protected override void Awake()
    38.         {
    39.             base.Awake();
    40.         }
    41.     }
    2016-06-24 14_33_59-Star Wards Prototype - Microsoft Visual Studio.png
     
  15. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Try to add also [SerializeField] to your private fields.

    Edit: I usually use only SerializeField and the fields also show in the inspector. I think that ShowInInspector is meant to only show and not to serialize the fields.
     
  16. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    346
    I did actually have that set initially but it didn't help.
     
  17. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I tested this code on last version of Full Inspector and Unity 5.3.5p5 on OSX and it works correctly:

    Code (CSharp):
    1. public abstract class SWBehavior : BaseBehavior {}
    2.  
    3. public abstract class SWElement : SWBehavior {}
    4.  
    5. public class LevelData : SWElement {
    6.     public enum LevelType {
    7.         Campaign,
    8.         Challange
    9.     }
    10.  
    11.     [SerializeField]
    12.     LevelType levelType;
    13. }
    I don't expect interfaces to cause that issue.
    Also I use FullSerializerSerializer, because JsonNetSerializer has some limitation and doesn't offer any advantage over FullSerializer (at least that I know of)
     
  18. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    Haven't looked at this yet, but does this apply to Windows Store Apps builds? Because as I mentioned the issue doesn't exist for iOS or Android, only WSA.

    Edit.
    This thread might be of relevance:
    http://forum.unity3d.com/threads/sy...ion-at-appcallbacks-setbridge-_bridge.376591/

    Edit2.
    Just updated to Unity 5.3.5p5 and still the same issue.

    Edit3.
    In fsMetaType.CreateInstance() I can see that ReflectedType.BaseType & DeclaringType are both null, if that helps.
    If you try the repo I made on the previous page you can see the bug.


    SOLVED
    After testing it seems the issue is in fsTypeCache.cs. Normally (on non-UWP platforms) you get all loaded Assmblies by calling AppDomain.CurrentDomain.GetAssemblies(). But as you know this isn't available on UWP and thus used: typeof(object).GetTypeInfo().Assembly instead, but this will only return one assembly (mscorlib.dll). The solution I found was to load/retrieve the assemblies from the apps installation folder, in the following way:

    Code (CSharp):
    1. #if (!UNITY_EDITOR && UNITY_METRO && !ENABLE_IL2CPP)
    2.         private static async System.Threading.Tasks.Task<List<Assembly>> GetAssemblies()
    3.         {
    4.             List<Assembly> assemblies = new List<Assembly>();
    5.  
    6.             var files = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFilesAsync();
    7.             if (files == null)
    8.                 return assemblies;
    9.  
    10.             foreach (var file in files.Where(file => file.FileType == ".dll" || file.FileType == ".exe"))
    11.             {
    12.                 try
    13.                 {
    14.                     assemblies.Add(Assembly.Load(new AssemblyName(file.DisplayName)));
    15.                 }
    16.                 catch (Exception ex)
    17.                 {
    18.                     System.Diagnostics.Debug.WriteLine(ex.Message);
    19.                 }
    20.  
    21.             }
    22.  
    23.             return assemblies;
    24.         }
    25. #endif
    And then use it similar to how you did for non-UWP platforms (inside the fsTypeCache static constructor):

    Code (CSharp):
    1.  
    2. static fsTypeCache() {
    3.    //...
    4.    //..
    5.    foreach (Assembly assembly in GetAssemblies().Result)
    6.    {
    7.       _assembliesByName.Add(assembly.FullName, assembly);
    8.       _assembliesByIndex.Add(assembly);
    9.    }
    10.    //..
    11.    //...
    12. }
    13.  
    Not sure if this is the best solution, but was the only one I could find. Would be great if this (or some other solution) can be added to the next release. :)

    Here is the full stacktrace again:

    Code (CSharp):
    1.  
    2. Exception thrown: 'System.Exception' in Assembly-CSharp.dll
    3. Exception caught when deserializing property <serializedConstraints> with type <ACE.UI.UIView>
    4. System.Exception: Cannot create an instance of an interface or abstract type for ACE.Serialization.ISerializeableDTO`1[ACE.UI.Layout.IVariable]
    5.    at FullSerializer.fsMetaType.CreateInstance()
    6.    at FullSerializer.Internal.fsReflectedConverter.CreateInstance(fsData data, Type storageType)
    7.    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    8.    at FullSerializer.fsSerializer.InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    9.    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    10.    at FullSerializer.fsSerializer.TryDeserialize(fsData data, Type storageType, Type overrideConverterType, Object& result)
    11.    at FullSerializer.Internal.fsReflectedConverter.TryDeserialize(fsData data, Object& instance, Type storageType)
    12.    at FullSerializer.fsSerializer.InternalDeserialize_5_Converter(Type overrideConverterType, fsData data, Type resultType, Object& result)
    13.    at FullSerializer.fsSerializer.InternalDeserialize_4_Cycles(Type overrideConverterType, fsData data, Type resultType, Object& result)
    14.    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    15.    at FullSerializer.fsSerializer.InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    16.    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    17.    at FullSerializer.fsSerializer.TryDeserialize(fsData data, Type storageType, Type overrideConverterType, Object& result)
    18.    at FullSerializer.Internal.fsReflectedConverter.TryDeserialize(fsData data, Object& instance, Type storageType)
    19.    at FullSerializer.fsSerializer.InternalDeserialize_5_Converter(Type overrideConverterType, fsData data, Type resultType, Object& result)
    20.    at FullSerializer.fsSerializer.InternalDeserialize_4_Cycles(Type overrideConverterType, fsData data, Type resultType, Object& result)
    21.    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    22.    at FullSerializer.fsSerializer.InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    23.    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    24.    at FullSerializer.fsSerializer.TryDeserialize(fsData data, Type storageType, Type overrideConverterType, Object& result)
    25.    at FullSerializer.fsSerializer.TryDeserialize(fsData data, Type storageType, Object& result)
    26.    at FullSerializer.Internal.fsArrayConverter.TryDeserialize(fsData data, Object& instance, Type storageType)
    27.    at FullSerializer.fsSerializer.InternalDeserialize_5_Converter(Type overrideConverterType, fsData data, Type resultType, Object& result)
    28.    at FullSerializer.fsSerializer.InternalDeserialize_4_Cycles(Type overrideConverterType, fsData data, Type resultType, Object& result)
    29.    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    30.    at FullSerializer.fsSerializer.InternalDeserialize_2_Version(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    31.    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference(Type overrideConverterType, fsData data, Type storageType, Object& result, List`1& processors)
    32.    at FullSerializer.fsSerializer.TryDeserialize(fsData data, Type storageType, Type overrideConverterType, Object& re
    33.  
     
    Last edited: Jun 30, 2016
  19. jrhee

    jrhee

    Joined:
    Dec 5, 2013
    Posts:
    74
    Regarding precompiled DLLs for FI 2.6.3: I tried extracting the Unity 5.3 DLLs package before removing the Core and Modules folders, but when I open it says "Nothing to import, all assets already imported". I got it working by taking the 5.1 DLLs in the DLL builder zip file, but what's the purpose of the 5.0 and 5.3 DLL unitypackages? Also it looks like the instructions on this page are out of date.
     
  20. jrhee

    jrhee

    Joined:
    Dec 5, 2013
    Posts:
    74
    EDIT: I noticed the below problem went away when I downloaded v2.6.4 from the website. I do still have the Serialization Manager continue to pop up asking me to set a default whenever I use the DLL and there's a compiler error in my code. Is there a way to avoid this? I don't seem to have this issue when I use the source version of the package.

    ---------------------------------------------------------------

    One followup: I'm getting the following errors when using the 5.1 DLL:

    [Error] UNetWeaver error: NetworkBehaviour BaseNetworkBehavior`1 cannot have generic parameters
    0. Unity.UNetWeaver.Log.Error() at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:20
    1. Unity.UNetWeaver.NetworkBehaviourProcessor.Process() at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetBehaviourProcessor.cs:48
    2. Unity.UNetWeaver.Weaver.ProcessNetworkBehaviourType() at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1064
    3. Unity.UNetWeaver.Weaver.CheckNetworkBehaviour() at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1549
    4. Unity.UNetWeaver.Weaver.Weave() at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1658
    5. Unity.UNetWeaver.Weaver.WeaveAssemblies() at C:/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1748
    6. Unity.UNetWeaver.Program.Process() at C:/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:34
    7. UnityEditor.Scripting.Serialization.Weaver.WeaveUnetFromEditor()

    [Error] Failure generating network code.
    0. UnityEditor.Scripting.Serialization.Weaver.WeaveUnetFromEditor()

    This seems to cause the FI serialization manager window to repeatedly pop up even after a default was previously set.
     
    Last edited: Jul 2, 2016
  21. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    For serializing this much content I'd either use the protobuf serializer or do custom deserialization, especially if you're storing the data in-editor for performance reasons.

    You can also try AOT compiling FullSerializer for the class in the array, which should run faster since it doesn't use reflection.
     
  22. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks mcmorry, were you able to resolve this strich?
     
  23. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Ugh, yuck. But a pragmatic solution is better than no solution at all! Would you mind submitting a PR to [Full Serializer]?
     
  24. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi @sient,
    is it possible to have a property set method to be called when changing a value in the inspector?
     
  25. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Would a C# property work? The property set method should be called as expected.
     
  26. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I was just using a C# property. But it seemed to me that the set method was not called. I'll test again to be 100% sure.
     
  27. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    795
  28. ctc5301

    ctc5301

    Joined:
    Jan 28, 2016
    Posts:
    16
    Compiler error:
    H:\unity3d\iTween\Assets\FullInspector2\Serializers\Formatter\RobustSerializationBinder.cs 12 The name 'TypeCache' does not exist in the current context

    Unity 5.4
     
  29. jrhee

    jrhee

    Joined:
    Dec 5, 2013
    Posts:
    74
    Bump- any thoughts on this? Is anyone else using the DLL?

     
  30. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
  31. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    If you're not using the BinaryFormatter serializer, you can remove the Serializers\Formatter folder. I've posted issue 157 in the meantime. The fix should be simple, likely TypeCache was renamed to fsTypeCache.
     
  32. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I've created issue 158 to track this. I'll try to get to it soon.
     
  33. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I have a feeling that 5.1 DLL is using pretty old code. The generic variant of BaseNetworkBehavior has been removed for awhile.
     
  34. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    795
    Bumping 156, still losing the reference every time Unity is restarted or in any build. Getting a bit worrisome for us.
     
  35. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry, I'll try to take a look tomorrow. There's a queue of bugs to address :(
     
  36. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I've posted an update to that bug - I need a bit more information. Thanks!
     
  37. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    @sient I also had a similar issue of @ludiq yesterday.
    I'm on Unity 5.3.5p7 and I did a build for iOS. It ended up with some dictionary serialized inside some prefabs completely empty (and this happens many times also while working... I use git to restore them :( ) but even more strange, a ScriptableObject was overwritten with some in game data stored in some kind of cache. So I closed Unity, restored prefabs and SO, and did the build to avoid data corruption.
    I can't really give you a sample code. One thing is for sure is related with dictionaries inside prefabs. They often lose their data, and they always lose data if Unity compile while in play mode.
    In a big project this kind of issues are a bit annoying because slow down a lot the production. I have to double check every time every single prefab and SO before to commit to see if some data are lost.
    I really hope you can find a solution to those issues.
     
  38. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    What build of FI are you using? I'm testing with 5000 or so prefabs. I've entering/exiting play mode a bunch, compiled while in play mode, did some builds, and saved the scene. How frequently does it reproduce?

    Here's the behavior I'm using to test with:
    Code (csharp):
    1.  
    2. [ExecuteInEditMode]
    3. public class SerializationTest : BaseBehavior {
    4.     public Dictionary<string, int> dict;
    5.  
    6.     protected override void Awake() {
    7.         if (dict.Count == 0)
    8.             Debug.LogError("dict count is 0", this);
    9.     }
    10. }
    11.  
    I have all of the prefabs contained in the scene using this helper class:
    Code (csharp):
    1.  
    2. using FullInspector;
    3. using UnityEngine;
    4.  
    5. public class Repro : BaseBehavior {
    6.     public Object[] objs;
    7. }
    8.  
     
    Last edited: Jul 29, 2016
  39. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I encountered a bug.

    Reproduce: Create a default script, attach it to an object, delete the script. It will says "Missing (Mono Script)"

    Normal Behavior: I should be able to drag some script into the Script box

    View attachment 193990

    View attachment 193992

    FI 2.6.4(28-07-16)'s Behavior: The Script box shows "Missing (Mono Script)" but grayed out, and can not drag and drop into it.
     
  40. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I'm out for holiday now so I can't be very precise about the version of FI but I was using the last build you released in June or the first of July. Anyway I have these issues for many many months even if I was always updating to last build.
    My dictionaries use often enum as key and classes as value. I don't know if this could change the behavior.
    I'll try to create a test project once I'll be back using some of my classes.
    Also I have many warnings about missing component is objects called something like fiBackup... and I can't get rid of them. Could this be a possible reason?
     
  41. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    300
    FEATURE REQUEST:
    One thing that I've always wanted from unity, and now implemented myself (but to do it efficiently it must be part of the metadata), is auto-assigning component-fields in scripts (references to Components on the same GameObject). This avoids ALOT of boilerplate code of constantly manually call get-/addcomponent in awake.

    Basically I now have:

    Code (CSharp):
    1. [AutoloadComponent(true)]
    2. private Text label = null;
    The boolean is "addIfMissing", which just calls AddComponent in case GetComponent returns null. Another feature could be the ability to specify a certain type, say if the reference is of type A and you have two derived components A1 & A2 available on the gameObject but want to get a specific subtype.
    This is done before awake and cleans up the code a bunch.

    Obviously it comes with a performance penalty since reflection is used, but if it's made part of the serialization process, it can be "efficient enough" for most use-cases. Also it's only on class specific (not instance), so it only have to be processed once for each custom type.
     
    Last edited: Aug 17, 2016
  42. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    Hey Sient,

    I've been doing some deep optimization for our game and I can across a pretty chunky optimization trick to make FullInspector faster to instantiate objects in-game. Hopefully you can get these improvements officially supported in the future.

    What seems to be happening is when an instantiation occurs, Unity calls the OnBeforeSerialize before it instantiates the new instance, then OnAfterDeserialize after it is done copying over the original's data internally. FullInspector uses the OnBeforeSerialize callback to change it's own custom inspector data into a Unity internally serializable string, and then the OnAfterDeserialize to take that string and convert it back to actual usable variable data. Unfortunately this is not good enough for our game, when we have components with a crap-ton of gameplay information sitting on them. One item in particular wasted 9ms of time and 0.5MB of data to do the serialization-deserialization process which was ultimately wasted time and space.

    The fix I came up with was to enqueue ISerializedObject that would be serialized in a static queue that would have been serialized, and then take from that queue if possible before having to deserialize.

    Added in fiSerializedObjectUtility:
    Code (CSharp):
    1.         private static Queue<ISerializedObject> _SkipSerializationQueue = new Queue<ISerializedObject>();
    2.  
    3.         public static void QueueState(ISerializedObject obj)
    4.         {
    5.             _SkipSerializationQueue.Enqueue(obj);
    6.         }
    7.  
    8.         public static bool DequeueState(ISerializedObject obj)
    9.         {
    10.             ISerializedObject original;
    11.             do
    12.             {
    13.                 if (_SkipSerializationQueue.Count == 0) return false;
    14.                 original = _SkipSerializationQueue.Dequeue();
    15.             }
    16.             while (original.SerializedStateKeys == null || original.SerializedStateKeys.Count != obj.SerializedStateKeys.Count);
    17.             var inspectedType = InspectedType.Get(obj.GetType());
    18.             for (int i = 0; i < obj.SerializedStateKeys.Count; ++i)
    19.             {
    20.                 InspectedProperty originalProperty = inspectedType.GetPropertyByName(obj.SerializedStateKeys[i]) ?? inspectedType.GetPropertyByFormerlySerializedName(obj.SerializedStateKeys[i]);
    21.                 InspectedProperty property = inspectedType.GetPropertyByName(obj.SerializedStateKeys[i]) ?? inspectedType.GetPropertyByFormerlySerializedName(obj.SerializedStateKeys[i]);
    22.                 var originalValue = originalProperty.Read(original);
    23.                 property.Write(obj, originalValue);
    24.             }
    25.             return true;
    26.         }
    And implementing them here:
    Code (CSharp):
    1.         public static bool SaveState<TSerializer>(ISerializedObject obj)
    2.             where TSerializer : BaseSerializer {
    3.  
    4.             // there's no need to do property serialization in builds! The only thing that happens is instantiation at this point.
    5. #if !FULL_INSPECTOR_TEST_COPY_QUEUING
    6.             if (!fiUtility.IsEditor)
    7. #endif
    8.             {
    9.                 QueueState(obj);
    10.                 return true;
    11.             }
    12. ...
    13.  
    Code (CSharp):
    1.         public static bool RestoreState<TSerializer>(ISerializedObject obj)
    2.             where TSerializer : BaseSerializer {
    3.  
    4.             // in build, attempt to dequeue state from instantiation, otherwise, continue since it's deserializing from the disk
    5. #if !FULL_INSPECTOR_TEST_COPY_QUEUING
    6.             if (!fiUtility.IsEditor)
    7. #endif
    8.             {
    9.                 if (DequeueState(obj)) return true;
    10.             }
    I'm not positive if it's fully fool proof though, so might need some extra checks and tweaks. Of course it's only viable in builds, or when testing with the preprocessor but that's where the performance matters the most. It took my garbage from 500kb to 27kb and the time from 9ms to 0.5ms.
     
    Last edited: Sep 16, 2016
    johanneskopf and mcmorry like this.
  43. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    Hey while I'm at it,

    I don't know how possible it is to convert all of our assets to use protobuf-net serialization. I changed the default in the Serialization Manager, but trying asset conversion throws a lot of errors about certain datatypes not being supported, like dictionaries. The description before choosing it says how it is by far the fastest, but there's some serialization gotchas. Yet I can't seem to find anywhere those gotchas are explicitly described and how to get around them! Is there a place I can start to convert over my project, or is it not possible since FullSerializer is more flexible?

    Thanks!
     
  44. ZorbaTHut

    ZorbaTHut

    Joined:
    Mar 19, 2014
    Posts:
    21
    FullInspector doesn't seem to support CustomPropertyDrawers for attributes. That is, I can do:

    Code (csharp):
    1.  
    2. [CustomPropertyDrawer(typeof(WidgetAttribute))]
    3. public class WidgetDrawer : PropertyDrawer
    4. {
    5.     // etc etc etc
    6. }
    7.  
    8. public class Thing : BaseBehavior
    9. {
    10.     [Widget] public string m_Widget;
    11. }
    12.  
    and Unity will use the WidgetDrawer to draw m_Widget; FullInspector doesn't seem to handle this properly. Is this an easy fix? Should I go make an issue to get it prioritized?
     
  45. primitiveType

    primitiveType

    Joined:
    Oct 25, 2012
    Posts:
    22
    I bought this plugin today and it seems to cause horrible framerate issues (only tested in editor). I have some pretty large classes with a few levels of inheritance, and with the scene I'm testing on there's a total of about 50 objects that are being serialized with the full serializer. They are all created at runtime.
    Once the objects get created, my editor comes to a complete crawl. Probably one frame every 5 seconds. Is it just not able to handle bigger classes? I read that once it serializes everything there is no performance hit, but I tried waiting for about thirty minutes after scene load to see if it would clear up, and no luck.

    I also tried profiling the editor, and I'm seeing EditorApplication.Internal_CallUpdateFunctions() is taking up all the time. If this plugin simply isn't meant for the amount of properties I have, please let me know. Also I can open a github issue if that's necessary.
     
  46. ZorbaTHut

    ZorbaTHut

    Joined:
    Mar 19, 2014
    Posts:
    21
    I ran into a similar issue and traced it to inconsistent handling of null properties - it's basically thinking that your objects have been updated, serializing them, deserializing them, and still thinking they've been updated.

    I may have fixed it by changing line 34 in Core/ListSerializationOperator.cs from:

    Code (csharp):
    1.  
    2.  if (ReferenceEquals(obj, null)) {
    3.  
    to:

    Code (csharp):
    1.  
    2.  if (ReferenceEquals(obj, null) || (obj == null && obj.GetInstanceID() == 0)) {
    3.  
    but if this totally blows up and fails to work, don't blame me :p

    I'm not sure how maintained this plugin is anymore, the lead hasn't been seen for two months.
     
  47. primitiveType

    primitiveType

    Joined:
    Oct 25, 2012
    Posts:
    22

    Thanks for the suggestion, I'll try this out tomorrow. Sad to hear the lead hasn't been responding. If I can't get it to work, is there any way to get a refund, or will I be SOL?
     
  48. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    @sient just open sourced Full Inspector under GPLv3.
    Full Inspector can now be used free of charge for projects that abide to the GPLv3 license.
    For projects were the code won't be published, you still need a license from the store, as usual.

    Maybe it's for the best that questions and issues be submitted to the official repository on github.
     
  49. WiktorWasowski

    WiktorWasowski

    Joined:
    Dec 23, 2012
    Posts:
    15
    This is great news! I was considering buying the asset, as it's on sale. Now that I have an opportunity to test it first, I'm already even more convinced to buy it. However, I have one concern after playing with it for some time while the documentation is very limited and doesn't seem to contain anything related to my problem. Being able to serialize properties is really handy, but can I somehow set a default value for them, like I would for fields?
     
  50. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    @Aveno I use[1] a C#6 compiler with unity, by alexzzzz. C#6 allows you to set default values for properties with
    Code (CSharp):
    1. public int SomeProperty {get; private set;} = 10
    Now, about this
    It is! I'm hoping to get time to improve the docs a bit with some of the things I learned while using FI. This is a really great tool and it will have much greater adoption if the docs are improved. I hope to see more users around, now that it is GPL.


    Also, remember to use the issue tracker on github for issues so it can benefit future users and have greater visibility.

    [1] I actually use the Unity3D IncrementalCompiler, by Esun Kim, which is C#6 and based on alexzzzz's (the Unity integration part)