keeps crash OdinAttributeProcessor when using generic type "object"
Issue #836
closed
keeps crash OdinAttributeProcessor when using generic type "object"
I added OdinAttributeProcessor
on base class to useValueDropdownAttribute
automatically
it works find with “int”, “string” “etc…”, but when i use “object” it keeps crash
sample code for reproduce
public class ItemBase<T0> : ScriptableObject {
public ItemBase<T0>[] GetScriptableObjects() {
return Resources.LoadAll<ItemBase<T0>>("");
}
public class PropertyProcessorItemBase : OdinAttributeProcessor<ItemBase<T0>> {
public override void ProcessSelfAttributes(InspectorProperty property, List<Attribute> attributes) {
ValueDropdownAttribute valueDropdownAttribute = new ValueDropdownAttribute($"@{property.Name}.GetScriptableObjects()");
attributes.Add(valueDropdownAttribute);
}
}
}
public class IntItem : ItemBase<int> {
}
public class ObjectItem : ItemBase<object> {
}
public class PlayerA : MonoBehaviour {
[SerializeField] private ItemBase<int> item;
}
public class PlayerB : MonoBehaviour {
[SerializeField] private ItemBase<object> item;
}
PlayerA “ItemBase<int>” works fine
PlayerB “ItemBase<object>” always keep crash
Unity version : 2020.3.27.f1
Odin version : 3.0.9.0
Unity Crash Stacktrace
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) [0x00016] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00038] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.Reflection.MethodBase.Invoke (object,object[]) [0x00006] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.Delegate.DynamicInvokeImpl (object[]) [0x000e9] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.MulticastDelegate.DynamicInvokeImpl (object[]) [0x0000a] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.Delegate.DynamicInvoke (object[]) [0x00002] in <695d1cc93cca45069c528c15c9fdd749>:0
at Sirenix.OdinInspector.Editor.ValueResolvers.ExpressionValueResolverCreator/<>c__DisplayClass2_0`1<TResult_REF>.<GetExpressionLambda>b__0 (Sirenix.OdinInspector.Editor.ValueResolvers.ValueResolverContext&,int) [0x00041] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\ValueResolvers\ExpressionValueResolverCreator.cs:96
at Sirenix.OdinInspector.Editor.ValueResolvers.ValueResolver`1<TResult_REF>.GetValue (int) [0x00039] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\ValueResolvers\ValueResolver.cs:313
at Sirenix.OdinInspector.Editor.Drawers.ValueDropdownAttributeDrawer.ReloadDropdownCollections () [0x0000b] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\Attribute Drawers\ValueDropdownAttributeDrawer.cs:95
at Sirenix.OdinInspector.Editor.Drawers.ValueDropdownAttributeDrawer.Initialize () [0x000ae] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\Attribute Drawers\ValueDropdownAttributeDrawer.cs:84
at Sirenix.OdinInspector.Editor.OdinDrawer.Initialize (Sirenix.OdinInspector.Editor.InspectorProperty) [0x00010] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinDrawer.cs:86
at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain (bool&) [0x00057] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:560
at Sirenix.OdinInspector.Editor.InspectorProperty.GetActiveDrawerChain () [0x00000] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:540
at Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent) [0x00012] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:713
at Sirenix.OdinInspector.Editor.InspectorProperty.Draw () [0x00000] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:696
at Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1<T_REF>.DrawPropertyLayout (UnityEngine.GUIContent) [0x0015a] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\Value Drawers\UnityObjectRootDrawer.cs:60
at Sirenix.OdinInspector.Editor.OdinDrawer.CallNextDrawer (UnityEngine.GUIContent) [0x00020] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinDrawer.cs:155
at Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1<T_REF>.DrawPropertyLayout (UnityEngine.GUIContent) [0x0001c] in C:\Workspace\Unity\Health\Assets\Project\External\Sirenix\Odin Inspector\Scripts\Editor\FixBrokenUnityObjectWrapperDrawer.cs:41
at Sirenix.OdinInspector.Editor.OdinDrawer.DrawProperty (UnityEngine.GUIContent) [0x00013] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinDrawer.cs:109
at Sirenix.OdinInspector.Editor.InspectorProperty.Draw (UnityEngine.GUIContent) [0x002c3] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\InspectorProperty.cs:808
at Sirenix.OdinInspector.Editor.PropertyTree.DrawProperties () [0x00019] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\PropertyTree.cs:499
at Sirenix.OdinInspector.Editor.PropertyTree.Draw (bool) [0x00007] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Core\PropertyTree.cs:388
at Sirenix.OdinInspector.Editor.OdinEditor.DrawTree () [0x00000] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:93
at Sirenix.OdinInspector.Editor.OdinEditor.DrawOdinInspector () [0x000ad] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:216
at Sirenix.OdinInspector.Editor.OdinEditor.OnInspectorGUI () [0x00000] in Y:\Repositories\sirenix-development-framework\Sirenix Solution\Sirenix.OdinInspector.Editor\Drawers\OdinEditor.cs:85
at UnityEditor.UIElements.InspectorElement/<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () [0x00296] in <bc087a59f3c04c9aad8fcd92325a4a28>:0
at UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool) [0x001e1] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.IMGUIContainer.DoMeasure (single,UnityEngine.UIElements.VisualElement/MeasureMode,single,UnityEngine.UIElements.VisualElement/MeasureMode) [0x00082] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.VisualElement.Measure (UnityEngine.Yoga.YogaNode,single,UnityEngine.Yoga.YogaMeasureMode,single,UnityEngine.Yoga.YogaMeasureMode) [0x0001c] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.VisualElement.<AssignMeasureFunction>b__202_0 (UnityEngine.Yoga.YogaNode,single,UnityEngine.Yoga.YogaMeasureMode,single,UnityEngine.Yoga.YogaMeasureMode) [0x00008] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at (wrapper delegate-invoke) <Module>.invoke_YogaSize_YogaNode_single_YogaMeasureMode_single_YogaMeasureMode (UnityEngine.Yoga.YogaNode,single,UnityEngine.Yoga.YogaMeasureMode,single,UnityEngine.Yoga.YogaMeasureMode) [0x0004d] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at UnityEngine.Yoga.YogaNode.MeasureInternal (UnityEngine.Yoga.YogaNode,single,UnityEngine.Yoga.YogaMeasureMode,single,UnityEngine.Yoga.YogaMeasureMode) [0x0002c] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at UnityEngine.Yoga.Native.YGNodeMeasureInvoke (UnityEngine.Yoga.YogaNode,single,UnityEngine.Yoga.YogaMeasureMode,single,UnityEngine.Yoga.YogaMeasureMode,intptr) [0x0000e] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object_single_int_single_int_intptr (object,intptr,intptr,intptr) [0x0003f] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at <unknown> <0xffffffff>
at (wrapper managed-to-native) UnityEngine.Yoga.Native.YGNodeCalculateLayout (intptr,single,single,UnityEngine.Yoga.YogaDirection) [0x0000a] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at UnityEngine.Yoga.YogaNode.CalculateLayout (single,single) [0x00014] in <7eecafb74d3e4341bc9f1f23fe7d280c>:0
at UnityEngine.UIElements.UIRLayoutUpdater.Update () [0x0003f] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase) [0x0001f] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.Panel.UpdateForRepaint () [0x00022] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event) [0x00099] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel) [0x00029] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&) [0x0003f] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.UIEventRegistration.ProcessEvent (int,intptr) [0x0001f] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.UIElements.UIEventRegistration/<>c.<.cctor>b__1_2 (int,intptr) [0x00003] in <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0
at UnityEngine.GUIUtility.ProcessEvent (int,intptr,bool&) [0x00018] in <fae907a62101488197452acea0d84e82>:0
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr) [0x0002d] in <fae907a62101488197452acea0d84e82>:0
Comments (3)
-
-
reporter Thank you very much
problem solved!!
would you tell me why “object” type must use static method?
-
- changed status to closed
- Log in to comment
Make your GetScriptableObjects method static and change the ValueDropdown’s expression to: `$"@ItemBase<{typeof(T0)}>.GetScriptableObjects()"`.
Let me know if that helped