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. Illusive-S

    Illusive-S

    Joined:
    Sep 19, 2013
    Posts:
    8
    My class is a native C# one so i made it derived from UnityEngine.Object
    But now i dont have access to its fields, it now looks like this in the inspector

    EDIT:
    BaseObject is being displayed properly, but i cant instantiate with it
     

    Attached Files:

    Last edited: Jun 2, 2015
  2. Psygantic

    Psygantic

    Joined:
    Mar 4, 2014
    Posts:
    10
    I have a project using Full Inspector that was consistently deploying fine to iOS. However, recently I switched to il2cpp (which is now mandatory for x64 support on iOS) and a fresh XCode project will no longer build. The problem appears to come from several generated files named Bulk_Generics_42.cpp, Bulk_Generics_43.cpp, etc., which contain #include statements for non-existent header files related to Full Inspector, for example:
    Code (CSharp):
    1.  
    2. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_1.h"
    3. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_1MethodDeclarations.h"
    4. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_2.h"
    5. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_2MethodDeclarations.h"
    6. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_3.h"
    7. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_3MethodDeclarations.h"
    8. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_4.h"
    9. #include "AssemblyU2DCSharp_FullInspector_tk_2_gen_4MethodDeclarations.h"
    10.  
    and so on, up to "gen_62". These files do not exist, though four files with similar names do:
    AssemblyU2DCSharp_FullInspector_tk_2_gen_0.h looks like:
    Code (CSharp):
    1. #pragma once
    2. #include <stdint.h>
    3. // System.Object
    4. #include "mscorlib_System_Object.h"
    5. // FullInspector.tk`2<System.Object,FullInspector.tkDefaultContext>
    6. struct tk_2_t15930  : public Object_t
    7. {
    8. };
    9.  
    AssemblyU2DCSharp_FullInspector_tk_2_gen_0MethodDeclarations.h looks like:
    Code (CSharp):
    1. #pragma once
    2. #include <stdint.h>
    3. #include <assert.h>
    4. #include <exception>
    5. #include "codegen/il2cpp-codegen.h"
    6.  
    7. // FullInspector.tk`2<System.Object,FullInspector.tkDefaultContext>
    8. struct tk_2_t15930;
    9.  
    10. // System.Void FullInspector.tk`2<System.Object,FullInspector.tkDefaultContext>::.ctor()
    11. // FullInspector.tk`2<System.Object,System.Object>
    12. #include "AssemblyU2DCSharp_FullInspector_tk_2_genMethodDeclarations.h"
    13. #define tk_2__ctor_m94287(__this, method) (( void (*) (tk_2_t15930 *, MethodInfo*))tk_2__ctor_m56551_gshared)(__this, method)
    14.  
    I'm using Unity 4.6.5 and Full Inspector 2.6.1. This is high severity, obviously - I can't deploy to iOS at all anymore.
     
    shochet likes this.
  3. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I believe I have fixed this perf regression - I've sent you a build.
     
    psxcode likes this.
  4. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    If you're using SharedInstance, you can Instantiate on the actual SharedInstance instance itself

    ie, if you have SharedInstance<foo> a;, then you call Object.Instantiate(a)

    What did you change to use BaseObject? The Instantiate should still work fine for that.
     
  5. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks, I have fixed this issue. Can you start a conversation with me and then I'll send you a link to the build? It looks like I cannot start a conversation with you.
     
  6. psxcode

    psxcode

    Joined:
    Jan 26, 2014
    Posts:
    26
    Hi. I want to propose this tiny addition to InspectorDatabase attribute editor

    I have a lot of elements and my scripts use index based references to find the data.
    Here I use index-based counter, and also the INSERT button.

    the Code
    fiListUtility.cs
    add function
    Code (CSharp):
    1.  
    2.         public static void InsertAt<T>(ref IList list, int index)
    3.         {
    4.             if (list.GetType().IsArray) {
    5.                 var wrappedList = new List<T>((IList<T>)list);
    6.                 wrappedList.Insert(index, default(T));
    7.                 list = wrappedList.ToArray();
    8.             } else {
    9.                 list.Insert(index, default(T));
    10.             }
    11.         }
    InspectorDatabaseEditorAttributeEditor.cs
    add functions
    Code (CSharp):
    1.  
    2.         private static bool CanInsertItem(tkDatabaseContext context)
    3.         {
    4.             var list = context.editedList;
    5.             return list.Count > 0 && GetCurrentIndex(context) < list.Count - 1;
    6.         }
    7.         private static void InsertItem(tkDatabaseContext context)
    8.         {
    9.             fiListUtility.InsertAt<T>(ref context.editedList, GetCurrentIndex(context));
    10.         }
    add Label_Insert
    Code (CSharp):
    1.  
    2. private static readonly fiGUIContent Label_Forward_Add = new fiGUIContent("Add", "Add a new item");
    3. private static readonly fiGUIContent Label_Insert = new fiGUIContent("Ins", "Insert a new item into current position");
    4. private static readonly fiGUIContent Label_Delete = new fiGUIContent("X", "Delete the current item");
    5.  
    insert new Button code
    Code (CSharp):
    1.  
    2. ...  },
    3. 2,
    4. {
    5. 40,
    6. new tk.Button(Label_Insert, (o, c) => InsertItem(c)) {
    7.     Styles = {
    8.            new tk.Color(Color.green),
    9.            new tk.EnabledIf((o, c) => CanInsertItem(c))
    10.      }
    11. }
    12. },
    13. 2,
    14.                            
    for index-based counter
    Code (CSharp):
    1.  
    2.                       new tk.IntSlider(tk.Val((o, c) => GetLabelText(c)),
    3.                             /*min, max*/ 0, tk.Val(l => l.Count - 1),
    4.                             /*get*/ (l, c) => l.Count == 0 ? 0 : GetCurrentIndex(c),
    5.                             /*set*/ (l, c, i) => ChangeIndexTo(c, i))
     
  7. Psygantic

    Psygantic

    Joined:
    Mar 4, 2014
    Posts:
    10
    Thank you - that seems to have fixed it.
     
  8. Deleted User

    Deleted User

    Guest

    I'm having an issue using KeyedCollection.

    I have my own KeyedCollection:

    Code (CSharp):
    1.     [Serializable]
    2.     public class EnumDictionary<T> : KeyedCollection<StatType, T> where T : Stat
    3.     {
    4.         protected override StatType GetKeyForItem(T item)
    5.         {
    6.             Debug.Log("Item value = " + item);
    7.             return item == null ? StatType.Null : item.StatType;
    8.         }
    9. }
    But it won't let me add items to it. I keep getting this error when trying to add an item:

    NullReferenceException: Object reference not set to an instance of an object
    Game.EnumDictionary`1[Game.Stat].GetKeyForItem (Game.Stat item) (at Assets/ObjectDictionary.cs:33)
    System.Collections.ObjectModel.KeyedCollection`2[Game.StatType,Game.Stat].InsertItem (Int32 index, Game.Stat item) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.ObjectModel/KeyedCollection.cs:161)
    System.Collections.ObjectModel.Collection`1[Game.Stat].Add (Game.Stat item) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:72)
    FullInspector.Internal.ListAdaptor`1[Game.Stat].Add () (at Assets/Imports/FullInspector2/Modules/Collections/Editor/Adaptors/ListAdaptor.cs:49)
    FullInspector.Rotorz.ReorderableList.ReorderableListControl.AddItem (IReorderableListAdaptor adaptor) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListControl.cs:1369)
    FullInspector.Rotorz.ReorderableList.ReorderableListControl.DoAddButton (Rect position, Int32 controlID, IReorderableListAdaptor adaptor) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListControl.cs:446)
    FullInspector.Rotorz.ReorderableList.ReorderableListControl.DrawFooterControls (Rect position, Int32 controlID, IReorderableListAdaptor adaptor) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListControl.cs:922)
    FullInspector.Rotorz.ReorderableList.ReorderableListControl.Draw (Rect position, Int32 controlID, IReorderableListAdaptor adaptor, FullInspector.Rotorz.ReorderableList.DrawEmptyAbsolute drawEmpty) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListControl.cs:1075)
    FullInspector.Rotorz.ReorderableList.ReorderableListControl.DrawControlFromState (Rect position, IReorderableListAdaptor adaptor, FullInspector.Rotorz.ReorderableList.DrawEmptyAbsolute drawEmpty, ReorderableListFlags flags) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListControl.cs:240)
    FullInspector.Rotorz.ReorderableList.ReorderableListGUI.DoListFieldAbsolute (Rect position, IReorderableListAdaptor adaptor, FullInspector.Rotorz.ReorderableList.DrawEmptyAbsolute drawEmpty, ReorderableListFlags flags) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListGUI.cs:218)
    FullInspector.Rotorz.ReorderableList.ReorderableListGUI.ListFieldAbsolute (Rect position, IReorderableListAdaptor adaptor, FullInspector.Rotorz.ReorderableList.DrawEmptyAbsolute drawEmpty, ReorderableListFlags flags) (at Assets/Imports/FullInspector2/Modules/Collections/Rotorz/Editor/ReorderableListGUI.cs:227)
    FullInspector.Internal.BaseCollectionPropertyEditor`4[Game.EnumDictionary`1[Game.Stat],System.Collections.Generic.IList`1[Game.Stat],Game.Stat,Game.Stat].DoEdit (Rect region, UnityEngine.GUIContent label, IList`1& collection, FullInspector.fiGraphMetadata metadata, IReorderableListAdaptor adaptor) (at Assets/Imports/FullInspector2/Modules/Collections/Editor/BaseCollectionPropertyEditor.cs:159)
    FullInspector.Internal.BaseCollectionPropertyEditor`4[Game.EnumDictionary`1[Game.Stat],System.Collections.Generic.IList`1[Game.Stat],Game.Stat,Game.Stat].Edit (Rect region, UnityEngine.GUIContent label, IList`1 collection, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Modules/Collections/Editor/BaseCollectionPropertyEditor.cs:411)
    FullInspector.PropertyEditor`1[System.Collections.Generic.IList`1[Game.Stat]].FullInspector.IPropertyEditorEditAPI.Edit (Rect region, UnityEngine.GUIContent label, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditor.cs:62)
    FullInspector.PropertyEditorExtensions.DoEdit2[Object] (IPropertyEditorEditAPI api, Rect region, UnityEngine.GUIContent label, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:180)
    FullInspector.PropertyEditorExtensions.DoEdit[Object] (IPropertyEditorEditAPI api, Rect region, UnityEngine.GUIContent label, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:89)
    FullInspector.PropertyEditorExtensions.Edit[Object] (IPropertyEditor editor, Rect region, UnityEngine.GUIContent label, System.Object element, fiGraphMetadataChild metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:77)
    FullInspector.Internal.fiEditorGUI.EditPropertyDirect (Rect region, FullInspector.InspectedProperty property, System.Object propertyValue, fiGraphMetadataChild metadataChild, System.Object context) (at Assets/Imports/FullInspector2/Core/Editor/fiEditorGUI.cs:305)
    FullInspector.Internal.fiEditorGUI.EditProperty (Rect region, System.Object container, FullInspector.InspectedProperty property, fiGraphMetadataChild metadata) (at Assets/Imports/FullInspector2/Core/Editor/fiEditorGUI.cs:315)
    FullInspector.Internal.ReflectedPropertyEditor.EditProperty (UnityEngine.Rect& region, System.Object element, FullInspector.InspectedProperty property, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:163)
    FullInspector.Internal.ReflectedPropertyEditor.EditInspectedMember (UnityEngine.Rect& region, System.Object element, InspectedMember member, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:250)
    FullInspector.Internal.ReflectedPropertyEditor.EditPropertiesButtons (UnityEngine.GUIContent label, Rect region, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:292)
    FullInspector.Internal.ReflectedPropertyEditor.Edit (Rect region, UnityEngine.GUIContent label, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:344)
    FullInspector.PropertyEditorExtensions.DoEdit2[Object] (IPropertyEditorEditAPI api, Rect region, UnityEngine.GUIContent label, UnityEngine.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:180)
    FullInspector.PropertyEditorExtensions.DoEdit[Object] (IPropertyEditorEditAPI api, Rect region, UnityEngine.GUIContent label, UnityEngine.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:89)
    FullInspector.PropertyEditorExtensions.Edit[Object] (IPropertyEditor editor, Rect region, UnityEngine.GUIContent label, UnityEngine.Object element, fiGraphMetadataChild metadata) (at Assets/Imports/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:77)
    FullInspector.DefaultBehaviorEditor.OnEdit (Rect rect, UnityEngine.Object behavior, FullInspector.fiGraphMetadata metadata) (at Assets/Imports/FullInspector2/Core/Editor/DefaultBehaviorEditor.cs:29)
    FullInspector.BehaviorEditor`1[TBehavior].Edit (Rect rect, UnityEngine.Object behavior) (at Assets/Imports/FullInspector2/Core/Editor/IBehaviorEditor.cs:64)
    FullInspector.IBehaviorEditorExtensions.EditWithGUILayout[Object] (IBehaviorEditor editor, UnityEngine.Object element) (at Assets/Imports/FullInspector2/Core/Editor/IBehaviorEditorExtensions.cs:22)
    FullInspector.FullInspectorCommonSerializedObjectEditor.ShowInspectorForSerializedObject (UnityEngine.Object target) (at Assets/Imports/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:150)
    FullInspector.FullInspectorCommonSerializedObjectEditor.OnInspectorGUI () (at Assets/Imports/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:166)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1150)
    UnityEditor.DockArea:OnGUI()
     
  9. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602

    Sure, I've added the changes (except for the label bit). Thanks!
     
  10. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I'm having a hard time reproducing this. Can you send a larger sample? KeyedCollection uses a really unusual set of APIs. Are you able to use a dictionary instead?
     
  11. tthmok

    tthmok

    Joined:
    Apr 16, 2014
    Posts:
    3
    I have this same issue right now.
     
  12. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Sorry about that! I've PM'ed you a build.
     
  13. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    @sient I wrote you by emails a couple of days ago about losing the changes on ScriptableObjects. Not sure if you got it. Please could you check?
     
  14. brendan-vance

    brendan-vance

    Joined:
    Jan 16, 2014
    Posts:
    36
    I'm getting a rather bizarre issue in which interface reference assigned in several of my prefabs seem to come unhooked. I've yet to be able to reproduce the exact circumstances under which this happens, BUT it only seems to occur in cases where I am inspecting a prefab's interface field at runtime PRIOR TO instantiating it. Anybody have any experience with this?
     
  15. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Oops - sorry! I found the email and I've sent a reply.
     
  16. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Is there any editor code touching the prefab? 2.6.2 comes with a new serialization system which should address a couple of rare edge-case scenarios. I'd be happy to send you a prerelease 2.6.2 build.
     
  17. brendan-vance

    brendan-vance

    Joined:
    Jan 16, 2014
    Posts:
    36
    There is code that reads values from the prefab at runtime, but no; nothing ever actually modifies it, nor does any editor-only code load or attempt to access it in any way.

    I've coded around the specific issue I was having, so I don't need a prerelease build right this minute! I think we can hold out until 2.6.2 goes live.
     
  18. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    I have a class that is serialized using the FullInspector.JsonNetSerializer.
    Between various properties it contains a Unity Transform referencing a prefab.

    Everything works fine with Unity but now I need to export and import this class using json files for backup purpose.
    I know that it's a problem to work with Unity Object class, but I'm trying to solve it for my editor tool.

    The first thing that I tried was to exclude it from the serialization using the [JsonIgnore] attribute, but this also makes the property to disappear from the inspector. How to do this properly?

    A much better solution would be to convert the prefab reference into a file path during the serialization process and to convert it back to a prefab reference when deserializing. Any idea how to proceed? Creating a custom JsonConverter could be enough? Will not go in conflict with FullInspector serialization?

    Thanks
     
  19. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    I'd be happy to help you write a custom JsonConverter. I think you still have my email address, if not just shoot me a PM here on the forums. I'll be out this afternoon but can look at it this evening if you just send me the class you want to serialize and the property that's giving you issues.
     
  20. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Thank you Dustin for your help.
    Here is the custom JsonConverter in case someone will need it.

    I prefer to export my ScriptableObjects to json to have a readable/recoverable backup. With ScriptableObject and Unity's unpredictable bugs it's always better to have an additional data format to store important settings.

    Code (CSharp):
    1. usingNewtonsoft.Json;
    2. usingSystem;
    3. usingUnityEditor;
    4. usingUnityEngine;
    5. public class TransformConverter : JsonConverter {
    6.    
    7.     public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
    8.         var path = AssetDatabase.GetAssetPath((UnityEngine.Object)value);
    9.         serializer.Serialize(writer, path);
    10.     }
    11.    
    12.     public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
    13.         if (reader.TokenType == JsonToken.Null)
    14.             return null;
    15.  
    16.         var path = (string)reader.Value;
    17.         var prefab = AssetDatabase.LoadAssetAtPath<Transform>(path);
    18.         if (prefab == null) {
    19.             Debug.LogWarning("Can't deserialize prefab reference: " + path);
    20.         }
    21.         return prefab;
    22.     }
    23.    
    24.     public override bool CanConvert(Type objectType) {
    25.         return objectType.IsAssignableFrom(typeof(Transform));
    26.     }
    27.    
    28. }
    It should be placed inside an Editor folder, or inside a #if UNITY_EDITOR conditional compilation block.
     
    Dustin-Horne likes this.
  21. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    should CanEditMultipleObjects work yet/ever? thanks
     
  22. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Thanks! :)

    Did you get this figured out and is it working how you want?
     
  23. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    I've actually tried a few different approaches to implement this, but all of them have failed to pan out for various reasons. The most promising solution ended up crashing Unity's C# compiler :(.

    My next goal is to make the attribute editor system significantly more extensible (when this is done, I'll push it out as 2.7, but 2.6.2 is finally almost ready - turns out there were quite a few bugs unfortunately :(.

    Rewriting the attribute editor system involves rewriting how context gets passed through property editors, but once that is done it should hopefully be a bit more feasible to implement multiple-object editing. I'm still planning to do it - it's just a difficult architectural problem; I could hack in support quickly but it would be a buggy mess that would cause more issues than it solved.
     
    rakkarage likes this.
  24. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yep :). It was just a matter of making sure he was clearing and populating his existing list rather than just appending I believe. but he got it working yes.
     
  25. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Yes. I tried first to use the attribute to exclude the Transform from the serialization but that was affecting also FullInspector.
    Instead, using a custom JsonConverter only when exporting/importing to json file, resolved perfectly my requirements.
     
    Dustin-Horne likes this.
  26. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Great! Sounds like a good approach to me!
     
  27. mrleerman

    mrleerman

    Joined:
    Jul 15, 2014
    Posts:
    3
    No problem, just glad to have it resolved. :)

    The next bit of weirdness I'm seeing seems to be a bug in fsMetaType. While attempting to deserialize a class that has a parameterized constructor but no default constructor fsMetaType gets a null reference exception whose stacktrace looks like this:

    Exception caught when deserializing property <_eventDispatcher> in <ScourgeFemale (Trykes.Action)>
    System.NullReferenceException: Object reference not set to an instance of an object
    at FullSerializer.fsMetaType.get_HasDefaultConstructor () [0x0008d] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\Reflection\fsMetaType.cs:244
    at FullSerializer.fsMetaType.CreateInstance () [0x00081] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\Reflection\fsMetaType.cs:279
    at FullSerializer.Internal.fsReflectedConverter.CreateInstance (FullSerializer.fsData data, System.Type storageType) [0x00007] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\Converters\fsReflectedConverter.cs:73
    at FullSerializer.fsSerializer.InternalDeserialize_3_Inheritance (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1 processors) [0x000d7] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\fsSerializer.cs:683
    at FullSerializer.fsSerializer.InternalDeserialize_2_Version (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1 processors) [0x000da] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\fsSerializer.cs:642
    at FullSerializer.fsSerializer.InternalDeserialize_1_CycleReference (FullSerializer.fsData data, System.Type storageType, System.Object& result, System.Collections.Generic.List`1 processors) [0x0003a] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\fsSerializer.cs:611
    at FullSerializer.fsSerializer.TryDeserialize (FullSerializer.fsData data, System.Type storageType, System.Object& result) [0x0003f] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\Module\Source\fsSerializer.cs:586
    at FullInspector.FullSerializerSerializer.Deserialize (System.Reflection.MemberInfo storageType, System.String serializedState, ISerializationOperator serializationOperator) [0x00028] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\FullSerializer\FullSerializerSerializer.cs:93
    at FullInspector.Internal.fiISerializedObjectUtility.RestoreState[FullSerializerSerializer] (ISerializedObject obj) [0x0016e] in W:\Users\mr_leerman\Documents\Unity Projects\Simple Bolt\Assets\FullInspector2\Core\fiISerializedObjectUtility.cs:209
    UnityEngine.Debug:LogError(Object, Object)
    FullInspector.Internal.fiISerializedObjectUtility:RestoreState(ISerializedObject) (at Assets/FullInspector2/Core/fiISerializedObjectUtility.cs:214)
    FullInspector.BaseBehavior`1:RestoreState() (at Assets/FullInspector2/Core/BaseBehavior.cs:68)
    FullInspector.BaseBehavior`1:OnValidate() (at Assets/FullInspector2/Core/BaseBehavior.cs:50)

    Following the stacktrace, Resharper lights up FsMetaType.cs line 244 with a warning about a null reference exception which seems to be the exact problem. I duplicated the null check from line 243 and the exception seems to have vanished.

    Thought you should know in case it hasn't been caught in 2.6.2.
     
  28. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yep, this has been fixed! Thanks :)
     
  29. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    Sient, 2 Questions:

    1. In the lastest Unity build they've added a [CreateAssetMenu] decorator for scriptableobjects. When used, Unity will add a menu items for your scriptable object in the Assets menu.
    https://pbs.twimg.com/media/CHNlyfTW8AAkQPP.png:large

    With this addition are there any real differences between using BaseScriptableObject vs SharedInstance? I'm leaning towards using scriptableobjects for potential forward compatibility issues. I'm not sure if there would be downtime if unity changed something and broke the SharedInstance feature.

    2. Is there an easy way to adjust the height on [InspectorTextArea] fields. By default they take up a lot of real estate. I'd like to be able to set the height to 20px or something like that.
     
    Last edited: Jun 25, 2015
    rakkarage likes this.
  30. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Use whichever you prefer, SharedInstance has a UX optimized for different things. SharedInstance communicates intent more clearly and enables you to use any class inside of a ScriptableObject without creating a specific scriptable object class (well, one is generated automatically for you).

    Regarding downtime, if SharedInstance were broken then pretty much all of FI would be broken, but since the serialization callback receiver support FI should be stable long-term.

    Sure, you should be able to just do [InspectorTextArea(20)] or [InspectorTextArea(Height = 20)].
     
  31. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    awesome. great job, btw. i was staring into the face of madness before i found FI.
     
  32. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    853
    Can FI expose dictionaries featuring custom value types (like a class with a number of variables itself)?
     
  33. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    Seint, can you point me to the documentation that covers things like [InspectorTextArea(20)]. The guide doesn't seem to cover all of the functionality so I've just been trying to back engineer some of the functionality from looking at the sample code.
     
  34. sz-Bit-Barons

    sz-Bit-Barons

    Joined:
    Nov 12, 2013
    Posts:
    150
    Hi sient,

    I have a problem with a custom property drawer...
    The reference structure is the following:
    - BaseBehaviour
    -> Serialized class (standard drawer)
    --> Serialized abstract class (standard drawer for the selected inherited class)
    ---> Serialized class (custom property drawer)

    The problem is that I don't see anything of the custom property drawer and everything which comes after that.
    here is a screenshot:


    However, if I have the class with the custom property drawer referenced directly inside a class deriving from BaseBehavior or MonoBehaviour everything is rendered okay:


    I use EditorGUILayout which might cause the problem (but I am not sure). Here is my code for the property drawer:

    Code (CSharp):
    1.     [CustomPropertyDrawer(typeof(AssetInfo))]
    2.     public class AssetInfoDrawer : PropertyDrawer
    3.     {
    4.         UnityEngine.Object cache;
    5.         bool foldout;
    6.  
    7.         public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    8.         {
    9.             Rect rect = new Rect(pos.xMin, pos.yMin, pos.width, 4 * pos.height);
    10.  
    11.             EditorGUI.BeginProperty(rect, label, prop);
    12.  
    13.             var indent = EditorGUI.indentLevel;
    14.             EditorGUI.indentLevel = 0;
    15.  
    16.             SerializedProperty category = prop.FindPropertyRelative("Category");
    17.             SerializedProperty bundleName = prop.FindPropertyRelative("BundleName");
    18.             SerializedProperty assetName = prop.FindPropertyRelative("AssetName");
    19.  
    20.  
    21.             string title = string.Format("{0}: {1}/{2} >> {3}", label.text, category.stringValue, bundleName.stringValue, assetName.stringValue);
    22.  
    23.             using (EditorGuiZone.Vertical("box"))
    24.             {
    25.                 if (EditorGuiZone.FoldOut(ref foldout, title))
    26.                 {
    27.                     EditorGUILayout.PropertyField(category);
    28.                     EditorGUILayout.PropertyField(bundleName);
    29.                     EditorGUILayout.PropertyField(assetName);
    30.                 }
    31.  
    32.                 UnityEngine.Object o = EditorGUILayout.ObjectField("Drop asset here", cache, typeof(UnityEngine.Object), false);
    33.  
    34.                 if (o != cache)
    35.                 {
    36.                     cache = o;
    37.                     // some logic
    38.                 }
    39.             }
    40.  
    41.             EditorGUI.indentLevel = indent;
    42.  
    43.             EditorGUI.EndProperty();
    44.         }
    45.  
    46. // EDIT: using(EditorGuiZone.Something()) { } will call the corresponding Begin and End methods automatically. (little helper script I wrote to make UI code more readable)
    47.  
    I found a thread where somebody has a similar problem and a simple solution for it (custom editor for the monobehaviour - this doesn't work) as well as a complex solution for it:
    http://answers.unity3d.com/questions/661360/finally-a-solution-cant-use-guilayout-stuff-in-pro.html
    The complex solution includes using another unity package which has many features which are similar to full inspector. Since it has it's own serialization and stuff I didn't tried that 'cause it probably wouldn't work together with full inspector.

    I am not sure if full inspector is responsible for this problem. But maybe it can solve it anyway?
    Or is there another solution how I can fix it?
    Thanks in advance.
     
  35. sz-Bit-Barons

    sz-Bit-Barons

    Joined:
    Nov 12, 2013
    Posts:
    150
    Sorry for the double post. But Now I have something different, which I want to separate from the post above to emphasise that this is another little issue.
    (BTW: I managed to get the code above working by not using any EditorGUILayout (I had to definedd all the Rectangles)... It is not as pretty as before but wirking).

    I used my class with the custom property drawer (see previous post) in a Dictionary as Value.
    As Key I use an enum called "DeviceSize".
    I have this ObjectField in my property drawer which is not connected directly to a field in my class (I just use it to extract some data).

    Now when I Drag a Prefab over the object filed I receive the following error:
    So in BaseCollectionPropertyEditor.GetBestDragAndDropObject() it wants to access a component of the type "DeviceSize". I don't really understand why, cause I hover over a field provided by the value not the key...

    This doesn't seem to break anything. just wanted to let you know.
     
  36. stevethorne

    stevethorne

    Joined:
    Apr 8, 2013
    Posts:
    16
    Is it still possible to write CustomEditor inspectors when the MonoBehaviour has an fiValue object in it? I have an Editor class to override the inspector, I really just want the fiValue for the serialization. Using EditorUtility.SetDirty, however, isn't serializing the fiValue. When I click on another object in the scene after modifying the fiValue in the inspector, and then go back to the object all of the values are still there except for the fiValue. It seems as though it's not being serialized properly. What can I do to keep using CustomEditors from Unity but use fiValues for the serialization?
     
  37. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    Yep - in general pretty much everything works except for delegates. If you post a specific code sample I can take a look at verify it is supported, or you can try out the trial.
     
  38. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    At the moment, please use intellisense; all of the inspector-specific annotations start with [Inspector*]; open up the type and read the doc-comment on top. This is currently a pretty painful UX so I plan on adding a section to the docs that goes through all of the attributes. Sorry about that! Let me know if you have any specific questions and I'd be happy to answer them.
     
  39. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    GUILayout is unfortunately not supported. I've tried a number of different approaches to making it work, but none of them have panned out :/. As a result, I've included the toolkit which is really easy to use (once you get your head around it).

    You *should* be able to use both vfw and FI at the same time; just not on the same MonoBehaviour at the same time, since they both use a custom editor. If vfw exposes its functionality as a property drawer, then Full Inspector will automatically use that property drawer (a property drawer to property editor binding system is automagically generated).
     
  40. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    This has been fixed, thank you. PM me if you want a build that corrects the issue. I'm currently out of town, but I expect to push 2.6.2 which includes the fix to the asset store Sunday or Monday.
     
  41. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    This should work. Can you send me some sample code that reproduces the issue? Thanks!
     
  42. brendan-vance

    brendan-vance

    Joined:
    Jan 16, 2014
    Posts:
    36
    I've started getting near-constant editor crashes, which the log indicates might possibly be related to full inspector's caching components. For example, this is one thing I now see in the log before the crash:

    Any thoughts?
     
  43. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    Ditto on the editor crashes. I'm using [ExecuteInEditMode] which I don't normally use, so I'm wondering if FI isn't playing well with this decorator.
     
  44. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    Unity is now crashing every 3 minutes or so. I disabled [ExecuteInEditMode] and the problem remains.
     
  45. truffle_shuffle

    truffle_shuffle

    Joined:
    Dec 30, 2014
    Posts:
    16
    If it helps, i've noticed that it mostly crashes right after I've saved a .cs script. I'm using Visual Studio Code (not sure that has anything to do with it.)
     
  46. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602

    I've PM'ed both of you the latest RC build. Can you test it out and see if the crashes persist? If you can find a way to reproduce the issue I'll definitely take a deep look into it.

    What version of Unity are you running? I've never seen a crash like this. I don't think VSCode should cause the issue, instead it is likely a bug in Unity's serializer.

    Can you also try executing the menu item "Full Inspector/Developer/Remove Metadata"? There is a fair amount of data in there, so maybe Unity corrupted something. Note that executing this menu item will clear out the saved foldout states.
     
  47. Duffer123

    Duffer123

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

    I've been looking for an easier way to input data in to various lists (inc inventory list) using the editor and then use buttons? to either save out as assets using serialisation or save to rows in a SimpleSQL table. How much will Full Inspector help with this?

    Also how easy would it be for me to implement this with Runtime Serialiser (fairly new to Asset Store) which serialises in to strings - ? That would be v handy as I llike to idea of serializing say GameObjects and Models and Texture2Ds in to strings that I can then store in text columns/rows in a SimpleSQL powered/ORM sqlite table/database..... (if you see what I mean...).

    Can someone help by spelling out how Full Inspector might help me achieve this?
     
    Last edited: Jul 6, 2015
  48. Duffer123

    Duffer123

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

    Also, is there any custom attribute to allow me to say fold a section of variables in or out under a label or something in the Inspector. I've reviewed the FI documentation and cant find it?

    How would I go about creating a button (and siting it where I want it) in the Inspector to say save out the List I am working on?

    [edit] Will this Asset make creating new Editor Windows as tools for development easier?

    How does this Asset work with classes and then scriptable object classes>? Can it change an ordinary class in to a scriptable object class or assist with sending scriptable objects - I am thinking of lists - to (become) new assets?

    Let's say I am creating a scriptable object item list based on an item class. I am thinking this will help with creating a nice Editor window to assist with completing data and development, but what else can it help with?
     
    Last edited: Jul 6, 2015
  49. brendan-vance

    brendan-vance

    Joined:
    Jan 16, 2014
    Posts:
    36
    I'm running 5.1.1f1 personal (and also using the 2013 VS Community plugin). The crash seems to happen on recompiling scripts (and indeed the crashes have decreased in frequency, which may correspond to my using the 'clear metadata' function).

    One weird thing I did that preceded the crash trouble involved changing a BaseBehaviour to a regular C# class without altering its name. Is it possible that could have mucked with FI's internal data structures?
     
  50. sient

    sient

    Joined:
    Aug 9, 2013
    Posts:
    602
    For the inspector portion, FI may end up making it much easier. You'll just need to add a call to PropertyEditor.Get(type, null).FirstEditor.EditWithGUILayout(...) inside of the EditorWindow. You should be able to test this out with the trial.

    For the Runtime Serializer, based on these API's it should definately be doable to write your own runtime serialization library. However, I'd strongly recommend going with Full Serializer - it's relatively mature and extremely flexible. It looks like Runtime Serializer is based on MiniJSON (I may be wrong though), which I evaluated for inclusion in FI but was not satisfied with.

    Keep in mind that the FI serialization stuff lives in MonoBehaviours and should not be exported elsewhere. If the Runtime Serializer's scene serializer is implemented properly, everything should just work, since FI uses the standard Unity serialization APIs.

    You can use [InspectorCategory], but that creates entirely separate categories (not foldouts) in the inspector. You can also create a custom tk editor to do something like this, which is pretty simple and maintainable (and significantly more flexible than attributes) once you wrap your head around it.

    Add [InspectorButton] to a method. You can then use [InspectorOrder] to customize exactly where the button is located in the inspector.

    Depends on what you mean. If the editor windows deal with editing object graphs, then yes. Otherwise maybe not - but there is a lot of utility code in FI that may come in handy.

    Essentially, BaseScriptableObject and BaseBehavior are just like ScriptableObject/MonoBehaviour, except that they can serialize everything and the inspector is better. I'm not sure what you mean by changing an ordinary class into a scriptable object class or the creating new assets from lists.

    Yes, that is one of the big features. In general, FI tries to make the inspector more productive, ie, it includes a backup system so when you're tweaking values during play-mode you can save them out and then restore them after play-mode.

    I think the biggest advantage to FI though is that you can use whatever you want on behaviors and have it "just work". Inheritance here is the biggest one, but also having generic types just work is nice to. So for example you can use UnityEvent<int> just fine, no need to create a UnityEventInt type.

    I'd strongly suggest downloading the trial. If you feel like that doesn't give you enough to test FI out before deciding if to purchase, send me an email.