C
C#3mo ago
Demite

✅ Object is null after initializing

Hello, I have a object I make WorldRegions region = new WorldRegions(i, 1) { RegionStartTile = startTile, Width = randomXSize, Height = randomYSize }; Yes this object is null when referenced, and null when in watch in debug. I'm not sure why anyone able to explain what is happening?
9 Replies
TheRanger
TheRanger3mo ago
can u show a screenshot of where it says its null?
Demite
DemiteOP3mo ago
Sure. Here is in Visual Studios on watch
No description
TheRanger
TheRanger3mo ago
ur breakpointing before the object is getting initialized altho the object does look initialized to me, its not null
Demite
DemiteOP3mo ago
I step through it but I figured it out. I had monobehaviour on it when I didn't want it to be.
TheRanger
TheRanger3mo ago
Oh, Unity?
Demite
DemiteOP3mo ago
yea. Probably should have said that.
Harbour
Harbour3mo ago
Is WorldRegion your own class? Also it’s “null” not null which would indicate something is setting its value to that elsewhere - I suspect it’s something in the class
TheRanger
TheRanger2mo ago
$close
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?