C
C#3w 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
TheRanger3w ago
can u show a screenshot of where it says its null?
Demite
DemiteOP3w ago
Sure. Here is in Visual Studios on watch
No description
TheRanger
TheRanger3w ago
ur breakpointing before the object is getting initialized altho the object does look initialized to me, its not null
Demite
DemiteOP3w ago
I step through it but I figured it out. I had monobehaviour on it when I didn't want it to be.
TheRanger
TheRanger3w ago
Oh, Unity?
Demite
DemiteOP3w ago
yea. Probably should have said that.
Harbour
Harbour3w 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
TheRanger3w ago
$close
MODiX
MODiX3w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?