- Home /
Problem displaying an int
Hey, I've just been following BurgZergArcade's tutorials and I seem to have made a typo causing an "Object reference not set to an instance of an object" error to be printed many times a second and I cant for the life of me find where I've gone wrong (I've spent the last hour going over the videos again but to no avail.) Could someone please point out where I've gone wrong? I'll be extremely grateful.
GUI display code for the integer:
private void DisplaySkills(){
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++) {
GUI.Label(new Rect(250, 50 + (cnt * 25), 100, 25), ((SkillName)cnt).ToString());
GUI.Label(new Rect(355, 50 + (cnt * 25), 30, 25), _toon.GetSkill(cnt).AdjustedBaseValue.ToString());
}
}
And the script for setting up the skills:
public class Skill : ModifiedStat {
private bool _known;
public Skill(){
_known = false;
ExpToLevel = 25;
LevelModifier = 1.1f;
}
public bool Known {
get{ return _known;}
set{ _known = value; }
}
}
public enum SkillName{
Melee_Offence,
Melee_Defense,
Ranged_Offence,
Ranged_Defense,
Magic_Offence,
Magic_Defense
}
Many thanks.
EDIT: The scripts for the vital stats and attributes work fine.
Where does the error occur? You should be able to double click the message in the console and have it take you to the specific line.
Oh, sorry, if forgot to put that: line 60 or rather the second GUI.Label in the top code, I have the same code (but with 'SkillName' & 'GetSkill' replaced with relevant variable) for attributes and vitals and they work fine.
Answer by venhip · Nov 25, 2012 at 04:15 PM
After playing around for a little while I have found out what is wrong, or at least what is causing the errors. I'll close this question and open another with an appropriate heading.