- Home /
How to avoid a DataObject to be null so to be able to be taked by another script?
You see, for some reason, when i want to make a non-gameObject object (i.e. DataObject) in a script to be used outside of that script, the object "cease to exist", a good example of this is what the editor shows related to them:
Did you see that Tile slot in the Prefab Adapt script?, did you see than on that slot is shown like none Tile exist there? well, that happend to me every time i want to make a DataObject accesible through a public variable to be used from another script.
I like to take that Tile DataObject programatically from another script, did you know some way to make sure the script doesn't eliminate that DataObject so to be used from another script in the future?
Alternative answers or aproach to the problem would be also very apreciated.
Thanks in advance.
Does this happen if your Tile is private? If not, there are 2 things to try:
Add
[System.Serializable]
above the definition od your DataObject classOR make your Tile private, and create a public getter and setter methods so you can access it.