Search Unity

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

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

  1. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Have you investigated using something like UnityEvent for this? That seems like a simpler/easier approach.

    I think I can make a compilable example from what you gave, but is it possible to send a block of code that describes all of this, ie, including the AttackAction class?
     
  2. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    What errors are you seeing? This should be supported.
     
  3. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    It always happen to me, albeit beyond the error message there seems to be no real negative effect. Do you mind I sent my project for you to check?
     
  4. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    New to your asset. Haven't searched this thread (because you can't - I hate that) so this may have been mentioned.

    How do you handle classes that are derived from NetworkBehavior instead of MonoBehavior?
     
  5. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    I've just attempted to use this and I am not doing something right as it isn't working.

    Here's my code:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using FullInspector;
    4.  
    5. public class Player : BaseBehavior
    6. {
    7.  
    8.     public int factionNumber;
    9.     public string factionName;
    10.  
    11.     public struct ResourceType
    12.     {
    13.         public int ID;
    14.         public string ResourceName;
    15.     }
    16.  
    17.     public struct ResourceOnHand {
    18.         public ResourceType resourceType;
    19.         public int amount;
    20.     }
    21.  
    22.     public ResourceOnHand[] resourcesOnHand = new ResourceOnHand[8];
    23.  
    24.     // Use this for initialization
    25.     void Start ()
    26.     {
    27.    
    28.     }
    29.  
    30.     void Awake ()
    31.     {
    32.         DontDestroyOnLoad (transform.gameObject);
    33.     }
    34.    
    35.     // Update is called once per frame
    36.     void Update ()
    37.     {
    38.    
    39.     }
    40. }
    41.  
    And here is my inspector

     
  6. krainert

    krainert

    Joined:
    Oct 24, 2013
    Posts:
    3
    I've tried it, and it can, but FI won't know to put the proper controls to add elements, meaning you will get duplicate errors when you try to add stuff through the FI GUI.
     
  7. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    Hi!
    Got some issues with flags... Running the following snippet, the serialization/deserialization will not work correctly (I can select the desired value/values, but on play it will be wrong).

    Code (CSharp):
    1. public class test : BaseBehavior {
    2.  
    3.     [Flags]
    4.     public enum TestEnum
    5.     {
    6.         Option1 = 1 << 1,
    7.         Option2 = 1 << 2,
    8.         Option3 = 1 << 3,
    9.     }
    10.  
    11.     public TestEnum enums;
    12.  
    13. }
    It's inconsistent in some way, so I'll think you'll find something... Selecting Option1 only will in all cases result in "Nothing" upon play.
    Also, the [Enum] attribute doesn't seem to do it's job. Setting "hide all" and/or "hide none" to true doesn't actually hide them.

    Edit.
    One more thing. If I already have None/All (0 and Int32.MaxValue) in my flag-enum, "Nothing" & "Everything" is still displayed which gives me 2 options for each.

    Thanks! :)
     
  8. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Could be possible to improve InspectorOrder attribute to share the order index between parent-child classes?
    Now the child class fields are shown always after the parent fields, no matter what values I set.
    Thanks
     
  9. sient

    sient

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

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    You should be able to derive from BaseNetworkBehavior instead.
     
  11. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602

    Are you still having this issue? This works as expected on my end.
     
  12. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Ah, ok - I see. Can you use a generic OrderedDictionary implementation instead? You can find one here.
     
  13. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Ah, thanks. This looks like a bug in Full Serializer; I'll try to get to it soon. See here.
     
  14. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    The order is intentionally split up the order between parent/child derived classes so that you can use whatever numbers you want. If you've modified FI such that this does not happen, I'd be happy to make it an option in [InspectorOrder] or a similar annotation.
     
  15. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Do you use Dropbox? PM me how to sent the project. It's not very big, but not suitable for email.
     
  16. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I didn't modify FI to force it. So if you want you could plan it for futures versions.
    Thanks
     
  17. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Does FI not support Stack<T> collections in the inspector? I have a pooling solution where I'm using Stack<Transform> with [SerializeField] and it's not showing up in the inspector, although other members of the class are.
     
  18. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    Got another issue building to Windows Store (Universal 10), lots of "ambiguous calls" in the following classes:
    • tkControl
    • fsMetaType
    • DTOFormatter
    • TypeCache
    • InspectedProperty
    • InspectedType
    • fiRuntimeReflectionUtility
    Example:
    Code (CSharp):
    1. Assets\FullInspector2\Core\fiRuntimeReflectionUtility.cs(326,42): error CS0121: The call is ambiguous between the following methods or properties: 'System.AssemblyExtensions.GetTypes(System.Reflection.Assembly)' and 'System.Reflection.AssemblyExtensions.GetTypes(System.Reflection.Assembly)'
    Any clue? Just got it so haven't looked at it any deeper yet.

    Edit.

    Another issue: When I build to iOS, i get the following error (which can be fixed automatically though):

    Code (CSharp):
    1. /Users/ACE/Desktop/temp/Builds/iOS/acelib-ui/acelib-ui/Classes/Native/Bulk_Assembly-CSharp_2.cpp:3967:14: Use of undeclared identifier 'BaseNetworkBehavior_1_OnSerialize_m2271'; did you mean 'BaseNetworkBehavior_OnSerialize_m1242'?
     
    Last edited: Oct 9, 2015
  19. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    After taking a few days off and returning to it with a fresh perspective, I figured out it was do to the complication of prefabs. I got myself all straightened out. Thank you.
     
  20. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I have this Log when I hit play on Unity 5.2.1p3

     
  21. RChrispy

    RChrispy

    Joined:
    Dec 18, 2013
    Posts:
    71
    Hey I wanted to test FI but the demo is not available? :(
    I the things I see and read are nice! I need some inspector for my interfaces. :)
     
  22. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yep, feel free to send me a link in a PM.
     
  23. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Wow, you're right - I've added support just now. I will PM you a build that includes support.
     
  24. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Can you try disabling the AssemblyExtensions class in FullInspector2\Core\FullSerializer\Module\Source\Internal\fsPortableReflection.cs? Thanks

    The other issue can be fixed by deleting BaseNetworkBehavior.
     
  25. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Wow! Does this always happen?
     
  26. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Can you retry downloading it? I just tried it myself and it worked as expected. The demo is on the first post in this forum thread.
     
  27. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @sient ,

    This has probably been asked a few times before but what if I am creating ScriptableObjects database items as in:-

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class BaseItemClass : ScriptableObject {
    5.  
    6.     public int itemID;
    7.  
    8.     public string itemName;
    9.  
    10.     public string itemTooltip;
    11.  
    12.     public string itemDescription;
    13.  
    14.     public Texture2D itemIcon;
    15.  
    16.     public GameObject itemModel;
    17.  
    18. }
    19.  
    and then attempting to look at the ScriptableObjects, when created, one at a time in the Inspector?

    How can Full Inspector help with that?
     
  28. andygami

    andygami

    Joined:
    Jan 10, 2014
    Posts:
    6
    i am running into issue with saving SharedInstances in the game while playing on the phone.
    I followed the guide as shown here https://github.com/jacobdufault/fullinspector/issues/26 but visual studio throw error stating that the FullInspector.FullInspectorSaveManager does not exist. seems like the link is outdated.
     
  29. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    This didn't work, unfortunately.
     
  30. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    It happens every time I open the project and every second time I play the game in the editor.
    I'm on Unity 5.2.1p3 now.
     
  31. Illusive-S

    Illusive-S

    Joined:
    Sep 19, 2013
    Posts:
    8
    There are Behavior Editors and Property Editors for Editors and Property drawers, is there a similar tool for EditorWindow? Can i do things like using PropertyEditor in EditorWindow?
     
  32. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    @sient

    Just wondering, will this asset still be supported in the future Unity update. It seems 5.3 will break a few thing.
     
  33. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry, can you be more specific? I'm a bit confused by "and then attempting to look at the ScriptableObjects, when created, one at a time in the Inspector?".
     
  34. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    That code is really old, back in FI 1.0 days it seems. What's the issue you're experiencing?
     
  35. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Ok, I'll look into windows 10 compilation support. I've created an issue here, though I'm going to look into this as soon as the SDK is done installing.
     
  36. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    So it is breaking anything? If you're using FS it might be fine, but for Json.NET / etc it might be breaking serialization. Does this happen in every build environment/setup?
     
  37. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sure, please see this document in the docs.
     
  38. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yes, I will continue to support it. I've been a bit short on time these past few weeks. I'll look into 5.3 - what's breaking? All I see are a few deprecation warnings which I'll get fixed in the next patch release.
     
  39. andygami

    andygami

    Joined:
    Jan 10, 2014
    Posts:
    6
    Code (csharp):
    1.  
    2. struct MyStruct
    3. {
    4.     public int a,b,c;
    5. }
    6.  
    7. public class MyClass : BaseBehavior
    8. {
    9.     public SharedInstance<MyStruct> mySharedInstance;
    10.  
    11.     void Edit()
    12.     {
    13.         mySharedInstance.Instance.a = 1;
    14.         mySharedInstance.Instance.b = 2;
    15.         mySharedInstance.Instance.c = 3;
    16.     }
    17. }
    18.  
    Using the code above, the changes i made will only be saved if i am running on the editor. It won't save while playing on devices..
     
  40. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    it is usable upto 5.3.0b3, but in b4 BaseNetworkBehavior seems to be broken and gave compile errors.
     
  41. rageingnonsense

    rageingnonsense

    Joined:
    Dec 3, 2014
    Posts:
    99
    I'm using the FullSerializer aspect of this (standalone). I installed the source folder, but nothing is being serialized (or more correctly, things are being serialized exactly as if unity was doing them). am I missing something? From the docs, it seems like I only need to copy the folder over and everything will just work. However, none of my LinkedLists are being serialized (along with a few arrays of custom objects).

    Is there something else I need to do to get this to work at all? I'm testing it via using Instantiate to clone an existing object.
     
  42. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Did you change your class to be based on FullInspector.BaseBehaviour? If not, that's probably why.
     
  43. rageingnonsense

    rageingnonsense

    Joined:
    Dec 3, 2014
    Posts:
    99
    I actually don't have that class available. I didn't get FullInspector in its entirety. I just got FullSerializer because that is really all I need. Does FullSerializer just not work without FullInspector?
     
  44. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    This is the support thread for FullInspector. I assumed, therefore, that you were looking for support for FullInspector.
     
  45. rageingnonsense

    rageingnonsense

    Joined:
    Dec 3, 2014
    Posts:
    99
    And that is a perfectly fair assumption. :p

    FullSerializer doesn't seem to have a support thread (that I could find). I know it was made for FullInspector, but https://github.com/jacobdufault/fullserializer suggests it works as a standalone module. Just trying to figure out if I am making the wrong assumption, or if I did something wrong.
     
  46. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I often use the InspectorCategory attribute for my scripts, but I have some difficulties when inheritance is involved.
    A base class that is inside my framework has a some public fields without any InspectorCategory assigned. As soon as a child class start to use the attribute, all the fields of the parent disappear from the inspector.
    Would be probably better to have some kind of default "others" tab being added automatically for all the non assigned fields.
    Even if I set a category to the parent class, then I have to set a category to all the children and this is not good.
    Maybe I'm missing something and complicating the things more than needed.
    Please let me know.
     
  47. LazloBonin

    LazloBonin

    Joined:
    Mar 6, 2015
    Posts:
    813
    FYI, Application.isLoadingLevel is now obsolete and throws a warning in Unity 5.2.2.

    (At fiSerializationManager.cs:116)
     
  48. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I just noticed this error as well.
     
  49. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I've solved the problem by delete all BaseNetworkBehavior related files (3 of them for me).
     
  50. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi guys, I'm experiencing from long time a problem with ScriptInspector that is hard to reproduce in a new empty project, and I'm wondering if I'm the only one :(
    Often, when I edit some field in the inspector and i hit play, or apply (in case of a prefab) I loose all the changes. The only way to avoid it is to use "save current state" in the context menu of the component, and then play or apply.
    If you have the same issue we could try to find a way to reproduce it and help @sient to fix it.