2D Toolkit Forum
2D Toolkit => Support => Topic started by: tasadar on April 16, 2012, 01:34:48 am
-
Hi, first message :) i've just started using 2dtk and so far so good.
i've just encountered a problem where the camera can not be found by the tk2dButton script. i dont provide a camera to the button(i cant actually since there is no camera in the scene, the camera that comes from the initial scene is used in all scenes) and as i checked in the Start function Camera.current,Camera.main & Camera.mainCamera are all null so it throws exception when you try to press the button. To fix it i replaced "Camera.main" with "Camera.allCameras[0]". I've no idea why it happens though.
-
Does this camera you're using have the tag set to "MainCamera"?
-
Does this camera you're using have the tag set to "MainCamera"?
nope.
-
That flag is how Unity decides what gets found using Camera.main - so if you set that tag, the buton should find the camera no problem.
-
ok that solves it but i think you should add another if case there...
-
I'm going to be revisiting the button class in a future update - I'm not particularly happy with how it works right now. I think automatically falling back could cause a lot of issues in the long run, but I do think I've got a decent solution to the problem. I'll post again when I have a more concrete example of how this will work.