jacobdufault / fullinspector

Full Inspector supercharges Unity's inspector
MIT License
110 stars 27 forks source link

NullReferenceException with InspectorHideIf #165

Closed FodderMK closed 8 years ago

FodderMK commented 8 years ago

With FullInspector 2.6.4 (07-11-2016 at 1757) I was not able to use InspectorHideIf:

NullReferenceException: Object reference not set to an instance of an object
FullInspector.Internal.ReflectedPropertyEditor.ShouldShowMemberDynamic (System.Object element, System.Reflection.MemberInfo member) (at Assets/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:218)
FullInspector.Internal.ReflectedPropertyEditor.GetElementHeight (UnityEngine.GUIContent label, System.Object element, FullInspector.fiGraphMetadata metadata) (at Assets/FullInspector2/Core/Editor/PropertyEditors/ReflectedPropertyEditor.cs:401)
FullInspector.PropertyEditorExtensions.GetElementHeight[Object] (IPropertyEditor editor, UnityEngine.GUIContent label, UnityEngine.Object element, fiGraphMetadataChild metadata) (at Assets/FullInspector2/Core/Editor/IPropertyEditorExtensions.cs:256)
FullInspector.DefaultBehaviorEditor.OnGetHeight (UnityEngine.Object behavior, FullInspector.fiGraphMetadata metadata) (at Assets/FullInspector2/Core/Editor/DefaultBehaviorEditor.cs:47)
FullInspector.BehaviorEditor`1[TBehavior].GetHeight (UnityEngine.Object behavior) (at Assets/FullInspector2/Core/Editor/IBehaviorEditor.cs:112)
FullInspector.IBehaviorEditorExtensions.EditWithGUILayout[Object] (IBehaviorEditor editor, UnityEngine.Object element) (at Assets/FullInspector2/Core/Editor/IBehaviorEditorExtensions.cs:16)
FullInspector.FullInspectorCommonSerializedObjectEditor.ShowInspectorForSerializedObject (UnityEngine.Object[] targets) (at Assets/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:231)
FullInspector.FullInspectorCommonSerializedObjectEditor.OnInspectorGUI () (at Assets/FullInspector2/Core/Editor/FullInspectorCommonSerializedObjectEditor.cs:255)
UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean rebuildOptimizedGUIBlock, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1231)
UnityEditor.DockArea:OnGUI()

I suspect this is related to the fix done for issue #142. I was able to solve the problem by changing

    public sealed class InspectorHideIfAttribute : Attribute {
        public string ConditionalMemberName;

to

    public sealed class InspectorHideIfAttribute : Attribute {
        public string ConditionalMemberName {
            set { ConditionalMemberNames = new[] { value }; }
        }
jacobdufault commented 8 years ago

Done, thanks!