public class WallProperties : MonoBehaviour
{
public Door door;
public bool IsDoor(bool enable) //enable=true
{
if(enable)
{
print (enable); //prints true
door=new Door();
door.DoorStart(); //sets values to default
print(door.GetStyle ()); //prints current value
print ((door==null)?"True":"False"); //prints true
}
return(door==null); //returns true
}
...
}
- I am trying to have the 'door' variable not NULL
- The mono class is not attached to anything
- It gave me lip when the "new Door()" was removed
- With the "new Door()" I am able to access the Door class
However, the variable ‘door’ stays NULL. Is there a way that the ‘door’ variable can be declared and not be NULL or should I just have a boolean class variable for the door?
If door is derived from Monobehavior, then it will need to be attached to a game object...either one you create dynamically or one you create in the editor. Then you will use GetComponent() on the game object with the script to initialize 'door', or you can use drag and drop in the inspector.
– robertbuI,m curious.... how is door equals NULL and is not crashing here? door.DoorStart(); //sets values to default print(door.GetStyle ()); //prints current value
– jovino