0

2.0.0a10 NullReferenceException - when trying to set singleton variables or invoke singleton events from component classes

TowerCrow 6 days ago updated 4 days ago 2

After fixing type inference most of my Inventory project errors have disappeared but here are a few new ones when trying to run the game in Generated mode:

NullReferenceException: Object reference not set to an instance of an object
Ludiq.Bolt.GeneratedClass`1[TShell].BindVariable[T] (System.String guid) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedClass.cs:34)
Ludiq.Bolt.Generated.InventoryManager.Bind () (at Assets/Ludiq.Generated/Transient/Scripts/InventoryManager.cs:54)
Ludiq.Bolt.BoltClassShellTrait.InstantiateGenerated (System.Func`2[T,TResult] instantiator) (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:395)
Ludiq.Bolt.BoltClassShellTrait.InitializeGenerated[T] () (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:387)
Ludiq.Bolt.GeneratedComponentHolderProtocol+Protocol.AddComponent[T] (UnityEngine.Object uo) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedComponentHolderProtocol.cs:28)
Ludiq.Bolt.GeneratedComponentHolderProtocol.AddGeneratedComponent[T] (UnityEngine.Object uo) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedComponentHolderProtocol.cs:37)
Ludiq.Bolt.BoltSingletonContainer.GetInstance[T] () (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltSingletonContainer.cs:39)
Ludiq.Bolt.GeneratedSingletonComponent`1[T].get_Instance () (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedSingletonComponent.cs:11)
Ludiq.Bolt.Generated.EquipmentPanel.Start () (at Assets/Ludiq.Generated/Transient/Scripts/EquipmentPanel.cs:250)
Ludiq.Bolt.Generated.EquipmentPanel.b__24_0 (Ludiq.Bolt.EmptyEventArgs args) (at Assets/Ludiq.Generated/Transient/Scripts/EquipmentPanel.cs:77)
Ludiq.Bolt.EventBus.Invoke[TArgs] (Ludiq.Bolt.EventHook hook, TArgs args) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:153)
UnityEngine.Debug:LogException(Exception, Object)
Ludiq.Bolt.EventBus:Invoke(EventHook, EmptyEventArgs) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:157)
Ludiq.Bolt.BoltClassShellTrait:InvokeEvent(EventHookID) (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:870)
Ludiq.Bolt.BoltUnityClassShellTrait:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltUnityClassShellTrait.cs:30)
Ludiq.Bolt.BoltComponent:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltComponent.cs:121)

NullReferenceException: Object reference not set to an instance of an object
Ludiq.Bolt.Generated.ItemSlot.RefreshSlot () (at Assets/Ludiq.Generated/Transient/Scripts/ItemSlot.cs:140)
Ludiq.Bolt.Generated.Inventory.RefreshUI () (at Assets/Ludiq.Generated/Transient/Scripts/Inventory.cs:213)
Ludiq.Bolt.Generated.Inventory.Start () (at Assets/Ludiq.Generated/Transient/Scripts/Inventory.cs:219)
Ludiq.Bolt.Generated.Inventory.b__18_0 (Ludiq.Bolt.EmptyEventArgs args) (at Assets/Ludiq.Generated/Transient/Scripts/Inventory.cs:71)
Ludiq.Bolt.EventBus.Invoke[TArgs] (Ludiq.Bolt.EventHook hook, TArgs args) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:153)
UnityEngine.Debug:LogException(Exception, Object)
Ludiq.Bolt.EventBus:Invoke(EventHook, EmptyEventArgs) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:157)
Ludiq.Bolt.BoltClassShellTrait:InvokeEvent(EventHookID) (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:870)
Ludiq.Bolt.BoltUnityClassShellTrait:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltUnityClassShellTrait.cs:30)
Ludiq.Bolt.BoltComponent:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltComponent.cs:121)

TargetException: Missing target object for 'Ludiq.Bolt.Generated.item'.
Ludiq.OptimizedReflection.VerifyTarget (System.Type targetType, System.Object target, System.Boolean static) (at Assets/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/OptimizedReflection.cs:87)
Ludiq.OptimizedReflection.VerifyInstanceTarget[TTArget] (System.Object target) (at Assets/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/OptimizedReflection.cs:69)
Ludiq.InstancePropertyAccessor`2[TTarget,TProperty].GetValue (System.Object target) (at Assets/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/InstancePropertyAccessor.cs:78)
Ludiq.OptimizedReflection.GetValueOptimized (System.Reflection.PropertyInfo propertyInfo, System.Object target) (at Assets/Ludiq/Ludiq.Core/Runtime/Reflection/Optimization/OptimizedReflection.cs:200)
Ludiq.MemberAccessor.get_rawValue () (at Assets/Ludiq/Ludiq.Core/Editor/Meta/MemberAccessor.cs:44)
Ludiq.Accessor.get_instantiatedValue () (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:247)
Ludiq.Accessor.get_rawValueType () (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:404)
Ludiq.Accessor.get_valueType () (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:418)
Ludiq.Accessor.AnalyzeCollection () (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:438)
Ludiq.Accessor.Dig[TSubpath,TAccessor] (TSubpath subpath, System.Func`2[T,TResult] constructor, System.Boolean createInPrefab, Ludiq.Accessor prefabInstance) (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:617)
Ludiq.Accessor.Member (System.String name, System.Reflection.BindingFlags bindingFlags) (at Assets/Ludiq/Ludiq.Core/Editor/Meta/Accessor.cs:1360)
Ludiq.ReflectedEditor.GetMemberAccessor (System.String memberName) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Special/ReflectedEditor.cs:41)
Ludiq.ReflectedEditor.b__10_0 (System.String name) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Special/ReflectedEditor.cs:36)
System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].MoveNext () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
Ludiq.ReflectedEditor.GetInnerHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Special/ReflectedEditor.cs:89)
Ludiq.Editor.GetControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Editor.cs:139)
Ludiq.Inspector.GetFieldHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:237)
Ludiq.Inspector.FieldHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:380)
Ludiq.ReflectedEditor.GetMemberHeight (Ludiq.Inspector memberInspector, System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Special/ReflectedEditor.cs:191)
Ludiq.ReflectedEditor.GetInnerHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Special/ReflectedEditor.cs:96)
Ludiq.Editor.GetControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Editor.cs:139)
Ludiq.Inspector.ControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:339)
Ludiq.Bolt.BoltClassShellTraitEditor.GetInnerHeight (System.Single width) (at Assets/Ludiq/Bolt.Core/Editor/Architecture/BoltClassShellTraitEditor.cs:227)
Ludiq.Editor.GetControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Editor.cs:139)
Ludiq.Inspector.ControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:339)
Ludiq.Bolt.BoltClassShellEditor.GetInnerHeight (System.Single width) (at Assets/Ludiq/Bolt.Core/Editor/Architecture/BoltClassShellEditor.cs:24)
Ludiq.Editor.GetControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Editor.cs:130)
Ludiq.Inspector.ControlHeight (System.Single width) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:339)
Ludiq.Inspector.GetLayoutPosition (System.Func`2[T,TResult] getHeight, System.Single scrollbarTrigger) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:834)
Ludiq.Inspector.GetControlLayoutPosition (System.Single scrollbarTrigger) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:853)
Ludiq.Inspector.DrawControlLayout (System.Single scrollbarTrigger) (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Inspector.cs:858)
Ludiq.LudiqRootObjectEditor+Persistent.OnGUI () (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/Root/LudiqRootObjectEditor.cs:48)
Ludiq.PersistentRootEditorWrapper.OnInspectorGUI () (at Assets/Ludiq/Ludiq.Core/Editor/Inspection/PersistentRootEditorWrapper.cs:33)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass55_0.b__0 () (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Bolt Version:
2.0.0a10
Unity Version:
2019.3.4f1
Platform(s):
PC
Scripting Backend:
Mono
.NET Version (API Compatibility Level):
.NET 4.x
Bolt 2

The null Reference error comes from component class trying to set itself as a singleton variable.

NullReferenceException: Object reference not set to an instance of an object
Ludiq.Bolt.GeneratedClass`1[TShell].BindVariable[T] (System.String guid) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedClass.cs:34)
Ludiq.Bolt.Generated.Singleton.Bind () (at Assets/Ludiq.Generated/Transient/Scripts/Singleton.cs:43)
Ludiq.Bolt.BoltClassShellTrait.InstantiateGenerated (System.Func`2[T,TResult] instantiator) (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:395)
Ludiq.Bolt.BoltClassShellTrait.InitializeGenerated[T] () (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:387)
Ludiq.Bolt.GeneratedComponentHolderProtocol+Protocol.AddComponent[T] (UnityEngine.Object uo) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedComponentHolderProtocol.cs:28)
Ludiq.Bolt.GeneratedComponentHolderProtocol.AddGeneratedComponent[T] (UnityEngine.Object uo) (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedComponentHolderProtocol.cs:37)
Ludiq.Bolt.BoltSingletonContainer.GetInstance[T] () (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltSingletonContainer.cs:39)
Ludiq.Bolt.GeneratedSingletonComponent`1[T].get_Instance () (at Assets/Ludiq/Bolt.Core/Runtime/Generation/GeneratedSingletonComponent.cs:11)
Ludiq.Bolt.Generated.TestClassTwo.Start () (at Assets/Ludiq.Generated/Transient/Scripts/TestClassTwo.cs:153)
Ludiq.Bolt.Generated.TestClassTwo.<activateimplementation>b__20_0 (Ludiq.Bolt.EmptyEventArgs args) (at Assets/Ludiq.Generated/Transient/Scripts/TestClassTwo.cs:69)
Ludiq.Bolt.EventBus.Invoke[TArgs] (Ludiq.Bolt.EventHook hook, TArgs args) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:153)
UnityEngine.Debug:LogException(Exception, Object)
Ludiq.Bolt.EventBus:Invoke(EventHook, EmptyEventArgs) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:157)
Ludiq.Bolt.BoltClassShellTrait:InvokeEvent(EventHookID) (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltClassShellTrait.cs:870)
Ludiq.Bolt.BoltUnityClassShellTrait:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltUnityClassShellTrait.cs:30)
Ludiq.Bolt.BoltComponent:Start() (at Assets/Ludiq/Bolt.Core/Runtime/Architecture/BoltComponent.cs:121)
</activateimplementation>

 Another error from trying to invoke a singleton class event from a component class.

NullReferenceException: Object reference not set to an instance of an object
Ludiq.Bolt.Generated.ItemSlot.OnPointerClick (UnityEngine.EventSystems.PointerEventData onPointerClick) (at Assets/Ludiq.Generated/Transient/Scripts/ItemSlot.cs:156)
Ludiq.Bolt.EventBus.Invoke[TArgs] (Ludiq.Bolt.EventHook hook, TArgs args) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:153)
UnityEngine.Debug:LogException(Exception, Object)
Ludiq.Bolt.EventBus:Invoke(EventHook, PointerEventData) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:157)
Ludiq.Bolt.EventBus:Invoke(EventHookID, GameObject, PointerEventData) (at Assets/Ludiq/Bolt.Core/Runtime/Events/EventBus.cs:169)
Ludiq.Bolt.PointerEventProxy:OnPointerClick(PointerEventData) (at Assets/Ludiq/Bolt.Core/Runtime/Events/Proxies/PointerEventProxy.cs:37)
UnityEngine.EventSystems.EventSystem:Update() (at C:/GameDev/UnityEngine/2019.3.4f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)