Hello Guest

Author Topic: Button Camera Bug  (Read 6321 times)

tasadar

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Button Camera Bug
« 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Camera Bug
« Reply #1 on: April 16, 2012, 10:34:47 am »
Does this camera you're using have the tag set to "MainCamera"?

tasadar

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Button Camera Bug
« Reply #2 on: April 16, 2012, 01:16:34 pm »
Does this camera you're using have the tag set to "MainCamera"?

nope.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Camera Bug
« Reply #3 on: April 16, 2012, 01:59:53 pm »
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.

tasadar

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Button Camera Bug
« Reply #4 on: April 16, 2012, 02:39:30 pm »
ok that solves it but i think you should add another if case there...

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button Camera Bug
« Reply #5 on: April 17, 2012, 02:25:45 pm »
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.