Unity2D C# How to pass TileBase value from one class to another

Viewed 19

I’m trying to use the .setTile function dynamically and am trying to get the value of a selected Tile from another class, but I keep getting an error saying I’m not referencing an object even when the selectedTile is added to the inspector. Thank you!

Class 1:

Class2 class2 = new Class2();
.SetTile(pos, class2.getSelected());

Class 2:

Public TileBase selectedTile

Public TileBase GetSelected() {
    Return selectedTile
}
0 Answers
Related