Object reference not set to an instance of an object
Posted: Mon Jul 15, 2019 1:11 am
Hi! So i'm having trouble with the saving and loading function and I hate to admit this but as i'm only a hopeful up and coming comp programmer, i need to ask for some help.
So in one of my my scripts, I have a function called saveTheGame. This script contains statements such as "ES2.Save(_BaseStats.playerHealth, "playerHP");", "ES2.Save(_BaseStats.currentLevel, "currentLevel");", and "ES2.Save(_BaseStats.currentEnemyWeapon, "currentEnemyWeapon");", etc.
In that same script I have a function named continueGame. This script contains statements such as "_BaseStats.playerHealth = ES2.Load <int>("playerHP");" and "_BaseStats.currentLevel = ES2.Load<string>("currentLevel");", etc.
I understand why things would be null when I havent yet used them but I initialize them with a value even if the value is equivalent to zero it isn't null, so like I dont understand...
I have no code checking to make sure the value has been initialized although I have a script named _BaseStats with all values initialized to their default value and I can see no reason why the variables could return a nullPointerException so that isn't the error. I created an empty GameObject and attached the _BaseStats script to it and then attached that same GameObject to the Easy Save 3 Manager GameObject but it's still giving me the error, "NullReferenceException: Object reference not set to an instance of an object ES3Settings.GetDefaultSettings () (at Assets/Plugins/Easy Save 3/Scripts/Settings/ES3Settings.cs:219)" as well as the error, "Could not find ES3 Default Settings object in Easy Save 3/Resources/ES3.UnityEngine.Debug:LogError(Object)".
I won't argue against being dumb because I just don't understand that. Any tips/guidance?
I am unfamiliar with asking for help in general so if there is something more that you need in order to assist me, I can supply whatever I have not already.
~ashenAlex
So in one of my my scripts, I have a function called saveTheGame. This script contains statements such as "ES2.Save(_BaseStats.playerHealth, "playerHP");", "ES2.Save(_BaseStats.currentLevel, "currentLevel");", and "ES2.Save(_BaseStats.currentEnemyWeapon, "currentEnemyWeapon");", etc.
In that same script I have a function named continueGame. This script contains statements such as "_BaseStats.playerHealth = ES2.Load <int>("playerHP");" and "_BaseStats.currentLevel = ES2.Load<string>("currentLevel");", etc.
I understand why things would be null when I havent yet used them but I initialize them with a value even if the value is equivalent to zero it isn't null, so like I dont understand...
I have no code checking to make sure the value has been initialized although I have a script named _BaseStats with all values initialized to their default value and I can see no reason why the variables could return a nullPointerException so that isn't the error. I created an empty GameObject and attached the _BaseStats script to it and then attached that same GameObject to the Easy Save 3 Manager GameObject but it's still giving me the error, "NullReferenceException: Object reference not set to an instance of an object ES3Settings.GetDefaultSettings () (at Assets/Plugins/Easy Save 3/Scripts/Settings/ES3Settings.cs:219)" as well as the error, "Could not find ES3 Default Settings object in Easy Save 3/Resources/ES3.UnityEngine.Debug:LogError(Object)".
I won't argue against being dumb because I just don't understand that. Any tips/guidance?
I am unfamiliar with asking for help in general so if there is something more that you need in order to assist me, I can supply whatever I have not already.
~ashenAlex