Deadcows / MyBox

MyBox is a set of attributes, tools and extensions for Unity
http://deadcow.ru
MIT License
1.94k stars 244 forks source link

Issue when wanting to "Display Inspector" on a CollectionWrapper of my ScriptableObject. #164

Closed DonTomasDeLaVega closed 3 years ago

DonTomasDeLaVega commented 3 years ago

Here is the issue: type is not a supported pptr value UnityEditor.SerializedProperty:get_objectReferenceValue () MyBox.Internal.DisplayInspectorAttributeDrawer:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent) (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Attributes/DisplayInspectorAttribute.cs:54) MyBox.Internal.ConditionalFieldAttributeDrawer:<OnGUI>g__TryUseAttributeDrawer|6_0 (MyBox.Internal.ConditionalFieldAttributeDrawer/<>c__DisplayClass6_0&) (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Attributes/ConditionalFieldAttribute.cs:83) MyBox.Internal.ConditionalFieldAttributeDrawer:OnGUI (UnityEngine.Rect,UnityEditor.SerializedProperty,UnityEngine.GUIContent) (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Attributes/ConditionalFieldAttribute.cs:74) UnityEditor.EditorGUILayout:PropertyField (UnityEditor.SerializedProperty,bool,UnityEngine.GUILayoutOption[]) MyBox.Internal.FoldoutAttributeHandler:Body () (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Attributes/FoldoutAttribute.cs:113) MyBox.Internal.FoldoutAttributeHandler:OnInspectorGUI () (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Attributes/FoldoutAttribute.cs:83) MyBox.Internal.UnityObjectEditor:OnInspectorGUI () (at Library/PackageCache/com.domybest.mybox@725b8fb2ca/Tools/Internal/UnityObjectEditor.cs:34) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) It doesn't seem to like it one bit ^^' I can do without, but i'd like to do with it ^^' Here's my code: image [...] image And when i add, after the conditionnal field, a displayInspector attribute, unity loses its mind

Deadcows commented 3 years ago

Very interesting feature you want here! The problem actually is not in ConditionalField. DisplayInspector is made to work with SO or MB field, and CollectionWrapper is not one of those. I'm not sure it'll be possible to make it to work.

Try to use Foldout instead of Conditional! I just reworked it's visual yesterday, it looks neat 🤓

[Foldout("Leaf Creation"), DisplayInspector]
public BookContext[] Contexts;
[Foldout("Leaf Creation"), DisplayInspector]
public Item[] Items;

image

Ability to use DisplayInspector with collection along with ConditionalField looks nice, I will add it to my to-do, but I'd wouldn't expect it any soon 🙄

btw sorry for the late responce! Abandoned MyBox for a few months with all the crunches with my game 🤯

Deadcows commented 3 years ago

But I fixed this error spamming! DisplayInspector now will show warning if used on property of the wrong type

image