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

JSON .NET for Unity

Discussion in 'Assets and Asset Store' started by Dustin-Horne, Sep 13, 2013.

  1. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    That was fixed in Unity 5.2.1p4

    • (732454), (733335) - Editor: Fixed crash when trying to build Universal Windows 10 Apps, but Windows 10 SDK is not installed.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Right, but in 5.2.2 on Windows 8.1 it gives an exception about a /NetCore/5.0 folder being missing if I have a Windows Universal DLL in the project.
     
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Dustin Horne

    Please let me know the bug report number when you get a chance to report this bug. We would like to make sure we can handle the IL that is causing a problem here. Thanks!
     
  4. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Definitely. I'm going to submit a bug tonight. I have verified that when I build from VS2013 the DLL works fine, but with 2015 it gives an Unsupported error. I have not tested it yet with 5.2.2 so I wanted to do that before I submit the bug.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Dustin Horne

    Thanks, I appreciate it.
     
  6. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @JoshPeterson -
    Josh - I'm still working on putting this together, but I have another bug I'd like you to take a look at as well. The bug has been around for awhile but I finally just pinpointed the issue. Previously I thought it was only Unity types but it turns out it's any struct. This only happens on Xbox One (maybe PS4 but I haven't gotten this tested yet).
    Case #739008

    Specifically, it happens when using Reflection to execute the setter or getter on a property of a struct. This user submitted the bug for me, but the bug also happens in another high profile Unity game on Xbox One. We were able to work around it in that case by creating custom converters, but that developer would be super happy if this was fixed as well, and in this new case there will be lots of custom structs so it's not feasible to write specific custom code for each one.

    The bug above was using Unity 5.2.2f1, but I know it existed in whatever the most recent XB1 version was prior to E3 as well.
     
    Last edited: Oct 26, 2015
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Dustin Horne

    Thanks, I've pinged our XboxOne team about case 739008. Let me know if/when you are able to submit a bug report on the other issue.
     
  8. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    That's Josh, I'll have the other one submitted today for sure. I built a simple repro for it. Here's what I'm going to include with the bug report:

    1. Repro project / scene - This has the DLL that is compiled in Visual Studio 2015 and fails IL2CPP compilation.
    2. A zip file with the 2013 compiled DLL - Just to show that the 2013 DLL works and allows you guys to compare the generated IL between the two versions.
    3. A zip file with my Visual Studio solution with JSON .NET for Unity - Just so you have the latest source that I've been using as a solution with the proper compilation directives and can compile with either 2013 or 2015 IDE.

    Let me know if there's anything I've left out (other than the description of the issue of course) or that I can include that would help with troubleshooting.
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Dustin Horne

    That sounds good, thanks.
     
  10. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Dustin Horne

    Thanks, we will have a look at this.
     
    Dustin-Horne likes this.
  12. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Awesome, thank you!
     
  13. LiuLink

    LiuLink

    Joined:
    Jul 22, 2015
    Posts:
    3
    @Dustin Horne
    I did a try with jsonfx and it works with webgl, thanks to you.

    Now I have a problem with jsonfx when deserialize WWW class from server that I don't have with Newtonsoft.Json. Appreciate you can pinpoint why:

    My GameRecord class:
    Code (csharp):
    1.  
    2. public class GameRecord
    3.     {
    4.         public bool Status { get; set; }        
    5.         public View_GameRecord viewGameRecord { get; set; }
    6.     }
    7. public partial class View_GameRecord
    8.     {
    9.         public List<ActionTypeA> lstTypeA;
    10.         public List<ActionTypeB> lstTypeB;
    11.         public List<ActionTypeC> lstTypeC;        
    12.     }
    13.  
    Newtonsoft.Json:
    Code (csharp):
    1.  
    2. var result = JsonConvert.DeserializeObject<GameRecord> (www.text);
    3.  
    JsonFx.Json:
    Code (csharp):
    1.  
    2. var result2 = JsonReader.Deserialize<GameRecord> (www.text);
    3.  
    Using Newtonsoft I can see the detail of View_GameRecord under GameRecord having values but not when using JsonFx although both of them return the correct value for 'Status'.

    Thanks very much.
     
  14. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    JsonFX might have a bug. Honestly I couldn't tell you. I'm not at all affiliated with JsonFX. I only recommended it in your case because you needed something simple so I thought it was worth you giving that a try before you spend money on my asset. But this is the support thread for JSON .NET.
     
  15. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @Dustin Horne I've just noticed that 1.5.0 was released in May. Is there a changelog? I would also really like to be notified of updates if possible.
     
  16. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yes, https://www.assetstore.unity3d.com/en/#!/content/11347
    Click the version number next to Version under the asset. I keep that change log updated. The asset store gives you the ability now to subscribe to updates for packages you've purchased.
     
  17. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    1.5.0 Changelog
    I will be pushing a version 1.6.0 in the near future with the Windows 10 Universal support. At that point everything for Unity 5 will be precompiled DLLs with the source included in a zip file. I'm still going to update the entire JSON .NET profile to the 7.x version but I have to wait until IL2CPP is rolled out to all platforms because it will result in a lot of changes.
     
  18. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Actually I must apologise as I did receive a notification email in May but you sent it from a different email address so it didn't get labelled. I just found it.
     
  19. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Ahh, I think you purchased through parentElement.com / FastSpring didn't you? The notification would have gone to whatever email address you have as your user account there.
     
  20. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    I saw Unity plans to add a UnityEngine.JsonUtility for serializing and deserializing objects to JSON format. I'm assuming this means they give us access to the JSON format of their gameobjects and other Unity specific objects. Are there plans for you to integrate that into your plugin to make the JSON of their specific objects less of a hassle?
     
  21. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'm actually considering that Ben. But that would be done through a specific JsonConverter. The reason being that Unity's JsonUtility will be super fast, but very basic. It's not going to support any special customization, no unmatched properties, no custom serialization through converters, no polymorphism, etc. But, once it's released I will certainly look at using it in a custom converter so unity game objects can be serialized and deserialized.
     
    Ben-BearFish likes this.
  22. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Hi Dustin,

    Can we specify a DateFormatHandling when serializing objects? It seems like the regular JsonSerializerSettings doesn't have support for this setting, but the WinRT one does (maybe it's related to something that exists only in .NET 4.5?).

    We wanted to serialize DateTime objects using the more readable IsoDateFormat instead of the MicrosoftDateFormat, if that is possible. :)

    Thanks!

    - Daniel
     
  23. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @CanisLupus - Currently yes, but only if you use a JsonConverter for it. I've been working on getting upgraded to a newer version of JSON .NET which will support that across platforms but my progress is slowed at the moment by IL2CPP and getting support in for Windows 10 Universal. I've had to accomplish this on Unity 5.x by generating a series of precompiled DLLs which is actually a long term benefit. Because of this, currently that would be supported on the WinRT / Universal and Windows 10 Universal apps but not the other platfoms.

    You'll want a JsonConverter for the DateTime type. For the WriteJson method you'll want to generate the value using this method:

    Code (csharp):
    1.  
    2. DateTime.UtcNow.ToString ("s", System.Globalization.CultureInfo.InvariantCulture)
    3.  
    If you need it in local time with an offset here are other methods for doing that but I'd recommend the UTC conversion. Depending on what type of precision you need, you may also check the other options here:
    http://stackoverflow.com/questions/...how-do-i-get-a-iso-8601-date-in-string-format

    You can then parse that string back in the ReadJson method by simply using the DateTime.TryParse method. Depending on how you format your output string, you may want to check out the second overload for TryParse that lets you specify culture and datetime styles.
    https://msdn.microsoft.com/en-us/library/9h21f14e(v=vs.90).aspx

    If you need help writing the converter let me know.
     
  24. CanisLupus

    CanisLupus

    Joined:
    Jul 29, 2013
    Posts:
    427
    Thank you very much for the detailed and mighty-quick reply! :)

    I have a question, though. We looked into creating a JsonConverter, but ended up finding an IsoDateTimeConverter in the JSON .NET classes, which is simpler and seems to do what we wanted. Is there a reason for not using it? We didn't know it existed before I posted, and you suggested creating a custom converter, so I think it's better to ask. ;)

    Thank you again,
    - Daniel
     
  25. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Oops, I completely forgot that was already there. :) Yeah that converter would be the thing to use.
     
    CanisLupus likes this.
  26. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Hey Dustin,

    Does your library support complex objects.

    So if I had a class with several subclasses inside it, containing multiple records made up of List<T> objects, would that all serialise and deserialise fine?
     
  27. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yep. Like:

    Code (csharp):
    1.  
    2. //Data class
    3. public class SomeData
    4. {
    5.     public int Value {get; set;}
    6. }
    7.  
    8. //Some container
    9. public class DataInfo
    10. {
    11.    public SomeData DataItem {get; set;}
    12.    public int Key {get; set;}
    13. }
    14.  
    15. //Overarching container
    16. public class KeeperOfTheData
    17. {
    18.     public string Name {get; set;}
    19.     public List<DataInfo> DataItems {get; set;}
    20. }
    21.  
    The above would work fine and produce JSON that looks something like this:

    Code (csharp):
    1.  
    2. {
    3.   "Name":"foo",
    4.   "DataItems": [
    5.          {
    6.               "Key": 1,
    7.               "DataItem": {
    8.                          "Value": 5
    9.                }
    10.          },
    11.          {
    12.               "Key": 2,
    13.               "DataItem": {
    14.                           "Value": 8
    15.                }
    16.          }
    17.     ]
    18. }
    19.  
    Of course it wouldn't have all that spacing, that's just for visualization. You actually can specify the formatting to be Indented if you want. It can even support polymorphism so if you have:

    Code (csharp):
    1.  
    2. public class SomeBaseClass
    3. {
    4.       public int Age{get; set;}
    5. }
    6.  
    7. public class ClassA : SomeBaseClass
    8. {
    9.       public string Name {get; set;}
    10. }
    11.  
    12. public class ClassB: SomeBaseClass
    13. {
    14.       public float Gravity {get; set;}
    15. }
    16.  
    17. public class ClassC: ClassA
    18. {
    19.      public Vector3 Position {get; set;}
    20. }
    21.  
    Now you could treat them all as the base class in a collection, or even an interface (so let's same it was ISomeBaseClass instead of SomeBaseClass, it would work the same). As long as you use TypeNameHandling.All you can handle it to serialize and deserialize as that option adds and extra $type parameter to your json string which tells it what concrete type to deserialize as.

    Code (csharp):
    1.  
    2. var dataItems = new List<SomeBaseClass>();
    3.  
    4. dataItems.Add(new ClassA { Age = 4, Name = "Larry"});
    5. dataItems.Add(new ClassB { Age = 9, Gravity = 4.07f; });
    6. dataItems.Add(new ClassC { Age = 36, Name="Dustin", Position = new Vector3(0, 0, 0) });
    7.  
    8. var settings = new JsonSerializerSettings();
    9. settings.TypeNameHandling = TypeNameHandling.All;
    10.  
    11. //Serialize using type name handling
    12. var json = JsonConvert.SerializeObject(dataItems, Formatting.None, settings);
    13.  
    14. //deserialize back to the original concrete instances
    15. var newDataItems = JsonConvert.DeserializeObject(json, settings);
    16.  
    Apologies for any typos in the code above, I just typed it from memory so didn't have the luxury of intellisense. :)
     
    Meltdown likes this.
  28. cjdev

    cjdev

    Joined:
    Oct 30, 2012
    Posts:
    42
    I'm sorry if this has been gone over before but I was wondering if you included support for LINQ to JSON?
     
  29. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
  30. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109

    this is pretty awesome.. this was the question I was coming to ask ;)

    was curious if you've tried this yet with the new plugin directory hierarchy (winrt, x86, ios, et al...) ?
     
  31. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    The plugin hierarchy isn't new (unless there is something else I don't know about). The problem is that it only works for WinRT and a couple of others. iOS and android expect those folders to contain native files (such as .jar files in Android).

    But, I do use that approach with Unity 5 and the new option to specify which assemblies work for each platform. In fact, I'm going to have a new update that I'm pushing later this week that has a couple of workarounds for stripping issues in Android and iOS. I'll push separate unity package files for different unity versions. 3.5 - 4.x will have one package. 5.0 to <5.2 will have one package. And 5.2+ will have another. Reason being that 5.2 added Windows Universal support.

    In the new update, the Unity 5 versions will come as precompiled DLLs instead of loose source code. The source code will still come bundled in a .zip file but it will be structured a bit differently. It will be a solution that includes projects for the different build versions, making it easy to build your own DLLs. And the precompiled DLLs will reduce your build times.

    Another change of note, I will be moving the asset to a /Plugins folder, so it will be /Plugins/JsonDotNet. This improves compatibility with Unityscript and also reduces build time for users with versions < Unity 5 because it won't need a rebuild every time.

    Lastly, I'm still looking at a couple of minor things that are Unity bugs or lack of features and still happen in 5.2. Here is the rundown of the last few items I'm investigating before I push an update (@JoshPeterson):
    1. When I include a .unitypackage with the Windows Store compatible DLL, the editor shows an exception when you first load your project because of the auto-updater tool that Unity uses to examine scripts and dlls against deprecated features. It can't process the DLL (***I'll explain below). This error does not at all affect runtime, so nothing will break. It's just annoying and only shows up when you first load.
    2. When a user imports the .unitypackage on a machine that is not Windows 10 and/or doesn't have the Windows 10 SDK installed, the editor will show an exception that it can't find the .NET Core installation (***I'll explain below). This is fixed by just deleting the /Assemblies/WinUniversal/Newtonsoft.Json DLL as you won't be able to target that platform anyway. Still, I need to file a bug report for it because it's an annoyance.
    3. I have an assembly compatible with Xbox 360, Xbox One, PS3, PS4, WiiU (and hopfully Apple TV), but since I'm not in those developer programs I don't have the option to select those platforms when exporting my .unitypackage. That means that anyone targeting those platforms will have to manually select the /Assemblies/AOT_IL2CPP/Newtonsoft.Json.dll and map it to those platforms. Again, not a show stopper, just an annoyance. If I have assemblies compatible with those platforms I should be able to map them even if I can't build to those platforms.
    4. In the same vein as above, I don't have the ability to disseminate between IL2CPP and Mono, so I can't use a different assembly based on the platform target for Android. For example, Unity now has experimental support for building to Android using IL2CPP but I can't specify a different assembly for use with IL2CPP in Android, so users of that feature may have to change the mapping, although the existing Android DLL might work with IL2CPP on Android instead of swapping to the dedicated IL2CPP version. I have not yet verified complete feature parity here.
    ***Explanation: So, a brief explanation on the Windows Universal issue. Since JSON .NET takes significant advantage of reflection features, of which parity between .NET Core and Mono differs, in order to make your project build and work properly with a Windows Universal project I have to build that version against .NET Core in a Windows Universal class library. Because of that, the DLL for that environment is compiled against .NET 4.5 which is why the upgrade advisor can't parse it and the .NET Core error is displayed on non-Win10 developer machines. In this case, Unity should actually just skip that DLL and not try to process it. Especially when that DLL is set to only work for the WSAPlayer and not selected for the editor.
     
    tswalk likes this.
  32. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    I snipped just a bit out of all that :D ... the pre-built is awesome, glad you're still putting the source though in too, even though I don't require it, I know some people do... but for me, will be a handy learning experience. I'm sold! :p
     
    Dustin-Horne likes this.
  33. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Cool new tool alert. Found and used this nice little site today:
    http://json2csharp.com/

    For those of you that are receiving JSON from a server, this can generate C# classes for you. It's a great starting point for quickly throwing models together.
     
    tswalk likes this.
  34. DickFeynman

    DickFeynman

    Joined:
    Jul 17, 2015
    Posts:
    16
    Hello,
    we are using JSON .NET and it works perfectly.

    One thing about Unity Cloud Build (UCB). When we build (for iOS) on our computers, the build is fine. But when the same project is build on UCB it does not build, and the only errors are from Newtonsoft.Json classes.

    They are not really errors. We don't know why, but UCB gives errors when it finds classes that contains the string "error". There is a screen of the UCB errors in the attachment.

    We don't know how to solve this, and we need builds from UCB but we also need to use your asset.

    How can we solve this?

    Thank you.
     

    Attached Files:

  35. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Oh that is a sucky error. Have you reported it to Unity? In the meantime, send me a PM with your email address and I'll send you a new .unitypackage to try that has the DLLs precompiled which might bypass this problem.
     
  36. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    ANNOUNCEMENT: SALE INCOMING
    If you've been waiting for JSON .NET for Unity to go on sale, you're in luck. Tune in November 27th to November 30th for a huge discount.
     
  37. s0lt4r

    s0lt4r

    Joined:
    Jun 9, 2015
    Posts:
    13
    Hi,

    I'm attempting to create an inventory system using JSON.NET and I'm having a bit of trouble when it comes to serializing non int, string, or array objects. I keep getting a "Sprite is not packed" error as well as a few other errors concerning the serialization of GameObjects.

    I've attached the Item class and the test serialization script.

    //Info for Item
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4.  
    5. [System.Serializable]
    6. public class Item
    7. {
    8.     public string itemName;                                     //itemName of the item
    9.     public int itemID;                                          //itemID of the item
    10.     public string itemDesc;                                     //itemDesc of the item
    11.  
    12.     public Sprite itemIconSprite;                               //itemIcon of the item
    13.     [HideInInspector]
    14.     public string itemIconName= "test";                                 //itemIcon of the item
    15.  
    16.     public GameObject itemModelObject;                          //itemModel of the item
    17.     [HideInInspector]
    18.     public string itemModelName = "test";                                //itemModel of the item
    19.  
    20.     public int itemValue = 1;                                   //itemValue is at start 1
    21.     public ItemType itemType;                                   //itemType of the Item
    22.     public float itemWeight;                                    //itemWeight of the item
    23.     public int itemMaxStack = 1;
    24.     public int rarity;
    25.  
    26.     [SerializeField]
    27.     public List<ItemAttribute> itemAttributes = new List<ItemAttribute>();
    28.  
    29.     public Item(){
    30.         string _itemName = itemName;
    31.         int _itemID = itemID;
    32.         string _itemDesc = itemDesc;
    33.         string _itemIconName = itemIconSprite.name;
    34.         string itemModelName = itemModelObject.name;
    35.         ItemType _itemType = itemType;
    36.         int _itemMaxStack = itemMaxStack;
    37.         List<ItemAttribute> _itemAttributes = itemAttributes;
    38.     }
    39.  
    40.     [SerializeField]
    41.     public Item(string _name, int _id, string _desc, Sprite _icon, GameObject _model, int _maxStack, ItemType _type, string _sendmessagetext, List<ItemAttribute> _attributes)                 //function to create a instance of the Item
    42.     {
    43.         itemName = _name;
    44.         itemID = _id;
    45.         itemDesc = _desc;
    46.         itemIconName = _icon.name;
    47.         itemModelName = _model.name;
    48.         itemType = _type;
    49.         itemMaxStack = _maxStack;
    50.         itemAttributes = _attributes;
    51.     }
    52.  
    53.     public Item getCopy()
    54.     {
    55.         return (Item)MemberwiseClone();      
    56.     }
    57.  
    58.  
    59. }
    //Serialization Script
    Code (CSharp):
    1. using UnityEngine;
    2. using Newtonsoft.Json;
    3. using System.Collections;
    4.  
    5. public class ItemInfo : MonoBehaviour {
    6.  
    7.     public Item item = new Item();
    8.     //JsonSerializer serializer = new JsonSerializer();
    9.  
    10.     // Use this for initialization
    11.     void Awake () {
    12.         //serializer.Converters.Add(new Sp)
    13.         WriteToItemDatabase();
    14.         //Debug.Log(output);
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update () {
    19.     //JsonSerializer.Create
    20.     }
    21.  
    22.     public void WriteToItemDatabase() {
    23.         string output = JsonConvert.SerializeObject(item);
    24.     }
    25. }
    26.  

    Any help/resources from anyone would be greatly appreciated.
     
  38. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    @s0lt4r - i think I've received a couple of contact emails from you through my blog but your email address you've entered appears to be incorrect and bounces every time I try to respond.

    Serialization and deserialization of GameObject and Monobehaviour types is not directly supported. This is mainly due to Unity's override of the equality operator which makes things appear null when they are not exactly. In order to serialize and deserialize the gameobject directly you would have to write a custom json converter to handle the fields you're after. As for the Sprite type, you'd need to show me the exact error you're getting.

    I'm out of the office due to the Thanksgiving holiday but I'll be back and available to help again on Monday.
     
  39. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    what is the difference with you plugin and the serialization that come with unity 5.3 ?
     
  40. BlaceX

    BlaceX

    Joined:
    Oct 28, 2015
    Posts:
    7
    Hi Dustin

    I am trying to serialize a Dictionary<Guid,int> but this fails on Android. Is Guid as keys not supported ?

    Casting to strings is ofcourse the obvious solution but would still be nice to avoid it. I can provice stacktrace and code if you need it.

    Thanks in advance
     
  41. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Tons of differences. The built in unity serialization is native and fast but doesn't support anything complex or custom such as polymorphism or custom converters.

    Could you shoot me an email with the stack trace? dustin(at)parentelement.com. It should work just fine. Sounds like a Unity bug but we can get it reported and work around it without the string cast.
     
  42. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    tosiabunio likes this.
  43. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Just a note to anyone that has purchased, if you're toying around with the Apple TV Beta please reach out to me and I can give you instructions for setting it up for Apple TV and send you an updated build. I am putting together an update that works around a couple of annoying unity stripping issues on iOS and Android. I also have a DLL version ready with Windows 10 Universal support.

    I did not want to push an update right before the sale, but once the sale is complete next week I will be publishing an update (a free upgrade) that adds all things mentioned above.
     
  44. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    yeh I was hoping the unity json support in 5.3 would be enough, however looking at the google docs on it, it seems the implementation is half baked.. so I've purchased yours, can't knock the price :)

    "The built in unity serialization is native and fast but doesn't support anything complex or custom such as polymorphism or custom converters."

    ...Just what sort if speed differences compared to yours, have you tested?

    btw your example test scene is broken.
     
  45. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I have not tested but I think that since it's built in and native it will be allocation free and blazing fast, but at the cost of not being feature rich. It's designed for faster serialization and deserialization, not for complex serialization and deserialization. I think it definitely has its use.

    I know, that happens every time I export from Unity 3.5 for some reason. It's frustrating. Find the TextTest.cs script and reattach it to that ScriptHost gameobject which will fix it. I'll be publishing an update next week and I'm going to revamp that test scene. It's really crummy and I think I can provide some better examples and documentation.
     
  46. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Oh yeah, that's why I announced the sale a couple of days early. :) I know there were some folks thinking about it and I wanted to make sure they (you included) knew it was upcoming so they didn't feel cheated.
     
  47. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Cyber weekend sale has been extended through December 1st.
     
  48. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    @Dustin Horne.

    Does this asset serialise/deserialise

    - dictionaries

    - custom classes

    - collections within collections

    ?
     
  49. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yes to all of the above. Dictionaries have to have primitive types as keys such as int, string, enum etc, but it's possible to build custom converters to handle about any scenario.
     
  50. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,215
    Dustin-Horne likes this.