Question by
Alanuski · Jun 25, 2017 at 05:21 PM ·
c#errorenumerror-message
C# missingReferenceException when comparing enums
We have a room that is destroyed and then we come back, reinstantiate the room, everything it's okay but then the if doesn't work.
We also inspect the cell variable and give us "null" value, but it's not true and the inspect says:
runInEditMode UnityEngine.MissingReferenceException: The object of type 'FloorController' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object. System.Boolean
The code lines that give some problems.
- Here the enum:
public enum GroundType {
door,wall,floor
}
- Here the fail if (it works fine when the room is new, but not when the room is re-created):
Cell cell = (Cell)GameController.sharedInstance.currentRoom.cells[position];
if (cell != null && celda.groundType != GroundType.wall){
doSomething();
}
- Here the error:
cell.groundType!= GroundType.wall Nodo no compatible: 'cell.groundType != GroundType.wall'
Comment
Your answer
Follow this Question
Related Questions
A namespace cannot directly contain mambers such as fields or methods... 2 Answers
how to save time and take the next variable in enum? 1 Answer
error CS0118 'charanim.CameraTurn' is a field but a 'type' was 'expected' 1 Answer
I Have an C# error and I can't fix it @username 1 Answer
Error stage @username 1 Answer