Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Switching code at run time

Discussion in 'Scripting' started by nintendoeats, Aug 16, 2014.

  1. nintendoeats

    nintendoeats

    Joined:
    Sep 15, 2012
    Posts:
    8
    I am making a Doom Clone (billboarded objects and enemies). I'm doing this by simply rotating the objects towards the main camera. I don't like this solution, but it seems to be the only one available.. I need two behaviors, one for editor time and one for run time, pointing the sprite at the scene camera and player camera respectively.

    I have a line of code that switches between cameras (using Sceneview.lastActiveSceneView), but I'm not sure of a good way to change between them. I tried assign a bool which defaults to false and flipping it to true at Start(), but of course Start() gets called at editor time to. So I'm kind of stuck and would be very happy for any thoughts (especially if they present a way to switch modes at run time)

    Thanks!
     
  2. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
  3. nintendoeats

    nintendoeats

    Joined:
    Sep 15, 2012
    Posts:
    8
    It did indeed. Not sure why I didn't think of that. Thanks :)
     
  4. _met44

    _met44

    Joined:
    Jun 1, 2013
    Posts:
    633
    Tunnel Vision ^^

    I come here to change my mind by fixing other people issues when it happens to me :p