Search Unity

I simply want to change the background camera color on Start in code but cannot?

Discussion in 'Scripting' started by San_Holo, Dec 3, 2016.

  1. San_Holo

    San_Holo

    Joined:
    Sep 26, 2014
    Posts:
    135
    Hi there

    I had to post this as I'm confused... absolutely stuck on why I cannot change my scenes camera color on Start() with code... but I can in the inspector while running.

    I can change the camera background color in Update()

    But simply I can't do it... OK hows about a late update?
    scene kicks in, everything ready then at a point later on I change? but in Start() I'm stumped.

    please advise, btw I have no special filters installed and the camera is not being returned to black by anything else and it's set to the relevant settings to handle color

    https://docs.unity3d.com/ScriptReference/Camera-backgroundColor.html
     
  2. Quingu

    Quingu

    Joined:
    Jan 30, 2013
    Posts:
    637
    Update is called per frame. Camera color is drawn per frame. During Start you may be before your first frame is complete.
     
  3. San_Holo

    San_Holo

    Joined:
    Sep 26, 2014
    Posts:
    135
    OK thanks
     
  4. San_Holo

    San_Holo

    Joined:
    Sep 26, 2014
    Posts:
    135
    That idea of yours worked... a simple check in update and I applied a color and well there you go...