- Home /
How to reference a tilemap component from script
I'm trying to write a script that changes the color of the the entire tilemap, but when I try to reference the tilemap component in the way shows below, I get an error saying "The type or namespace Tilemap could not be found". There aren't any typos, I have attached a tilemap component and this method of referencing components has worked for every other component I've ever referenced in a script. Why isn't this working?
Tilemap tm;
// Start is called before the first frame update
void Start()
{
tm = GetComponent<Tilemap>();
}
Answer by PastaMan64 · May 03 at 01:00 PM
Ok so turns out all I needed was to put Using UnityEngine.Tilemaps;
at the top. Even if I ended up finding the answer myself, I'll leave this question here for anyone else who runs into the same problem
Your answer
Follow this Question
Related Questions
Help with scriptable tiles PLEASE HELP URGENT!!! 1 Answer
Collision/scripting for tiles 0 Answers
How can I achieve movement on hextile? 0 Answers
How to store tile's rotation? 1 Answer