2D Toolkit Forum
2D Toolkit => Support => Topic started by: jakecattrall on May 24, 2013, 01:47:16 pm
-
I got this far:
GameObject _tileMap = GameObject.Find("TileMap");
Presumably that gets my tilemap object, but then what?
On a general note, it would be nice to see some detailed code examples in the script reference.
-
You shouldn't do that really - GameObject.Find is pretty slow, especially so if you do it every frame.
Check the Unity tutorials on how to reference objects, etc. The best way is to create a public variable in your object, and then simply drag and drop a reference in the Unity interface. No finding, and a reliable link to the object permanently.
Expanded the code samples in the tk2d 2.0 tutorial a bit more:
http://unikronsoftware.com/2dtoolkit/docs/2.00/
-
Sorry to bring up an old topic but I'm writing an editor script and can't use the drag and drop to make a reference to the tilemap. In this case, is GameObject.Find() my best option?
-
GameObject.Find is fine from editor scripts, its just very slow at runtime.