SolidAlloy / GenericScriptableArchitecture

ScriptableObject architecture with small, easy-to-expand codebase, and simple UI.
Other
116 stars 12 forks source link

NullReferenceException when creating a new variable #17

Open Mattias-TB opened 1 year ago

Mattias-TB commented 1 year ago

I am using Unity 2021.3.6f1 and have installed using the Package Manager:

image

I am getting a NullReferenceException when trying to create a new Variable of type Int, I can still create Events without problems.

NullReferenceException: Object reference not set to an instance of an object
GenericUnityObjects.Util.GenericTypesDatabase`1[TObject].TryGetConcreteTypeImpl (System.Type genericType, System.Type& concreteType) (at Library/PackageCache/com.solidalloy.generic-unity-objects@2.17.1/Runtime/Util/GenericTypesDatabase/GenericTypesDatabase.cs:115)
GenericUnityObjects.Util.GenericTypesDatabase`1[TObject].TryGetConcreteType (System.Type genericType, System.Type& concreteType) (at Library/PackageCache/com.solidalloy.generic-unity-objects@2.17.1/Runtime/Util/GenericTypesDatabase/GenericTypesDatabase.cs:94)
GenericUnityObjects.Editor.ScriptableObjects.GenericSOCreator.CreateAssetInteractively (System.Type genericTypeWithoutArgs, System.Type[] genericArgs, System.String fileName) (at Library/PackageCache/com.solidalloy.generic-unity-objects@2.17.1/Editor/ScriptableObjects/GenericSOCreator.cs:107)
GenericUnityObjects.Editor.ScriptableObjects.GenericSOCreator+<>c__DisplayClass5_0.<CreateAsset>b__0 (System.Type[] genericArgs) (at Library/PackageCache/com.solidalloy.generic-unity-objects@2.17.1/Editor/ScriptableObjects/GenericSOCreator.cs:35)
GenericUnityObjects.Editor.ScriptableObjects.SelectionWindow.OneTypeSelectionWindow+<>c__DisplayClass2_0.<GetDropdownTree>b__0 (System.Type type) (at Library/PackageCache/com.solidalloy.generic-unity-objects@2.17.1/Editor/ScriptableObjects/SelectionWindow/OneTypeSelectionWindow.cs:32)
UnityDropdown.Editor.DropdownMenu`1[T].FinalizeSelection () (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownMenu`1.cs:78)
UnityDropdown.Editor.DropdownNode.HandleMouseEvents () (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownNode.cs:170)
UnityDropdown.Editor.DropdownNode.Draw (System.Int32 indentLevel, UnityEngine.Rect visibleRect) (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownNode.cs:187)
UnityDropdown.Editor.DropdownNode.DrawSelfAndChildren (System.Int32 indentLevel, UnityEngine.Rect visibleRect) (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownNode.cs:102)
UnityDropdown.Editor.DropdownNode.DrawSelfAndChildren (System.Int32 indentLevel, UnityEngine.Rect visibleRect) (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownNode.cs:108)
UnityDropdown.Editor.DropdownMenu.DrawTree (UnityEngine.Rect visibleRect) (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownMenu.cs:192)
UnityDropdown.Editor.DropdownMenu.Draw () (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownMenu.cs:108)
UnityDropdown.Editor.DropdownWindow.DrawContent () (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownWindow.cs:105)
UnityDropdown.Editor.DropdownWindow.OnGUI () (at Library/PackageCache/com.solidalloy.unity-dropdown@1.2.0/Editor/DropdownWindow.cs:63)
UnityEditor.HostView.OldOnGUI () (at <44a70d1b13cf47e29810e30f45ffae08>: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 <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatchUtilities.PropagateEvent (UnityEngine.UIElements.EventBase evt) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToRegularTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.SendEventToTarget (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.MouseEventDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel iPanel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <7096c6494db14f0c807ca461735e58a8>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <89d2c0fe37e0454991daf2807b7dcb63>:0)
Mattias-TB commented 1 year ago

I was going to try to reproduce this in a fresh project and I noticed that the only difference was that in the fresh project, the Scripting Backend was set to Mono and API Compatibility Level was set to .NET Standard 2.1. I switched to .NET Framework and tried creating a new variable. which worked right away. I then switched to IL2CPP and that also worked.

In the project from the first post in this issue, the Scripting Backend is set to IL2CPP (since I am building for Android), after switching to Mono, creating a variable and then switching backl to IL2CPP, the error is gone and I can create variables.

sima995 commented 1 year ago

Hi! Can you hit me up on discord? I'm facing a similar problem. s_marcell#6643