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

Conditional ConditionalField nolonger works with TextArea(1, 3) #72

Closed android272 closed 4 years ago

android272 commented 4 years ago

Not sure what happened but this was working not too long ago. I have a bool flag that I am using to hide two strings with the TextArea attributes on them. If I remove the textArea the conditionalField works as normal. All my other conditionalFields are working as expected.

Here is a sample of the fields I am using.

[SerializeField]
private bool showStr;
[
    SerializeField,
    ConditionalField(nameof(logQuest)),
    TextArea(1, 3),
    Tooltip("Tooltip")
]
private string str;

Here is the error I am getting.


UnityEditor.TextAreaDrawer.GetPropertyHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <ffcf2f9855fe46038192299154f37a45>:0)
MyBox.Internal.ConditionalFieldAttributeDrawer.GetPropertyHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/com.mybox@ba840da295/Attributes/ConditionalFieldAttribute.cs:110)
UnityEditor.PropertyDrawer.GetPropertyHeightSafe (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.PropertyHandler.GetHeight (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <ffcf2f9855fe46038192299154f37a45>:0)
XNodeEditor.NodeEditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, XNode.NodePort port, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditorGUILayout.cs:40)
XNodeEditor.NodeEditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditorGUILayout.cs:27)
XNodeEditor.NodeEditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditorGUILayout.cs:19)
XNodeEditor.NodeEditor.OnBodyGUI () (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditor.cs:57)
XNodeEditor.NodeEditorWindow.DrawNodes () (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditorGUI.cs:471)
XNodeEditor.NodeEditorWindow.OnGUI () (at Library/PackageCache/com.github.siccity.xnode@a1cf78d3fb/Scripts/Editor/NodeEditorGUI.cs:30)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEditor.DockArea.OldOnGUI () (at <ffcf2f9855fe46038192299154f37a45>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <35bab3c7b0dc4999845bcfccc7758d96>:0)```
android272 commented 4 years ago

Looks like this used to work back in

commit: 06aac8cc6ec47248002697e2ac2e0e3d6b1dc0a5 First iteration of AttributeBase that allows to use multiple attribut…

Deadcows commented 4 years ago

Apparently this issue were present before but it linked with attributes order and some... other things. ConditionalFieldAttribute is a mess 😰 I'm working on a better and complex solution to change the way all attributes works with each other in MyBox.

Anyways. It should be fixed now with the latest commit Please let me know if it helped.. or not helped 🤨