Getting a NullReferenceException after implementing the LazyValue on the Fighter script.
The line is:
currentWeapon.value = weapon;
this is within the EquipWeapon method. Here is the stack trace:
NullReferenceException: Object reference not set to an instance of an object
RPG.Combat.Fighter.EquipWeapon (RPG.Combat.Weapon weapon) (at Assets/Scripts/Combat/Fighter.cs:63)
RPG.Combat.Fighter.RestoreState (System.Object state) (at Assets/Scripts/Combat/Fighter.cs:152)
RPG.Saving.SaveableEntity.RestoreState (System.Object state) (at Assets/Scripts/Saving/SaveableEntity.cs:33)
RPG.Saving.SavingSystem.RestoreState (System.Collections.Generic.Dictionary`2[TKey,TValue] state) (at Assets/Scripts/Saving/SavingSystem.cs:78)
RPG.Saving.SavingSystem+<LoadLastScene>d__0.MoveNext () (at Assets/Scripts/Saving/SavingSystem.cs:22)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
RPG.SceneManagement.SavingWrapper:Awake() (at Assets/Scripts/Scene Management/SavingWrapper.cs:15)
UnityEngine.Object:Instantiate(GameObject)
RPG.Core.PersistentObjectSpawner:SpawnPersistentObject() (at Assets/Scripts/Core/PersistentObjectSpawner.cs:22)
RPG.Core.PersistentObjectSpawner:Awake() (at Assets/Scripts/Core/PersistentObjectSpawner.cs:16)
Steps to reproduce:
- start the game
- save the game
- stop the game
- start the game (this will load from last save)
Not sure if I have to do some additional digging, or if this is doing this for everybody. If you would like more info, let me know. My repo is currently private, or I would link that as well.