Hello Guest

Author Topic: Creating a Camera at runtime  (Read 4454 times)

JakeTBear

  • Newbie
  • *
  • Posts: 10
    • View Profile
Creating a Camera at runtime
« on: February 05, 2014, 10:56:21 pm »
Hello,

Just like the title says, what would be the best way to create a camera at run time, what I am trying to do is to avoid using the editor for setup and instead having a prefab that does all the setups for me through script.

I would also need to create a second camera for UI, how would I set this up in code?

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Creating a Camera at runtime
« Reply #1 on: February 06, 2014, 01:12:26 am »
You can simply create it as you would any other component in Unity. A lot of the interface functions aren't fully exposed as its meant to be tweaked using the UI, and as a result it will probably be a bit more complicated to set it up than it would otherwise, but its definitely doable.

tk2dCameraEditor.DoCreateCameraObject is what runs when you create a camera in the UI. Thats probably a good starting point.

JakeTBear

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Creating a Camera at runtime
« Reply #2 on: February 06, 2014, 01:28:39 am »
perfect! thanks!